Generate HTML5 Canvas Programmatically using C#

Create HTML5 Canvas using C#

In this article, I will show you how to generate the HTML5 Canvas element with graphics using C#. You can embed this feature within your .NET web applications for the dynamic generation and integration of HTML5 Canvas on web pages.

HTML5 Canvas element is used to draw graphics on the fly within the web pages. It provides you with an area that acts as a container of graphics or drawing objects. You can draw paths, boxes, texts, images, and other objects and then render them into image formats. Aspose.Imaging for .NET allows you to generate an HTML5 Canvas element using C# or VB.NET. This feature lets you create the HTML5 Canvas dynamically and set its source graphics file within your web applications such as ASP.NET application. So let’s proceed further to check how to create the HTML5 Canvas element using C# with Aspose.Imaging for .NET API.

C# API to Generate HTML5 Canvas – Installation

First of all, let’s have a look at how to install Aspose.Imaging for .NET within your .NET application. It’s as simple as pie. You may either add a reference to API’s DLL or install it using NuGet Package Manager.

PM> Install-Package Aspose.Imaging

Create a Web Page with HTML5 Canvas using C#

HTML5 Canvas allows you to set a source image that would appear within the canvas area. Using Aspose.Imaging for .NET, you can export CDR, CMX, EMF, WMF, and SVG graphics to an HTML5 Canvas without worrying about the HTML, JavaScript, and CSS code. The following are the steps to create an HTML page having an HTML5 Canvas element on it.

  • Load a graphics file that you want to set as a source of the canvas using Image.Load() method.
  • Create HTML5 Canvas by exporting the image using Image.Save() method.

The following code sample shows how to create HTML5 Canvas with graphics using C#.

Generate HTML5 Canvas Element Only using C#

In the previous example, we have generated a complete HTML page that contains the HTML5 Canvas element. However, in certain cases, you may need to generate the canvas element only to embed it within your web page. For such cases, you can configure Aspose.Imaging API to avoid generating the complete HTML page. The following are the steps to generate the HTML5 Canvas element.

The following code sample shows how to create the HTML5 Canvas element only using C#.

Conclusion

This article covered how to generate HTML5 Canvas dynamically using C# within .NET applications. We have seen how to create the complete HTML page containing an HTML5 Canvas or HTML5 Canvas only using Aspose.Imaging for .NET. You can explore more about the API using the documentation.

See Also

Posted in Aspose.Imaging Product Family | Tagged , , | Leave a comment

Perform OCR on Images using C# OCR Library

Perform OCR using C#

The OCR (Optical Character Recognition) is a well known and widely used technology to recognize and read text from images and scanned documents. In the OCR operation, the characters on the images are scanned, recognized, and converted into the digital form. The converted text can be validated and saved to perform further operations. In this article, I’ll show you how to perform OCR on images programmatically using C# within your .NET applications. The rest of the article is divided into the following sections.

C# OCR Library – Installation

Aspose.OCR for .NET is a powerful OCR library that lets you scan and read text from the images quite easily. It doesn’t require lengthy codes to get the OCR features up and running within your .NET applications. The following are the installation methods of the C# OCR Library.

Install via NuGet Package Manager

Simply search for Aspose.OCR in NuGet Package Manager and install it.

C# OCR Library

Install via Package Manager Console

The following is the command to install Aspose.OCR via Package Manager Console.

PM> Install-Package Aspose.OCR

Perform OCR on Images using C#

Let’s see how to perform OCR on an image that could possibly be a page of a scanned document. The following are the steps to perform this operation.

The following code sample shows how to perform OCR on the image using C#.

Perform OCR on Image with a Single Line of Text

In the previous example, we have performed OCR on the image which contained multiple lines of text. However, it is possible that the image contains only a single line of text. In such cases, you can tell the API to recognize the line only. The following are the steps to perform OCR on the image containing a single line.

The following code sample shows how to perform OCR on an image containing a single line of text using C#.

Perform OCR for Non-English Characters

Aspose.OCR doesn’t limit the OCR features for the English language and you can recognize the characters of other languages as well. The recognition process and the code will remain the same regardless of the text’s language. The following is the set of characters that can be recognized by the Aspose’s OCR API.

space!#$%&()
*+,./012
456789:;<=
>?@[\]_`{
}~ABCDEFG
IJKLMNOPQR
STUVWXYZa
cdefghijk
mnopqrstu
wxyzÂÀÁÃÄÆ 
ÇÈÉÊËÌÍÎÏÑ 
ÒÓÔÕÖÙÚÛÜẞ 
ßàáâãäæçèé 
êëìíîïñòóô 
õöùúûüÿŒœŸ 

Conclusion

This article demonstrated how to perform OCR on the images programmatically using C#. You can recognize the characters in the images containing single or multiple lines of text. Learn more about the C# OCR API from the documentation.

See Also

Posted in Aspose.OCR Product Family | Tagged , , , | Leave a comment

Create, Fill, or Edit Fillable PDF Forms Programmatically with C#

Fill PDF Form

PDF forms are frequently used to collect data and information. For example, Questionnaires are usually designed to collect responses for survey purposes. We interact with different fillable PDF forms in today’s digital world. Considering the huge scope and importance of PDF forms, Aspose.PDF for .NET API supports many features to work with PDF forms. Let us explore the following use cases using C# language in this article:

Create Fillable PDF Forms using C#

You can create a fillable PDF form from scratch using Aspose.PDF for .NET API. Here we will consider the basic example of adding two TextBoxField instances and RadioButton. However, one of the TextBoxField is single line while the other one is multi-line. Below are the steps to create a form in PDF document:

  1. Create an instance of Document class
  2. Add a blank page in PDF document
  3. Add TextBox Field in the form
  4. Set different properties of the fields including Font, Border etc.
  5. Add Radio Button in the form
  6. Save PDF document

Following code snippet shows how to create form in PDF using C#:

The screenshot below shows output PDF document containing form fields as specified in above code snippet:

PDF form

Fill, Modify, or Delete Form Fields in Existing PDF using C#

As we have explored creating a form in PDF document using C#, Aspose.PDF for.NET API supports working with existing PDF forms as well. Let us discuss the following features of the API.

i) Fill a Form Field in Existing PDF file using C#

For filling the PDF forms, we will continue with the PDF document that was created in the example above. Below are the steps to fill fields in an existing PDF document:

  1. Load source PDF document
  2. Get Textbox Fields and fill values
  3. Get Radio button field and select an option from the group
  4. Save filled PDF form

Following code snippet follows these steps and explains how to fill fields in a PDF document using C#:

Below screenshot shows filled form fields of PDF form using C#:

Fillable PDF

ii) Modify a Form Field in PDF Document using C#

Sometimes you may need to change value in any field of a PDF form. Changing a value in a form field is a basic use case that can be achieved with below steps:

  1. Load the PDF form
  2. Get a specific field using its name
  3. Modify field value
  4. Save the updated PDF document

Following code snippet shows how to change a value in a form field of PDF document:

It is noteworthy here that you can not only change the value of the form but other properties can be updated as well. For instance, the field has been marked as Read Only in the code snippet above.

iii) Delete a Form Field in Existing PDF File using C#

We have already learned about adding and filling PDF form fields. Now let us explore removing a form field. You need to follow the steps below:

  1. Load the PDF document
  2. Call Delete method with the name of the form field
  3. Save PDF Document

Following code snippet shows how to delete form field from PDF file using C#:

Preserve Extended Rights of PDF Forms using C#

A PDF form might have extended rights, also referred to as extended features, which you would want to preserve during form manipulation. You should save it incrementally while following the steps below:

  • Load the PDF document in Stream
  • Work with form
  • Save the file without any parameter

The following C# code snippet explains how to preserve extended rights of PDF form:

Use JavaScript in PDF Form using C#

You can use JavaScript in PDF form fields with Aspose.PDF for .NET API. Let us follow the below steps to achieve this requirement:

  1. Initiate an instance of Document class
  2. Add a TextBoxField on the first page at specific page coordinates
  3. Set up JavaScript
  4. Specify document action
  5. Save PDF document

Following code snippet shows how to add JavaScript in PDF form using C#:

The JavaScript gets the current date and time of the system when PDF document is opened and that value is populated into a text box.

Conclusion

In this article, we have learned different aspects of working with form in PDF documents. Creating, filling or editing PDF forms is simple with Aspose.PDF for .NET API. The API offers many such exciting features to work with different files. Let us know your feedback or comments via Free Support Forum.

See Also

Extract Text from PDF Documents

Posted in Aspose.PDF Product Family | Tagged , , , , , , , | Leave a comment

Create PDF Documents using C# with .NET PDF Library

Create PDF Documents using C#

PDF is a platform-independent document format that keeps the formatting and layout of its content consistent across different operating systems or machines. This is the reason various organizations use PDF format for generating invoices, receipts, reports, and other business documents dynamically. Aspsoe.PDF for .NET is a PDF library that helps you implement PDF automation in .NET applications. It allows you to create, edit, parse and convert PDF documents programmatically using C# or VB.NET. In this article, I’ll cover PDF generation features and show you how to create PDF documents from scratch using C#.

I’ll start by creating a simple PDF document and then proceed to add other elements to the document. The following is the list of features I am going to demonstrate in this article.

C# PDF Library – Installation

You can install Aspose.PDF for .NET using NuGet Package Manager or Package Manager Console using the following command. Alternatively, it can be downloaded from the Downloads section.

Install-Package Aspose.Pdf

Create a PDF Document using C#

Lets first create a PDF document containing a text fragment. The following are the steps to create a simple PDF document from scratch.

The following code sample shows how to create a PDF document using C#.

create pdf using C#

Apply Text Formatting in PDF using C#

Let’s now check out how to add text to a PDF document and use different formatting options. The following are the steps to perform this operation.

  • Use Document class to create a new PDF document or load an existing one.
  • Access the Page you want to place the text on.
  • Create an object of TextFragment and set the text and other formatting options such as position, font, color, size, etc.
  • Use the TextBuilder class to add the TextFragment object to the page.
  • Use the Document.Save() method to create the PDF document.

The following code sample shows how to add formatted text in a PDF document using C#.

create pdf with formatted text using C#

Create a Multi-Column PDF using C#

We often see that the text in newspapers, research articles, and other types of document is divided into two or more columns. In order to achieve this text division Aspose.PDF for .NET allows creating a multi-column PDF. The following are the steps to create a multi-column PDF.

The following code sample shows how to create a multi-column PDF using C#.

create multi-column pdf using C#

Insert Image in a PDF using C#

The following steps demonstrate how to insert images in PDF documents.

  • Create a new PDF document or open an existing one using Document class.
  • Get the page you want to insert an image in.
  • Add the image to the page’s images.
  • Use GSave, ConcatenateMatrix, and Do operators to place the image on the page.
  • Save the PDF document using Document.Save() method.

The following code sample shows how to insert an image in PDF using C#.

insert image in PDF using C#

Create Table in a PDF Document using C#

The table is used to organize the data in the form of rows and columns and to provide a quick overview of the information. In order to create a table in the PDF document, follow the below steps.

  • Create an object of Document class to create a new PDF or load an existing one.
  • Access the page you want to create a table in.
  • Create an instance of Table class.
  • Set the table’s border and cells’ border using the BorderInfo class.
  • Create and add a new Row to the Table.Rows collection.
  • Add cells to the Row.Cells collection.
  • Add the table to the page using Page.Paragraphs.Add() method.
  • Save the PDF document using Document.Save() method.

The following code sample shows how to create a table in PDF using C#.

create table in pdf using C#

Add Annotation in a PDF using C#

Annotations are graphical objects that are used to provide additional information about the content in the PDF documents. PDF format supports various annotations including text, highlight, line, notes, and etc. The following are the steps to add an annotation in PDF document.

The following code sample shows how to add an annotation to PDF using C#.

add annotation in PDF using C#

You can also add hyperlinks to a PDF document using the Link Annotation. The following are the steps to perform this operation.

The following code sample shows how to add a hyperlink to a PDF document using C#.

add hyperlink in PDF using C#

Create Bookmarks in a PDF using C#

Bookmarks are used to navigate to a particular section or page in the PDF documents. Aspose.PDF for .NET allows you to add or manipulate bookmarks. The following are the steps to create and add a bookmark in a PDF document.

The following code sample shows how to create a PDF document with bookmarks using C#.

create bookmark in PDF using C#

Conclusion

In this article, I have shown you how to create PDF documents from scratch using C#. The step by step guide and code samples demonstrate how to add text, image, table, annotation, hyperlink, and bookmarks in a PDF document programmatically. You can explore other features of Aspose’s .NET PDF Library using the documentation.

See Also

Posted in Aspose.PDF Product Family | Tagged , , , | Leave a comment

Create and Send Outlook Email Messages using Java

Create and Send Outlook Emails Java

Aspose.Email for Java is a powerful email processing API that provides all the basic as well as advanced features for email management. It allows you to create Outlook email messages, read existing emails, and convert MSG, EML, PST, OST, MBOX, and MHT messages to other formats from within your Java applications. In this article, I’ll demonstrate some basic yet important features of how to create and send Outlook emails using Java.

I am going to cover the following features of creating and sending emails in this article:

Java Email API – Installation

Aspose.Email for Java can be downloaded from the Downloads section or installed using the following Maven configurations.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-email</artifactId>
    <version>20.3</version>
    <classifier>jdk16</classifier>
</dependency>

Create Outlook Email Messages using Java

Aspose.Email for Java lets you create email messages and save them in your desired email format including EML, EMLX, MSG, and MHTML. The following are the steps to create an email message and save it as a file.

  • Create an instance of MailMessage class.
  • Set the message’s properties such as Subject, Body, To, CC, etc.
  • Add attachments if required.
  • Save the email message in your desired format using MailMessage.save() method.

The following code sample shows how to create an Outlook email message using Java.

Create an Email with HTML Body using Java

In the previous example, we simply created a plain text email and saved it as an email file. However, most of the emails today are created with HTML body to well organize and present the email’s content. In this case, HTML tags are used to specify the layout of the email. Let’s see how to create an email with an HTML body using Aspose.Email for Java.

The following code sample shows how to create an email with an HTML body using Java.

Create an Email with a Particular Encoding using Java

Aspose.Email for Java also allows you to set the desired text encoding for the email messages. The encoding standard is used to tell the email application or browser about how to interpret the characters in the email’s body. The following are the steps to create an email with a particular encoding standard.

The following code sample shows how to create an email with a particular encoding standard using Java.

Send Outlook Emails using Java

Once you have created an email, you can send it to its recipients using Simple Mail Transfer Protocol (SMTP). The following are the steps to send an email message using Aspose.Email for Java.

  • Create a new email message or load an existing one using the MailMessage class.
  • Create an instance of the SmtpClient class and set its host, username, password, and port.
  • Send email using SmtpClient.send() method.

The following code sample shows how to send an email via SMTP client in Java.

Send Emails Asynchronously using Java

Aspose.Email for Java also lets you send emails asynchronously. For this, you can use the SmtpClient.beginSend() method. The following code sample shows how to send emails asynchronously using Java.

Send Emails with a Read Receipt using Java

You can also add a request for a read receipt to the email messages. This feature allows you to receive a notification after the email has been received. The following are the steps to create and send an email message containing a request for read receipt.

The following code sample shows how to send an email containing a read receipt using Java.

Send Bulk Emails using Java

There might be the case when you need to send a bulk of different emails. In that case, you can simply add all the email messages to a MailMessageCollection object and pass it to SMTP client for sending. The following code sample shows how to send a bulk of emails using Java.

Conclusion

In this post, I have shown you how to create Outlook email messages and save them as EML, MSG, and MTH formats using Java. In addition, different ways of sending emails in Java using the STMP client are also discussed. You can learn more about Aspose’s Java Email Library using the documentation.

See Also

Posted in Aspose.Email Product Family | Tagged , , | Leave a comment