Convert XML to PDF – Easy XML to PDF Conversion

XML to PDF

In this article, we will be converting XML files to PDF using C#. Aspose.PDF for .NET API extensively supports the XML conversion feature because of the inclusions of many related enhancements, as requested by the API users. You can elevate your .NET applications with this efficient feature of exporting XML to PDF. Let us consider following use cases related to XML conversion using C#:

Convert XML to PDF

For converting an XML to PDF, you need to follow the XML Schema of Aspose.PDF for .NET API which is available as XSD file. Following is an XML file that we will be converting to PDF as a Hello World demonstration.

<?xml version="1.0" encoding="utf-8" ?>
<Document xmlns="Aspose.Pdf">
  <Page id="mainPage">
    <TextFragment>
      <TextSegment>Hello</TextSegment>
    </TextFragment>
 
    <TextFragment>
      <TextSegment>World!</TextSegment>
    </TextFragment>
  </Page>
</Document>

You need to follow the steps below to convert XML to PDF file:

  1. Initialize an object of Document Class
  2. Load XML file with BindXml method
  3. Save the converted PDF file

Following code snippet shows how to convert XML to PDF in C#:

Use HTML in XML and Convert to PDF

Sometimes you might need to use HTML in XML prior conversion to HTML. Aspose.PDF for .NET API supports this feature as well. However, HTML and XML tags are quite similar. Therefore, you need to specify the CDATA tag so that the HTML is not parsed as XML markup. Below sample XML file includes HTML denoted by CDATA to avoid any anomaly:

<?xml version="1.0" encoding="utf-8" ?>
<Document xmlns="Aspose.Pdf">
  <Page id="mainSection">
    <HtmlFragment>
      <![CDATA[
        <font style="font-family:Tahoma; font-size:40px;">This is Html String.</font>
        ]]>
    </HtmlFragment>
  </Page>
</Document>

You can convert this XML file to PDF with following steps:

  1. Instantiate Document class object
  2. Load the input XML file
  3. Save the output PDF file

Below code snippet shows how to convert an XML file, containing HTML, to PDF in C#:

Convert XML and XSLT to PDF

Sometimes you may have an existing XML file that contains important application data and you want to generate PDF reports using that XML file. In such scenarios, you can create XSLT file to transform your existing XML document to Aspose.PDF’s compatible XML document. Then you can proceed to convert XML to PDF. Let us learn this with simple and basic example:

<?xml version="1.0" encoding="utf-8" ?>
<Contents>
  <Content>Hello World!</Content>
</Contents>
<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="text()"/>
    <xsl:template match="/Contents">
    <html>
      <Document xmlns="Aspose.Pdf" IsAutoHyphenated="false">
        <PageInfo>
          <DefaultTextState
                            Font = "Helvetica" FontSize="8" LineSpacing="4"/>
          <Margin Left="5cm" Right="5cm" Top="3cm" Bottom="15cm" />
        </PageInfo>
        <Page id="mainSection">
          <TextFragment>
            <TextSegment>
              <xsl:value-of select="Content"/>
            </TextSegment>
          </TextFragment>
        </Page>
      </Document>
    </html>
</xsl:template>
</xsl:stylesheet>

You can notice that the XML file does not follow the XML schema of Aspose.PDF for .NET API. However, the XSLT file transforms it to required compatibility. Now you can follow the steps below to convert such XML using XSLT to PDF:

  1. Initialize PDF Document
  2. Bind XML and XSLT file
  3. Save the output PDF document

The code snippet below is based on these steps which show how to convert XML to PDF in C#:

Conclusion

We have learned how to convert XML to PDF file provided the XML follows the mentioned schema of the API. Considering the popularity and usability of HTML tags, we have also considered the scenario when you need to include some HTML in the source XML file. Moreover, we have also explored how to convert XML and XSLT to PDF when the existing XML file does not follow the schema.

See Also

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

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

Merge Multiple PDF Files into a Single PDF using Java

Merge PDF Files into Single PDF

In various scenarios, you come across the need of merging two or more PDF documents into a single file. For example, PDF merging allows you to combine similar kinds of documents. Furthermore, you can merge multiple PDFs into a single PDF before sharing it online or sending it to someone. In this article, I’ll demonstrate how to automate this feature and merge two or multiple PDF files programmatically using Java.

Java API to Merge PDF Files

Aspose.PDF for Java is a feature-rich PDF API that lets you merge multiple PDF documents quite easily within a few lines of code. You can either download the API’s JAR or install it in your Maven-based application using the following configuration.

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>20.5</version>
    <classifier>jdk17</classifier>
</dependency>'

Merge Two PDF Files into Single PDF using Java

Lets first check out the simple scenario of merging only two PDF files and this can be achieved within a couple of steps.

The following code sample shows how to merge two PDF files into a single PDF using Java.

Merge Multiple PDF Files using Java

In the previous example, we have merged only two PDF files into a single PDF. However, there could be a case when you need to merge more than two PDF files. In such cases, you can pass an array to the PDF files’ paths to the concatenate method. The following are the steps to perform this operation.

The following code sample shows how to merge multiple PDF files into a single PDF using Java.

Merge PDF Files using InputStream in Java

In case you are dealing with the PDF files in the form of InputStream, you can directly pass the InputStream objects and get the merged PDF as an OutputStream object. The following are the steps to merge PDF files loaded into InputStream objects.

The following code sample shows how to merge PDF files using InputStream objects in Java.

Conclusion

In this article, you have learned how to merge multiple PDF files into a single PDF programmatically using Java. The code samples and step by step guide shows how to merge two or more than two PDF files using physical paths or InputStream objects. You can learn more about the Java PDF Merger library using the documentation.

See Also

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

Convert EPUB to PDF – Simple Steps with Screenshots

EPUB to PDF Convert

Ebooks are an example of how technology has changed everyday life for us. You can easily read and share ebooks in the form of an EPUB file. However, sometimes you might prefer to convert EPUB to PDF file because of the strengths of PDF file format. For instance, you can digitally sign, encrypt, or password protect a PDF file. In this article, we will convert a file from EPUB to PDF format with the following use cases:

We will be performing all of these conversions using Aspose.HTML for .NET API. You can request for free 30 days trial license to test the API in its full capacity. Moreover, you can configure the API simply by installing it from NuGet gallery. Let us move on to EPUB file conversion scenarios:

Convert EPUB to PDF using C#

You can convert EPUB to PDF by following the steps below:

  1. Load input EPUB file
  2. Initialize an object of PdfSaveOptions Class
  3. Call the ConvertEPUB method

These steps are followed by below code snippet which shows how to convert EPUB to PDF using C#:

Resultantly, the PDF file is created with high quality and high fidelity rendering. Moreover, the size of the generated PDF file is also reasonable. You may compare the following screenshots to compare rendering quality for the files:

Input EPUB File Preview

EPUB to PDF

Output PDF File Preview

Convert EPUB to PDF

You can notice that even minor details are noticeable in both the files. Therefore, it speaks volumes about the capabilities of exporting EPUB to a PDF file with Aspose.HTML for .NET API.

Convert EPUB to PDF with Password Protection using C#

We have already learned the basic conversion of EPUB file to PDF. Let us proceed to export EPUB to a password-protected and encrypted PDF document. You need to follow the steps below to set up encryption with user and owner password for the output PDF document:

  1. Load input EPUB file
  2. Initialize PdfEncryptionInfo object with necessary parameters
  3. Instantiate object of PdfSaveOptions Class
  4. Convert from EPUB to PDF

Below code snippet converts EPUB to PDF with specified Encryption routine and respective passwords.

The screenshot below displays different properties of PDF document as we have set in the code. Respective properties have been marked on this screenshot, for your convenience.

Convert EPUB to PDF with Page Setup using C#

First of all, the page setup term here is referring to setting up page size, page margin, and background color. Aspose.HTML for .NET API gives you total control on the file conversion process. You can specify the output requirements for the PDF document as per your requirements. In this example, we will be setting up some page related properties by following the steps below:

  1. Load input EPUB file
  2. Instantiate PdfSaveOptions object
  3. Set page size and page margin
  4. Set the background color of pages
  5. Convert to a PDF file

Following code snippet shows how to convert EPUB to PDF using C#, which is based on the steps listed above:

Conclusion

We have learned different possibilities of converting EPUB to PDF documents. These use cases can be helpful for securing Ebooks because their online presence will become more secured because neither the encrypted PDF files nor their metadata will be accessible to the search engines in any way. There could be many other advantages as well which may need the conversion of EPUB file format.

Related Post

Font Kerning and Emulation support in Aspose.HTML API

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

Find and Replace Text in Word Documents using Java

In this article, I’ll demonstrate how to find and replace text (words or phrases) within Word (DOC/DOCX) documents programmatically using Java. The step by step guide and code samples will cover various scenarios of finding and replacing text in Word documents.

Find and replace text in Word documents

MS Word provides an easy way to find and replace text in the documents. One of the popular use cases of finding and replacing text could be removing or replacing sensitive information within the documents before they are shared among various entities. However, the manual process may require you to install MS Word and update every document separately. In such situations, it would be handy and time-saving especially when you have integrated find and replace features within your desktop or web application. So let’s begin and see how to find and replace text in Word documents using Java in various scenarios.

Java API to Find and Replace Text in Word DOC/DOCX

In order to implement the find and replace feature, we’ll use Aspose.Words for Java which is a powerful, feature-rich, and easy to use Word processing API for Java platform. You can either download its JAR or install it within 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.5</version>
    <classifier>jdk17</classifier>
</dependency>

Find and Replace Text in Word DOC/DOCX File using Java

Let’s start by addressing a simple find and replace scenario where we will find the word “Sad” within the input Word document. The following are the steps to perform this operation.

The following code sample shows how to find and replace text in Word DOCX using Java.

Below is the input Word document that we have used in this article.

find and replace text in DOCX using Java

The following is the output after finding and replacing the word “sad”.

find and replace a word

Find and Replace Similar Words in DOC/DOCX using Java

You can also customize the API to find and replace text based on the similarity. For example, the words “sad”, “mad” and “bad” are following a similar pattern that ends on “ad”. Email IDs are another example of such a text. In such cases, you can define a regex pattern to find and replace all the text occurrences having a particular pattern. The following are the steps to achieve this.

The following code sample shows how to find and replace similar words based on a particular pattern using Java.

The following is the screenshot of the Word document after updating similar words.

find and replace similar words using Java

Replace Text in the Header/Footer of Word Document

Aspose.Words also allows you to find and replace text only in the header/footer of the Word document. The following are the steps to perform this operation.

The following code sample shows how to find and replace text in the header/footer of Word document using Java.

The following screenshot shows the updated text in the footer of the Word document.

find and replace text in footer

Find and Replace Text with Meta-Characters in DOCX using Java

There could be the case when you need to find and replace a phrase that is divided into multiple lines or paragraphs. In such cases, you will have to take care of the paragraph, section, or line breaks. Aspose.Words for Java makes it simple for you to handle such cases quite easily. The following are the meta-characters that you can use for different breaks:

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

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

The following is the screenshot of the output Word document.

find and replace text with meta characters

Conclusion

In this article, you have seen how to find and replace text in Word DOC/DOCX documents programmatically using Java. Various scenarios of finding and replacing text in DOCX have been addressed with the help of code samples. You can learn more about Aspose.Words for Java from the documentation.

See Also

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

Convert OXPS or XPS to PDF Programmatically using C#

XPS and OXPS files are frequently used for printing because of their resolution independence. However, sometimes we need to convert XPS to PDF or OXPS to PDF. Aspose.Page for .NET API lets you perform these conversions with high-fidelity and quick rendering. Let us explore the following use cases:

Convert XPS to PDF using C#

XPS to PDF conversion is simple with Aspose.Page for .NET API. We will be learning the following approaches to perform XPS file conversion:

i) Convert Specific Pages of XPS to PDF in C#

For converting selected pages of XPS document to PDF, please follow the steps below:

  1. Initialize XPS input stream
  2. Load XPS document from stream
  3. Initialize PdfSaveOptions object
  4. Specify page numbers for conversion
  5. Save the document as PDF file

Below code snippet follows these steps and shows how to convert XPS to PDF using C#:

This code snippet uses an XPS document containing several pages, as the input file. Whereas, only page numbers 1 and 3 are converted to PDF as specified in the code snippet. Following screenshot displays 2 pages rendered to PDF document:

XPS to PDF

ii) Convert All Pages of XPS to PDF in C#

You can convert a whole XPS file to PDF. Follow the steps below and all pages of the XPS file will be converted to a PDF file:

  1. Load input XPS file
  2. Initialize options object with necessary parameters
  3. Create an instance of PdfDevice for rendering
  4. Export XPS to PDF document

Below code snippet is based on all these steps which shows how to convert XPS file to PDF using C# language:

Convert OXPS to PDF using C#

OXPS format is an updated and advanced form of XPS file format. However, such files are not supported by some old operating systems. Aspose.Page for .NET API is capable of converting OXPS files as well. Let us proceed to learn the following usage scenarios:

i) Convert Some Pages of OXPS to PDF in C#

An OXPS file may contain many pages and any number of pages can be converted to PDF by following below steps:

  1. Load OXPS file
  2. Declare PdfSaveOptions object
  3. Set the page number(s) that you want to convert
  4. Render OXPS to PDF

Following code snippet shows how to convert OXPS to PDF using C#. It converts the first page of the OXPS file to PDF as mentioned in the code snippet.

ii) Convert All Pages of OXPS to PDF in C#

Converting all pages of OXPS is simple and related to the example we have considered above. Let us follow the steps below and convert all pages of OXPS file to a single PDF document:

  1. Initialize OXPS input stream
  2. Load the OXPS file from stream
  3. Instantiate an object of PdfSaveOptions class
  4. Export OXPS to PDF file

Below code snippet follows these steps one by one and converts OXPS to PDF using C#:

Conclusion

In this article, we have learned how to convert XPS to PDF and OXPS to PDF with different use cases. We have learned with C# examples and screenshots about high fidelity, efficient, and quick file format conversion. You can further explore Aspose.Page for .NET API with the help of API documentation and API references. Moreover, feel free to ask any inquiry at Free Support Forums.

See Also

Create or Edit XPS Documents Programmatically in C++

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

Convert GIF Images to TIFF, PDF, PNG, JPG, or BMP using C#

Convert animated GIF using C#

Animated GIF (Graphics Interchange Format) contains a number of image frames in a particular order within a single file. These frames are shown in a sequence to create the animation. There could be various use cases when you need to convert animated GIFs to other multi-page or raster image formats. The multi-page formats include TIFF as well as PDF whereas raster images could be PNG, JPG, BMP and etc. In this article, I’ll show you how to convert animated GIF images to TIFF, PDF, PNG. JPG, and BMP images programmatically using C#. The code samples provided in this article can easily be ported to VB.NET as well.

C# GIF Converter API

Aspose.Imaging for .NET is a feature-rich API that supports manipulating a wide range vector or raster image formats including the animated GIFs. It allows converting animated GIF to other multi-page formats as well as raster images within the .NET application. You can install the API using NuGet Package Manager or download and reference its DLL file manually.

Convert Animated GIF to TIFF using C#

TIFF is a multi-page image format that keeps multiple images within a single file. Since the animated GIF also contains a sequence of frames, you can export all or selected frames to the TIFF format. In this conversion, each frame in GIF will be converted to a page in the TIFF image. The following are the steps to convert an animated GIF to TIFF format using Aspose.Imaging for .NET.

The following code sample shows how to convert GIF to TIFF using C#.

Convert Animated GIF to PDF using C#

In an animated GIF to PDF conversion, each frame of the GIF is converted into a separated page within the PDF. Just like GIF to TIFF, you can specify the range of frames you want to get in the converted PDF file. The following are the steps to convert an animated GIF to PDF.

The following code sample shows how to convert animated GIF to PDF using C#.

Convert a GIF Frame to PNG, JPG, or BMP using C#

Since animated GIF contains a sequence of frames, you can extract the desired frame and convert it to raster images such as PNG, JPG, BMP, etc.

Convert GIF Frame to PNG using C#

The following are the steps to convert a GIF frame to a PNG image.

The following code sample shows how to convert a frame of an animated GIF to PNG using C#.

Convert GIF Frame to JPG using C#

Aspose.Imaging exposes JpegOptions class to set the options while converting a GIF frame to the JPG image. The following code sample shows how to convert a frame in GIF to JPG using C#.

Convert GIF Frame to BMP using C#

For GIF to BMP conversion, the API provides the BmpOptions class. The following code sample shows how to convert a GIF frame to BMP using C#.

Conclusion

In this article, you have learned how to convert an animated GIF to multipage formats such as TIFF and PDF using C#. Furthermore, we have seen how to extract a particular frame from the animated GIF and convert it to the PNG, JPG, or BMP images. You can explore more about Aspose.Imaging for .NET using the documentation.

See Also

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

Add Fill Layer in Photoshop Document (PSD file) – Easy Guide

Add fill layer in photoshop

Photos are a very useful way of reflecting information. PSD format files are used to create images. However, there could be scenarios like editing several Photoshop files along the same lines. For instance, a photo processing application may need to add a layer in multiple Photoshop documents, along with other operations. Aspose.PSD for .NET API offers many features to work with PSD, PSB, AI, and many other file formats. Let us explore the following use cases related to adding a layer in PSD files:

Add Fill Layer at Runtime in Photoshop Document using C#

Aspose.PSD for .NET API supports creating a fill layer in a PSD file. You do not necessarily need to load the layer from an existing file. Simply follow below steps to add a fill layer at runtime in the PSD file:

  1. Initialize an instance of PsdImage class with page dimensions
  2. Create an instance of FillLayer class
  3. Set Display Name for the layer
  4. Add the layer to the image

Following code snippet shows how to add fill layer in Photoshop using C#:

This code snippet will generate a PSD file of specified dimensions where the screenshot below is showing names of three fill layers exactly as set by C# code above:

Add Layer in Photoshop

Add Existing Fill Layer in PSD file using C#

We have already learned about creating and adding new fill layers. Let us check out how to add layer from existing Photoshop file. Following are the possibilities of adding existing fill layers:

i) Add Layer with Pattern Fill using C#

A pattern fill may have an image, line, or shadow to fill the area. You need to follow the steps below for adding a layer with Patten Fill in a PSD image:

  1. Load source PSD file
  2. Iterate through all layers and check for FillLayer
  3. Set different settings for the layer
  4. Edit the Fill Layer
  5. Save the image

The code snippet below shows how to add fill layer with Pattern fill using C#:

ii) Add Layer with Gradient Fill using C#

You can also use Gradient fill for filling a layer in Photoshop Document. Aspose.PSD for .NET API supports the following types of Gradient fills:

  • Linear
  • Diamond
  • Radial
  • Reflected
  • Angle

Below are the steps for adding a layer with a gradient fill:

The code snippet below is based on these steps and shows how to add GradientFill layer in Photoshop document using C#:

This code snippet will generate five different files, each with a different kind of Gradient fill in the layer of the PSD file.

iii) Add Layer with Color Fill using C#

You can add a layer with Color fill in Photoshop Document, a PSD file. Follow the steps below for adding or creating a Fill Layer with Color Fill:

  1. Load source PSD image
  2. Check all layers and find FillLayer
  3. Read fill settings of the layer
  4. Set fill color and update the layer
  5. Save the PSD image

The code snippet below is based on the aforementioned steps that show how to add fill layer in Photoshop Document using C#:

Conclusion

In this article, we have explored few of the many possibilities of adding fill layers in PSD files. We have learned how to add a layer from scratch, as well as how to add layers from existing PSD files. Different types of Gradient fill layers are also addressed along with examples. There are many other exciting features offered by Aspose.PSD for .NET API. Please feel free to get in touch with us via Free Support Forums in case of any concerns.

See Also

Find Layers and Update Layer’s Text or Image in Photoshop Files

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

Find Layers and Update Layer’s Text or Image in Photoshop Files using C#

In this article, you will learn how to find layers and update the layer’s text or image within Photoshop’s PSD files dynamically using C# .NET.

PSD is the default format used by Adobe Photoshop for saving its documents in a multilayered structure where each layer contains the text, images, graphical objects, and other supported elements. There could be the case when you have a PSD template and you need to create several resultant images by populating the text and image layers within the template. An example of such a scenario is creating employee cards within an organization. In order to automate this process, I’ll show you how to:

C# Library to Find and Update PSD Layers

Aspose.PSD for .NET allows creating and modifying PSD files without installing Adobe Photoshop or Illustrator. The API can be handy in the scenario where you need to update PSD layers dynamically using C# or VB.NET. You can install the API using NuGet Package Manager or download and reference its DLLs manually.

Find and Update Text Layers in PSD Files using C#

Aspose.PSD for .NET allows you to find the desired layer in PSD files using the layer’s name. Once you find the layer, you can update its content. The following are the steps to find and update a text layer in a PSD file.

The following code sample shows how to find and update the text layer in the PSD file using C#.

Below is the screenshot of the input PSD file we have used in this example:

Find layer in PSD using C#

The following is the resultant PSD file having updated text layer:

Update text layer in PSD using C#

Find and Update Image Layers in PSD Files using C#

In order to deal with graphical objects such as images, Aspose.PSD for .NET exposes Graphics class. This class is used to clear or draw the graphics within the PSD layers. The following are the steps to find a PSD layer and update its image.

The following code sample shows how to find and update image layers in the PSD file using C#.

The following is the screenshot of the PSD file after updating the image layer using the above-mentioned code:

Update image layer in PSD using C#

Conclusion

In this article, we have seen how to find and update the layers in a Photoshop file (PSD) using C#. The step by step guide and code samples demonstrate how to find layers and update their text or image in the Photoshop PSD files. You can explore more about Aspose.PSD for .NET using documentation.

See Also

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

Generate and Read Barcodes using C++

In this article, I’ll demonstrate how to generate barcodes programmatically using C++. You will also learn how to implement a barcode scanner or reader within your C++ applications.

generate barcode in C++

Barcodes are used to visually represent the data in the machine-readable form. The said technology has proved to be useful especially in the automated checkout systems deployed in stores and supermarkets. Almost every product in the market these days contains a barcode on it. This widespread popularity of the barcode has extended its use cases in various domains. Keeping an eye on the importance of barcodes, a few years ago, Aspose has launched barcode generator and reader API for various platforms. This article aims to showcase how to implement the barcode generator and reader within the C++ applications to dynamically generate and read barcodes.

C++ Barcode Generator and Reader API

Aspose.BarCode for C++ is a feature-rich C++ API for generating and reading a multitude of 1D and 2D barcodes. It lets you generate, customize, and export the barcodes to high-quality images. You can download the library files from the Downloads section. The downloadable package also contains a demo C++ application for you.

The following is the list of barcode symbologies you can generate using Aspose.BarCode for C++:

  • Code128
  • Code39 Standard
  • Code39 Extended
  • Code93 Standard
  • Code93 Extended
  • Code11
  • Codabar
  • BooklandEAN
  • EAN13
  • EAN8
  • EAN128
  • Interleaved2of5
  • Standard2of5
  • MSI
  • Postnet
  • Planet
  • UPCA
  • UPCE
  • EAN14(SCC14)
  • SSCC18
  • ITF14
  • BarCode supplement
  • Pdf417
  • QR
  • Datamatrix
  • Matrix 2 of 5
  • PZN (Pharma Zentral Nummer, Pharmazentralnummer barcode)
  • Deutsche Post Identcode
  • Aztec
  • Australia Post

Generate a Barcode using C++

Generating a barcode using Aspose.BarCode can be achieved within a couple of lines of code. The following are the steps to perform this operation.

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

The following is the barcode we have generated using the above code.

Generate 2D Barcode (QR or other) using C++

In the previous example, we have created a one-dimensional barcode. Lets now create a two-dimensional barcode such as QR code. The following are the steps to create a QR barcode.

The following code sample shows how to generate a QR barcode using C++.

The following QR code will be generated using the above code.

Generate Customized Barcodes using C++

You can also customize the appearance of the barcode. For example, you can set the foreground color, background color, size, border style and etc. The following ate the steps to customize the barcodes using Aspose.BarCode for C++.

The following code sample shows how to generate a customized barcode using C++.

The following is the customized Aztec barcode we have generated.

Generate Barcodes with a Caption using C++

Barcodes may also contain the caption below or above the barcode. You can set the caption’s text as well as its visibility in the barcode image. The following code sample shows how to generate a barcode with the captions using C++.

The following is a barcode with the above and below captions.

Scan and Read Barcodes using C++

Lets now see how to scan and read the barcodes using Aspose.BarCode for C++. The following are the steps to perform this feature.

  • Create an instance of the BarCodeReader class.
  • Initialize BarCodeReader instance with the barcode’s image file and it’s symbology.
  • Use BarCodeReader->Read() method to retrive the text and type of the barcode.

The following code sample shows how to scan and read a barcode using C++.

Read Barcodes with Multiple Symbologies using C++

Most of the time, an image contains only a single barcode symbology. However, in certain cases, the image may contain barcodes of multiple symbologies at the same time. In such cases, you can provide a list of the barcode symbologies to be scanned and read.

The following code sample shows how to scan an image having multiple barcode symbologies using C++.

Conclusion

In this article, you have learned how to generate barcodes with different symbologies using C++. In addition, the procedure of scanning and reading barcodes is also discussed along with C++ code samples. You can explore more about the API using the documentation.

See Also

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

Convert EMF, WMF and SVG Images Programmatically using C#

Convert SVG

Images are everywhere on the internet. There are different image formats for different requirements. Let us explore working with a few of the popular image formats including EMF, WMF, and SVG images. In this article, we will be considering the compression of EMF, WMF, and SVG vector images to EMZ, WMZ, and SVGZ respectively. Moreover, we will also learn how to convert EMF, WMF, and SVG vector images to raster images such as PNG using C#. Following are the use cases we will be exploring:

Vector image files are often huge in size so the compression and uncompression of such images are helpful when you need to transfer files over a network. Let us learn the conversions with Aspose.Imaging for .NET API.

Convert EMF to EMZ using C#

EMZ file is actually the compressed form of EMF image. You can convert EMF to EMZ by following below steps:

  1. Load source EMF image
  2. Initialize VectorRasterizationOptions object
  3. Save image while specifying EmfOptions

Below code snippet shows how to convert an EMF to EMZ using C#:

Convert EMZ to EMF using C#

If you have received a compressed EMZ file and then you want to convert EMZ to EMF then follow the steps below:

  1. Load source EMZ file
  2. Initialize EmfRasterizationOptions object
  3. Save image while specifying EmfOptions

The code snippet below explains how to convert EMZ to EMF using C#:

Convert WMF to WMZ using C#

You can compress WMF images with Aspose.Imaging for .NET API. The compression process converts WMF to WMZ by following below steps:

  1. Load source WMF file
  2. Initialize WmfRasterizationOptions object
  3. Save the image using WmfOptions

Below code snippet shows how to convert WMF to WMZ using C#:

Convert WMZ to WMF using C#

As we have already learned to compress WMF image. Aspose.Imaging for .NET API lets you uncompress WMZ files and convert such WMZ to WMF file. You should follow the following steps for conversion:

  1. Load input WMZ file
  2. Declare an instance of WmfRasterizationOptions class
  3. Save image as WMF file

The code snippet below shows how to convert WMZ to WMF using C#:

Convert SVG to SVGZ using C#

SVG images are widely used to display high quality and complex graphics. You can compress such vector images and convert SVG to SVGZ with below steps:

  1. Load input SVG file
  2. Initialize VectorRasterizationOptions object
  3. Save SVGZ image using SvgOptions

Following code snippet shows how to convert SVG to SVGZ using C#:

Convert SVGZ to SVG using C#

You can uncompress an SVGZ file and convert an SVGZ to SVG with simple steps below:

  1. Load input SVGZ file
  2. Specify SvgRasterizationOptions instance
  3. Save SVG image with SvgOptions

The following code snippet shows how to convert SVGZ to SVG using C#:

So we have learned how to compress and uncompress vector format images including EMZ, WMZ and, SVGZ images. Let us move forward and understand how to convert such image files to raster images.

Convert EMZ to PNG using C#

EMZ is the compressed form of EMF image. You can directly convert it to a raster image format like PNG or JPG. You do not need to uncompress the image first and then convert it. Please follow below steps to convert EMZ to PNG image:

  1. Load input EMZ image
  2. Initialize an instance of VectorRasterizationOptions Class
  3. Save image with PngOptions

The code snippet below shows how to convert EMZ to PNG image using C#:

Convert WMZ to PNG using C#

Now, let us learn the conversion of compressed WMF files, WMZ, directly to PNG. Below steps convert WMZ to PNG:

  1. Load source WMZ image file
  2. Declare an object of VectorRasterizationOptions class
  3. Save PNG image file using PngOptions class

Following code snippet follows these steps and shows how to convert WMZ to PNG using C#:

Convert SVGZ to PNG using C#

The exciting feature of SVGZ to PNG conversion has been introduced based on several requests from our customers. This feature lets you efficiently convert SVGZ to PNG image with high fidelity results. All you need to do is to follow the steps below:

The code snippet below is based on these steps which explain how to convert SVGZ to PNG with C#:

Conclusion

We have discussed the compression and uncompression of vector image formats which is helpful for transferring files. The approach is also suitable when you want to archive such images. For example, you can compress such vector images before archiving and later uncompress as per your requirements. Moreover, we have also explored the conversion of compressed vector images to raster images with Aspose.Imaging for .NET API. Furthermore, you may explore the API via API Reference, API Documentation, and feel free to contact us at the Free Support Forum in case of any concern.

See Also

Generate HTML5 Canvas Programmatically using C#

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