Aspose.BarCode for PHP via Java – PHP Barcode Generator and Reader API

PHP Barcode Generator Library

Barcodes are used to visually represent the data about an object in the machine-readable form. It is more popular to keep the data about products which can be read using the barcode scanners. In order to make it possible to generate and read a variety of barcodes in the PHP based web applications, we have released Aspose.BarCode for PHP via Java – an easy to use PHP barcode generator and reader API which is designed to work via Java Bridge.

In this article, I will present the recipes and code samples of how to generate and read the barcodes using PHP in your applications. After reading this article, you’ll be able to:

  • generate a barcode using PHP,
  • generate 2D barcodes such as QR using PHP,
  • generate barcodes with a customized appearance in PHP,
  • generate barcodes with a caption using PHP,
  • scan and read a barcode using PHP,
  • scan and read a barcode with a particular symbology using PHP.

Aspose.BarCode for PHP via Java – Installation and Usage

The installation of Aspose.BarCode for PHP via Java consists of a few simple steps. The following are the pre-requisites of the API:

You can download the complete package containing the API’s JAR file, Java Bridge.jar, Java.inc, and ready to run source code examples to read, generate and recognize barcodes using PHP. In order to run the examples, following the below steps:

  • Run JavaBridge server using run-bridge.bat (available in the package).
  • Open doc/examples/php_side/how_to_generate_barcode_examples.php in the browser or run it using the command line.

Generate Barcodes using Barcode Generator in PHP

Once you have set up the environment, you can begin working with barcodes in your PHP based application. Aspose.BarCode for PHP via Java supports a variety of barcode symbologies including:

  • Code128
  • Code11
  • Code39
  • QR
  • Datamatrix
  • EAN13
  • EAN8
  • ITF14
  • PDF417
  • and many more.

The following is the simple recipe to generate a barcode of any supported symbology using PHP:

  • Create an object of BarcodeGenerator class and initialized it with the desired encoding type and code text.
  • Generate barcode using BarcodeGenerator->save() method.

The following code sample shows how to generate a barcode using PHP.

Output

PHP Barcode Generator

Generate 2D Barcodes in PHP

Two-dimensional barcodes are represented as squares or the rectangles containing multiple dots. Aspose.BarCode for PHP via Java also supports various 2D barcode types such as QR, PDF417, etc. The following code sample shows how to generate a QR barcode using PHP:

Output

QR Code Generator in PHP

Generate Barcodes with a Customized Appearance in PHP

Aspose.BarCode for PHP via Java also lets you customize the appearance of the barcodes. For example, you can set the background, foreground or border color of the barcode. The following code sample shows how to generate a barcode with a customized appearance in PHP.

Output

Generate Barcode in PHP

Generate Barcode with Caption in PHP

You can also set as well as customize the appearance of the barcode’s caption. The following code sample shows how to set the barcode’s caption and customize its font.

Output

PHP Barcode Library

Read a Barcode using Barcode Reader in PHP

Along with the barcode generator, the API also provides you a powerful barcode reader to scan the barcodes and extract the data. The following is the recipe for how to read a barcode.

  • Create an instance of BarcodeReader and initialize it with the file’s path.
  • Read barcode using BarcodeReader->read() method.
  • Get barcode type and text using BarcodeReader->getCodeTypeName() and BarcodeReader->getCodeText() methods.

The following code sample shows how to read a barcode using PHP.

Recognize Barcode with a Particular Symbology in PHP

Barcode Recognition is the process of identifying the type of barcode we want to scan or read. In the previous example, we simply read a barcode without knowing its symbology type. However, in some cases, we know about the symbology of the barcode in advance. In such a scenario, we can speed up the scanning process by providing the barcode symbology explicitly to the barcode reader.

The following code sample shows how to read a barcode of a specific symbology using PHP.

Advanced Barcode Manipulation Features

Aspose.BarCode for PHP via Java provides a wide range of features for manipulating barcodes using PHP. You may have a look at the following documentation articles and simply port the Java code to PHP.

In case you would find anything confusing or difficult for you, feel free to contact us via our forum.

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

Find and Replace Text in Word Documents using C# .NET

This article covers various approaches to find and replace text in Word documents using C# in .NET or .NET Core applications.

Find and Replace is quite a useful feature of MS Word to quickly locate and replace the desired text in the documents. It becomes more handy and time-saving when you are working with longer documents. In cases when you need to find and replace text in hundreds of Word documents or you need to automate this process, you’ll definitely opt to do it programmatically. So in this article, I’ll show you how to find and replace text in Word documents programmatically in different scenarios using C#. Once you have read this article, you will be able to:

  • find and replace text in Word documents,
  • find and replace similar words in Word documents,
  • find and replace text using Regex,
  • find and replace text in the header/footer of Word document,
  • find and replace text with meta-characters in Word document.

First of all, create a new C# project (Console, ASP.NET, etc.) in Visual Studio and install Aspose.Words for .NET via NuGet Package Manager or Package Manager Console.

Installing via NuGet Package Manager

Finding and replacing text in Word DOC

Installing via Package Manager Console

PM> Install-Package Aspose.Words

After we have installed Aspose.Words for .NET, let’s now begin finding and replacing text in the following Word document.

c# find and replace text in word document

Find and Replace Text in Word Documents in C#

The following are the steps to find and replace a particular text in Word document using Aspose.Words for .NET.

The FindReplaceOptions class provides various options to customize the find/replace operations. The following code sample shows how to find and replace a particular word or string in a Word document using C#.

Output

find text in word document using c#

Find and Replace Similar Words in Word Documents using C#

You can also customize the API to find similar words and replace them with a particular word. For example, you can find the words “sad” and “mad” and replace them with a single word. The following code sample shows how to find and replace similar words in Word document using C#.

Output

c# replace text in docx file

Find and Replace Text using Regex in C#

There might be the case when you want to find and replace text that appears in a particular pattern. For example, you need to hide/replace all the email IDs in a Word document. In such cases, you can create a regular expression for email IDs and pass it to Document.Range.Replace(Regex, string, FindReplaceOptions) method.

The following code sample shows how to find and replace text based on a pattern in Word document.

Output

how to replace text in word document

Find and Replace Text in Header/Footer of Word Document using C#

You can also find and replace text in the header or footer sections of a Word document using the HeaderFooter class. The HeaderFooter.Range.Replace(string, string, FindReplaceOptions) method is used for this purpose. The following code sample shows how to replace text in the header/footer of Word document in C#.

Output

Word Document Finding and Replacing Text in C#.NET

Find and Replace Text with Meta-Characters in Word Documents using C#

There could be a scenario where a particular text or phrase is composed of multiple paragraphs, sections, or pages. In such cases, the simple find and replace method wouldn’t work effectively and we’ll have to handle the paragraphs breaks, section breaks or page breaks. For this, Aspose.Words allows you to use the following meta-characters in the search string or the replacement string:

  • &p: paragraph break
  • &b: section break
  • &m: page break 
  • &l: line break

The following code sample shows how to find and replace the text with a paragraph break in a Word document.

Output

find and replace text using regular expression C#

Explore more about the features offered by Aspose.Words for .NET here.

Related Article(s)

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

Create Outlook Messages and Send Emails using C# .NET or .NET Core

In this blog, you will learn how to create Outlook email messages (including MSG, EML, EMLX, or MHTML) and send emails synchronously or asynchronously using C# in .NET or .NET Core.

The email has become a primary source of exchanging messages and sharing content such as documents, images, or other types of files. The frequency of using emails is more within the online systems for sharing important notifications or documents with multiple entities. In such cases, preparing a template and sending emails to multiple stakeholders manually could be a time consuming and hectic task.

Here comes the need for an Email Automation Service using which you can create and send emails seamlessly. So in this article, I am going to teach you how to create email messages of popular Outlook formats and automate the process of sending emails programmatically. After reading this article, you will be able to:

  • create and save an email message in C#,
  • create an email with HTML body in C#,
  • create an email with a particular encoding in C#,
  • send emails synchronously using SMTP in C#,
  • send emails asynchronously using SMTP in C#,
  • and send bulk emails in C#.

Install Aspose.Email – C# Email Manipulation API

In order to automate the process of creating and sending email messages, we will use Aspose.Email for .NET which is a powerful email manipulation and processing API. It supports popular email formats including MS Outlook messages such as MSG, EML/EMLX, etc. You can directly download the API’s DLL or install it via NuGet Package Manager or Package Manager Console in Visual Studio.

PM> Install-Package Aspose.Email

After you have created a C# (Console, ASP.NET, etc.) application and installed Aspose.Email for .NET, you can begin creating and sending the emails in C#.

Create an Email Message in C#

In order to create or manipulate email messages, Aspose.Email provides the MailMessage class. This class lets you set all the properties of an email message (Subject, To, From and Body), add attachments, and save the message as different email formats such as EML, MSG, MHTML, etc. The following are the steps to create an email message:

  • Create an instance of MailMessage class.
  • Set the message’s properties.
  • Save the email message using MailMessage.Save() method.

The following code sample shows how to create and save an email message in C#.

Create an Email with HTML Body in C#

The HTML tags are used to make the body of the email more structured, presentable and enriched with different elements such as tables, images, lists, and so on. In case you want to create an email with having HTML body, you use MailMessage.HtmlBody property. The following code sample shows how to create an email with HTML body in C#.

Create an Email with a Particular Encoding in C#

You can also specify your desired encoding standard to tell the browser or email application about how to interpret the characters in the email’s body. The MailMessage.BodyEncoding property is used for this purpose. The following code sample shows how to set body encoding when creating an email using C#.

Send Emails Synchronously or Asynchronously in C#

Now, once you have created the email message, you can send it to its recipients synchronously or asynchronously. The SmtpClient class lets you send the email messages using SMTP (Simple Mail Transfer Protocol). The following are the steps to send an email in C# using Aspose.Email for .NET.

  • Create or load an email message using the MailMessage class.
  • Create an instance of SmtpClient class and set host, username, password and port number.
  • Send email synchronously or asynchronously using SmtpClient.Send or SmtpClient.BeginSend method respectively.

Send an Email Synchronously in C#

Send an Email Asynchronously in C#

Send Bulk Emails in C#

You can also create and send emails in bulk. The MailMessageCollection class is used to contain the collection of email messages you want to send. The following code sample shows how to send bulk emails in C#.

You can explore the documentation of Aspose.Email for .NET to learn more about the API.

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

Create MS Excel Files Programmatically in C# without MS Office

In this article, you will learn how to create MS Excel (XLS or XLSX) files programmatically in C# without installing MS Office.

Create Excel File in C# API

Spreadsheets nowadays have become an essential part of keeping, organizing and analyzing the data. Spreadsheets, such as MS Excel, are capable of doing calculations and sorting, generating graphs or charts, creating budgets, and performing many other accounting or data analysis tasks. Since automated solutions are more in business these days, the trend of creating and manipulating Excel documents (XLS/XLSX) has emerged and growing at a huge pace. This use case has raised the need for having an Excel automation solution.

In accordance with the above-mentioned scenario, this comprehensive article aims to show you some basic features for Excel automation in C# .NET applications. Ultimately, you’ll learn how to:

  • create Excel (XLS or XLSX) files dynamically using C#,
  • write data to the existing Excel file using C#,
  • create charts or graphs in an Excel file using C#,
  • and create a table in an Excel file using C#.

Aspose.Cells for .NET – C# Excel Automation API

In order to work with Excel documents, we will use Aspose.Cells for .NET which is a powerful API to create, read and manipulate spreadsheet documents including XLS and XLSX files. You can either download or install the API using one of the following ways:

Using NuGet Package Manager

C# Excel Automation Library

Using the Package Manager Console

PM> Install-Package Aspose.Cells

Create an Excel File (XLS or XLSX) in C#

An Excel file is also known as a Workbook which is composed of single or multiple worksheets containing the rows and columns to hold the data. Thus, a workbook acts as the container of the worksheets in an Excel file. So in order to create an Excel file, you will first create a workbook and then the worksheets within that workbook. The following are the steps to create an Excel file using Aspose.Cells for .NET.

  • Create an instance of Workbook class.
  • Access the first worksheet (created by default) of the workbook.
  • Access the desired cell(s) of the worksheet and put the value in the cell(s).
  • Save the workbook as an XLS or XLSX file.

The following code sample shows how to create an Excel XLSX file using C#.

Output

Create Excel Files in C#

Write Data to an Excel XLSX File in C#

In case you want to edit and write data to an existing Excel file, you can also do it in a similar fashion. Simply load the source Excel spreadsheet document using the Workbook object and access the desired worksheets and cells. The following are the steps to edit an existing Excel file.

  • Open Excel file in a FileStream object.
  • Create an instance of Workbook and initialize it with the FileStream object.
  • Access the worksheets and cells using the Worksheet and Cell classes respectively.
  • Save the workbook as an Excel .xlsx file.

The following code sample shows how to edit and write data to an existing Excel XLSX file in C#.

Create Charts or Graphs in Excel XLSX File using C#

Excel spreadsheets provide a fine way of analyzing or presenting the data visually using the graphs and charts. Aspose.Cells for .NET provides a complete set of classes to create and manipulate a variety of charts in Excel spreadsheets where each class is used to perform some specific tasks.

In order to create the charts in an Excel file, you’ll have to follow the following steps:

  • Add some data (to be used as a data source) to the worksheet by accessing its cells.
  • Add a new chart object to the worksheet using Worksheet.Charts collection by passing the type of chart using the ChartType enumeration.
  • Get the newly created chart from the collection in a Chart object.
  • Specify the cells’ range to provide the data source to the chart object.
  • Save the workbook as an Excel .xlsx file.

The following code sample shows how to create a chart in an Excel XLSX file in C#.

Output

Create chart in Excel in C#

Learn more about creating charts in Excel worksheets using C#.

Create a Table in Excel XLSX File in C#

You can also create a table from the range of cells in an Excel worksheet and add a row for the total (sum, count, etc.) in the table. The following are the steps to create a table in an Excel (XLSX) file using Aspose.Cells for .NET:

  • Load an Excel workbook or create a new one using Workbook class.
  • Add data to the cells of the worksheet.
  • Add a new ListObject to the worksheet.
  • Set ListObject.ShowTotals property to true.
  • Calculate the total and save the workbook as an Excel .xlsx file.

The following code sample shows how to create a table in Excel worksheet in C#.

Output

Create table in Excel Worksheet in C#

Learn more about working with tables in Excel worksheets using C#.

You may have a look at the documentation of Aspose.Cells for .NET to learn the advanced features for manipulation of Excel files in C#.

Related Article

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

Convert PDF Files to MS Word Documents (DOC/DOCX) in Java

PDF is one of the most commonly used formats for sending the document out to third parties. The reason behind this popularity is PDF’s compatibility across multiple platforms regardless of any hardware/software requirements. However, in some cases, you would want to convert the PDF document into an editable document format. PDF to Word DOC or DOCX could be the priority conversion option in such cases. To automate the conversion process, this article will showcase how to convert PDF to Word programmatically in Java.

So in this article, you will get to know how to:

  • Convert PDF to DOC using Java.
  • Convert PDF to DOCX using Java.
  • Convert PDF to Word (DOC/DOCX) with additional options.

API for PDF to Word Conversion in Java

Thanks to Aspose.PDF for Java – a PDF manipulation Java API that provides easy ways to convert PDF files to a variety of other formats including Word (DOC/DOCX). You can download and add API’s JAR file to your project or reference it 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-pdf</artifactId>
    <version>19.12</version>
</dependency>

Convert PDF to DOC using Java

Once you have referenced Aspose.PDF for Java in your application, you can convert any PDF document to DOC format in a couple of lines of code. The following are the steps required to perform this conversion.

The following code sample shows how to convert PDF to DOC in Java.

Input PDF Document

How to Convert PDF to Word in Java

Output Word Document

Convert PDF to DOC in Java

Convert PDF to DOCX using Java

DOCX is a well-known format for Word documents and in contrast to the DOC format, the structure of DOCX was based on the binary as well as the XML files. In case you want to convert PDF to DOCX format, you can tell the API to do so using the SaveFormat.DocX argument in Document.save() method.

The following code sample shows how to convert PDF to DOCX in Java.

Additional Options for PDF to Word Conversion

Aspose.PDF for Java also provides some additional options that you can use in PDF to Word conversion, such as the output format, image resolution, distance between text lines and so on. DocSaveOptions class is used for this purpose and the following is the list of options you can use:

The following code sample shows how to use DocSaveOptions class in PDF to DOCX conversion using Java.

Related Article(s)

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

Merge Multiple PDF Files into One PDF using C# .NET

Merge PDF files in C#

Aspose.PDF for .NET is a feature-rich API for creating, editing, reading or converting PDF documents. Along with other PDF manipulation features, Aspose.PDF for .NET also allows you to combine or merge PDF files programmatically in C# or VB.NET. In this article, you will learn how to:

  • Merge two PDF files into a single PDF file in C#.
  • Merge multiple (more than two) PDF files in C#.
  • Merge two or more PDF files using file streams in C#.

Before we start, let’s first have a look at the installation methods of Aspose.PDF for .NET.

Installing Aspose.PDF for .NET

You can install the API either using NuGet Package Manager or the Package Manager Console in Visual Studio.

Installing via NuGet Package Manager

Merge multiple PDF files in C# .NET

Installing via Package Manager Console

PM> Install-Package Aspose.PDF

Once you have installed the package, you can start merging the PDF files.

Merge Two PDF Files into One PDF in C#

The process of merging two PDF files into a single PDF is as simple as pie and can be performed only in two steps.

The following is the code sample to merge two PDF files using C#.

Merge Multiple PDF Files in C#

In case you want to merge more than two PDF files, you can do it using a string array containing the paths of all the PDF files to be merged. The following are the steps to perform this operation.

The following code sample shows how to merge multiple PDF files in C#.

Merge Multiple PDF Files using Streams in C#

There might be the case when you are not dealing with the files located on the disk. Instead, you want to merge PDF files available in the form of streams. In such a case, you can merge the PDFs directly using the Stream objects in the overloaded PdfFileEditor.Concatenate() methods. The following code samples show how to merge PDF files using the Stream objects in C#.

Merge Two PDF Files using Stream Objects

Merge Multiple PDF Files using Stream Objects

In case you are interested to explore more about the Aspose.PDF for .NET, take a look at the documentation.

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

Generate Word Documents from Templates Dynamically using Java

Generate word from template in java

The report generation process more often consists of populating the predefined document templates containing the placeholders for desired fields. The reporting engines take the template document as input, populate the placeholders with the data dynamically and generate the resultant reports. This article is also going to showcase a similar use case where you can generate the Word documents by populating the Word templates dynamically and programmatically using Java.

To generate Word documents from DOCX templates, we’ll use the LINQ Reporting Engine offered by Aspose.Words for Java API. LINQ Reporting Engine supports a variety of tags for text, images, lists, tables, hyperlinks, and bookmarks for Word templates. The template documents containing these tags are populated by the engine with data coming from Java objects as well as XML, JSON, or CSV data sources. So let’s begin generating the Word documents from the templates using Java.

This article will cover how to generate Word document from a template using:

  • values from the Java objects,
  • XML data source,
  • JSON data source,
  • and CSV data source.

Installing Aspose.Words for Java – Word Automation and Report Generation API

You can download Aspose.Words for Java JAR or add it to your Maven-based application using the following 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-words</artifactId>
    <version>20.1</version>
    <type>pom</type>
</dependency>

Generate Word Documents from Template using Java Objects

To begin the report generation, let’s first create a Word document by populating the template with values from the Java objects. In order to define a document template, create a new Word document, insert the following tags and save it as a DOCX document.

<<[s.getName()]>> says: "<<[s.getMessage()]>>."

In the above template, “s” will be treated as an object of Java class that will be used to populate the tags. So let’s create a class named Sender with two data members.

Now, it is time to pass the Word template to the LINQ Reporting Engine and generate the Word document based on the values of Sender‘s object. The following are the steps for generating the Word document:

  • Create the Document object and initialize it with the template’s path.
  • Create and initialize an object of Sender class.
  • Create an object of ReportingEngine class.
  • Build the report using ReportingEngine.buildReport() method that accepts the document template, the data source, and the name of the data source.
  • Save generated Word document using Document.save() method.

The following code sample shows how to generate a Word document from a Word template using the values of the Java object.

Output

generate word document by template with Java objects

Create Word Documents from Template using XML Data

Let’s now take one step further and see how to populate the Word templates using an XML data source in a bit complex scenario. The following is the XML data source that we’ll use to populate the Word template.

In this scenario, we’ll use the following tags in the template document for multiple records in the XML data source.

<<foreach [in persons]>>Name: <<[Name]>>, Age: <<[Age]>>, Date of Birth: <<[Birth]:"dd.MM.yyyy">>
<</foreach>>
Average age: <<[persons.average(p => p.Age)]>>

The Java code for generating Word document, in this case, would be the same and except for passing Java object as the data source, we’ll pass the XmlDataSource object in ReportingEngine.buildReport() method. The following code sample shows how to create a Word document by populating the document template using XML data source in Java.

Output

generate word document by template with XML in Java

Generate Word Documents from Template using JSON Data

Let’s now have a look at how to generate Word document from the DOCX template using a JSON data source. Following is the JSON data that we’ll use in this example.

In this example, we’ll generate the Word document containing a list of the clients grouped by their managers. In accordance with this scenario, the DOCX template will look like the following:

<<foreach [in managers]>>Manager: <<[Name]>>
Contracts:
<<foreach [in Contract]>>- <<[Client.Name]>> ($<<[Price]>>)
<</foreach>>
<</foreach>>

For loading JSON data source, Aspose.Words provides JsonDataSource class. The following code sample shows how to create a Word document from the template using a JSON data source in Java.

Output

create word document with JSON in Java

Generate Word Documents from Template using CSV Data

Last but not least, let’s check out how to generate the Word document by populating the Word template using the following CSV data source.

The following Word template will be used in this example:

<<foreach [in persons]>>Name: <<[Column1]>>, Age: <<[Column2]>>, Date of Birth: <<[Column3]:"dd.MM.yyyy">>
<</foreach>>
Average age: <<[persons.average(p => p.Column2)]>>

For dealing with CSV data sources, Aspose.Words offers CsvDataSource class. The following code sample shows how to generate a Word document using a CSV data source in Java.

Output

create word document with CSV in java

Learn more about LINQ Reporting Engine

LINQ Reporting Engine supports a wide range of tags for generating fully-featured Word documents dynamically in Java. You can explore more about these tags along with their syntax in this article.

In case you would have any questions or queries, you can post to Aspose.Words Forum.

Related Article(s)

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

Java API for Optical Mark Recognition and Processing in Images

Java OMR Library

Do you need a simple yet feature-rich OMR library for Java? Do you want to recognize optical marks in scanned images? Try Aspose.OMR for Java – A Java class library to perform the Optical Mark Recognition (OMR) operations in Java-based applications. Let’s have a quick walk through the features of the said Java API to see how to recognize optical marks in a variety of image formats and capture human-marked data from surveys, questionnaires or tests containing MCQs.

Dynamically Create OMR Template in Java

Aspose.OMR for Java provides a complete set of features from creating the OMR template to recognizing the optical marks to capture the data. The API supports generating the OMR template file or the image from simple text markups. You can simply pass the template’s text markup to the API and it will generate the template for you. The following is a sample text markup for an OMR template.

?text=Name__________________________________ Date____________

?grid=ID
sections_count=8
#What is Aspose.OMR main function?
() OCR () Capture human-marked data
() There is no main function () Enhance images
#Can Aspose.OMR process photos as well?
() Yes, indeed! () No
#Aspose.OMR is available on any platform, because it is:
() Cross-platform code () Cloud service
#Aspose.OMR works with any kind of OMR forms: tests, exams, questionnaires, surveys, etc.
() Yes, indeed! () No
#Excellent recognition results can be achieved only for filled bubbles at least for:
() 40% () 60% () 75% () 98%
#Do you have to mark up every question on the page?
(Yes) Yes, that will help a lot! (No) No
#Rate your preference from 0 to 9 with "0" being preference towards performance
and "9" being preference towards flexibility.
(0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
#I found aspose omr to be a useful tool. (5 - strongly agree, 1 - strongly disagree)
(5) (4) (3) (2) (1)

?text= Answer sheet section
?answer_sheet=MainQuestions
elements_count=10
columns_count=5

?text=Sign________________________________

You can simply save the text markup in a text file with .txt extension. Once done, you can generate the template using the following steps:

The following code sample shows how to generate the OMR template from text markup using Java.

Output

Optical Mark Recognition (OMR) in Images using Java

In order to perform OMR in images, you just need two things – the prepared OMR template (.omr) and the images (user-filled forms/sheets) to perform OMR on. The API supports the OMR for the following image formats:

The following are the steps to perform OMR in images:

The following code sample shows how to recognize optical marks in images using Java.

Using a Custom Recognition Threshold for OMR

You can also fine-tune the OMR results by defining a custom threshold between 0 to 100. Increasing the threshold makes the API more strict in recognizing the answers. The threshold values can be set in TemplateProcessor.recognizeImage() method as the second parameter as shown in the following Java code sample.

Recalculating the OMR Results

In some cases, you may want to recalculate the OMR results with different threshold values. Instead of calling TemplateProcessor.recognizeImage() again and again in such cases, you can configure the API for automatic recalculation using TemplateProcessor.recalculate() method to improve image processing efficiency. The following code sample shows how to implement the recalculation of the OMR results.

Contact us via our forum for any questions or queries.

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

Create Pivot Tables in Excel and Sort or Hide Data using C# .NET

C# Library to Create and Sort PivotTable in Excel

In this article, you’ll learn how to create Pivot Tables in Excel and sort or hide the Pivot Table data or items programmatically in C# using Aspose.Cells for .NET – .NET API to create and manipulate Excel spreadsheets without requiring Microsoft Excel.

Things have gone digital and the automated solutions for the generation and manipulation of Excel spreadsheets are widely used. The Pivot Tables in Excel are extensively used to summarize and analyze the data. Whereas sorting the data in the Pivot Tables is very useful for critical inspection of the huge data in Excel spreadsheets. The sorting of data in Pivot Tables can be applied for arranging the items alphabetically (A-Z or Z-A) for text values or from the highest to lowest or lowest to highest values in case of numbers.

Based on the importance of Excel Pivot Tables, this article aims to show you how to:

  • create a Pivot Table in Excel,
  • sort Pivot Table by row field values,
  • sort Pivot Table by column field values,
  • and hide Pivot Table rows.

For the demonstration, the following sample Excel spreadsheet will be used throughout the examples.

Create Pivot Table in Excel in C#

Create a Pivot Table in Excel using C#

Let’s first check out how to create an Excel Pivot Table in C# using Aspose.Cells for .NET. Once we have created the Pivot Table, we’ll hide the rows and sort the data based on its column or the row fields. The following code sample shows how to create an Excel Pivot Table.

Output

Pivot Table in Excel in C#

Sort Pivot Table by Row Field Values in C#

In the previous section, we simply created the Pivot Table using the data in the Excel spreadsheet. Now, we’ll create another Pivot Table and apply the sorting on the data. The following code sample creates and sorts the PivotTable by “SeaFood” row field values.

Output

Sort Pivot Table in Excel in C#

Sort Pivot Table by Column Field Values in C#

You can also sort the data in a Pivot Table by the column field values. The following C# code sample applies the sorting on field values of the “28/07/2000” column.

Output

Sort and Hide Data in Pivot Table in Excel

Hide PivotTable Rows in C#

You can hide the rows in the Excel Pivot Table based on certain conditions you want to apply. The following code sample shows how to hide particular rows in the Pivot Table using C#.

Have a look at the documentation of Aspose.Cells for .NET for more details on how to work with Pivot Tables in Excel using C# in any .NET based application. Reach us at our forum in case of any questions or queries.

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

C# .NET Word Automation – Create, Edit or Convert MS Word Documents Programmatically

C# .NET Word Automation

Are you looking for a .NET Word Automation solution to generate and process word processing documents in C#? Do you want to create, read, edit/modify and convert Word documents programmatically without requiring MS Office? Let’s try out Aspose.Words for .NET API – A complete set of features for generation and processing of Word documents (.doc, .docx, etc.) in your .NET or .NET Core based applications.

MS Word document automation and report generation are in high demand by enterprises. Aspose.Words for .NET is a complete and feature-rich Word automation solution to create, edit or analyze Word documents in such cases. This article covers all the basic features required for generating and manipulating the Word documents programmatically using C#. Once you read this article, you will be able to:

  • Create a Word (.doc, .docx) document.
  • Edit or modify a Word document.
  • Convert a Word document to other formats such as PDF.
  • Parse a Word document.

Aspose.Words for .NET – C# Word Automation API

Aspose.Words for .NET DLL can be downloaded from here. Another option is to install it via NuGet Package Manager or Package Manager Console in Visual Studio.

Using NuGet Package Manager

C# .NET Word Automation Library

Using Package Manager Console

PM> Install-Package Aspose.Words

Create a Word Document Dynamically using C#

Let’s start our journey by creating a new Word document using Aspose.Words for .NET. The DocumentBuilder class of the API contains all the methods and properties to create Word documents from scratch. In combination with the Document class, DocumentBuilder supports inserting elements such as text/paragraphs, checkboxes, tables, lists, images and the other objects that a Word document can contain. Moreover, you can specify the font and other formatting options using this class. The following are the steps to create a Word document using DocumentBuilder class.

  • Create a new Document object.
  • Create and new DocumentBuilder object and initialize it with the Document object.
  • Insert/write elements using the DocumentBuilder object.
  • Save the document using Document.Save method.

The following code sample shows how to create a Word DOCX document with formatted text, table, and image in C#.

The following is the document we get after executing the above code.

Create Word document in C# .NET

Visit these articles to explore more about the elements you can add to a Word document using Aspose.Words for .NET.

Edit or Modify a Word Document in C#

You can also edit or modify the existing Word documents using Aspose.Words for .NET. Aspose.Words Document Object Model classes let you access and modify the document’s elements as well as their formatting. DOM is actually the in-memory representation of the document. To understand the document representation as DOM, please see the DOM overview.

Let’s now check out how to edit an existing element in a Word document. Suppose we need to update the text “This is the first page.” in the document that we have recently created. Since this is the first paragraph in the first section of the document, we can access it by specifying the index of the first section and the first paragraph. The following code sample shows how to edit the paragraph in the Word document using C#.

The following is the updated Word document.

Word Automation in C# .NET

Convert Word Document to Other Formats in C#

Along with creating and manipulating Word documents, Aspose.Words for .NET also allows converting a document to other formats including (but not limited to) PDF, XPS, EPUB, HTML, and image formats such as BMP, PNG or JPEG. The following code sample shows how to convert a Word document to PDF in C#.

Visit this article to see how to convert a Word document to other formats.

Parse a Word Document in C#

You can also parse a Word document by extracting its content as a plain text. The following code sample shows how to extract text from a Word document and save it into a .txt file.

Visit the documentation of Aspose.Words for .NET for a complete Developer’s Guide. In case you would find anything confusing for you, do let us know via our forum.

Related Article(s)

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