Generate or Scan QR, Pdf417, Datamatrix, Aztec, and Other Barcodes in Java

Barcode technology is a popular and widely used way to visually represent data about objects in the form of different patterns. Barcode is the encoded and machine-readable form of the data that can be decoded or read using the barcode scanners. These days, almost every product contains a barcode that can be scanned to retrieve information about that product. Furthermore, the increasing number of online businesses has also influenced the usage of different types of barcodes in the purchase process. Keeping an eye on today’s trends, this article aims to show you how to generate barcodes of various symbologies and scan barcode images programmatically in Java.

In this article, you will learn how to:

  • generate a barcode,
  • generate QR or other barcodes,
  • create barcodes with a customized appearance,
  • create barcodes with a caption, and
  • scan and read barcodes in Java.

Java Barcode Generator and Scanner API

In order to generate barcodes in Java-based applications, i.e. console application, Java Swing application, etc., we will use Aspose.BarCode for Java which is a feature-rich Java barcode generator and scanner API. You can download the JAR of Aspose.BarCode for Java or install it in 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-barcode</artifactId>
    <version>20.3</version>
    <classifier>jdk17</classifier>
</dependency>

Generate a Barcode in Java

The following are the simple steps to generate a barcode and save it as an image.

  • Create an object of the BarcodeGenerator class.
  • Initialize the BarcodeGenerator object with the encoding type and the text to encode.
  • Set the resolution of the resultant image (optional).
  • Generate barcode using BarcodeGenerator.save(string) method.

The following code sample demonstrates how to generate a barcode image in Java.

Generated Barcode

generate barcode java

Generate QR Barcode in Java

You can generate a variety of barcode types using Aspose.BarCode for Java. The supported barcode symbologies of the API include, but not limited to:

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

You can generate any of the above-mentioned barcode types by specifying the respective encoding type using the EncodeTypes parameter while initializing the BarcodeGenerator’s object. For the demonstration, we’ll generate a QR barcode. The following code sample shows how to generate QR barcode in Java:

Generated QR Code

generate QR barcode java

Generate Barcode with Customized Appearance in Java

By default, the barcodes are generated in black and white color combination. However, you may want or need to customize its appearance in certain cases. Aspose.BarCode for Java lets you customize the barcode’s forecolor, back color, text’s color, font, and etc. The following are the steps to generate a barcode with a customized appearance.

The following code sample shows how to generate an AZTEC barcode with a customized appearance using Java.

Barcode with Customized Appearance

java generate barcode custom colors

Generate Barcodes with Captions in Java

The barcode images may also contain their captions. You can add the caption below the barcode, above the barcode or at both of the locations at the same time. The following steps are used to set captions for a barcode:

The following code sample shows how to set the caption while generating the barcode in Java.

Barcode with Captions

generate barcode with caption java

Read or Scan Barcode in Java

Along with generating the barcodes, you can also scan the barcode images to decode and read the information/data they contain. Since an image may contain more than one barcode, you may access and read all of them at the same time. The following are the steps to scan and read a barcode image:

  • Create an object of BarCodeReader class and initialize it with the path of the barcode image file.
  • You can also pass DecodeType as the second parameter to BarCodeReader’s constructor to read the barcodes with a particular symbology only.
  • Read the barcodes using BarCodeReader.readBarCodes() method.

The following code sample shows how to scan and read barcode images in Java.

Output

CodeText: Aspose.BarCode
Symbology type: Code128

Learn more about Aspose.BarCode for Java

You can explore more about Aspose.BarCode for Java using the documentation.

Related Articles

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

Import Data from JSON to Excel Worksheet in C# .NET

Convert JSON to Excel C#

MS Excel provides a variety of features to keep and organize tabular data in the form of worksheets. Along with data organization, you can perform various operations such as data sorting, graph plotting, mathematical computations and etc. JSON, on the other hand, is a widely used format to store and transmit the data in the form of key-value pairs. Most often, it is used to transmit data from the server to the web pages. There could be the case when you receive the data in the form of JSON, i.e. from a web service, and want to save it into an Excel worksheet. In such a case, the optimal way is automating the process by importing data from JSON to Excel worksheets programmatically.

In order to deal with the above-mentioned scenario in ASP.NET or any C# based application, I’ll show you how to import JSON data into Excel file. In this article, you will learn how to:

  • import data from JSON to Excel worksheet in C#
  • apply cell formatting when converting JSON to Excel in C#

In order to import data from JSON files, we’ll leverage the capabilities of Aspose.Cells for .NET. It is a powerful API to manipulate spreadsheet files in .NET, .NET Core & Xamarin based applications. You can install the API’s package from NuGet or download the DLL directly from the Downloads section.

Import Data from JSON to Excel in C#

The following are the steps to import data from JSON to Excel XLSX:

The following code sample shows how to import data from JSON to Excel in C#.

Input JSON Data

[
   {
       Name: "John Smith",
       Contract:
       [
           {
               Client:
               {
                   Name: "A Company"
               },
               Price: 1200000
           },
           {
               Client:
               {
                   Name: "B Ltd."
               },
               Price: 750000
           },
           {
               Client:
               {
                   Name: "C & D"
               },
               Price: 350000
           }
       ]
   },
   {
       Name: "Tony Anderson",
       Contract:
       [
           {
               Client:
               {
                   Name: "E Corp."
               },
               Price: 650000
           },
           {
               Client:
               {
                   Name: "F & Partners"
               },
               Price: 550000
           }
       ]
   },
   {
       Name: "Jimmy Adams",
       Contract:
       [
           {
               Client:
               {
                   Name: "MIT"
               },
               Price: 800000
           },
           {
               Client:
               {
                   Name: "SnB"
               },
               Price: 520000
           }
       ]
   },
]

Output Excel Worksheet

JSON to Excel

Import JSON to Excel with Formatting Styles in C#

You can also apply different styles to the Excel worksheet when importing the data from JSON file. The CellsFactory class of Aspose.Cells for .NET provides a range of options to set various styling parameters such as font, color, alignment, border styles, etc. The following are the steps to import data from JSON to Excel along with the styling.

The following code sample applies different styles when importing data from JSON to Excel in C#.

Output Excel Worksheet

JSON to Excel C#

See Also

Learn more about Aspose.Cells for .NET

You can explore more about Aspose.Cells for .NET using the documentation and the source code examples.

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

C# Convert DICOM to JPEG, GIF, PNG, and BMP Images

DICOM to Image

DICOM (Digital Imaging and Communications in Medicine) is a standard file format for storing medical imaging information. The information stored in the DICOM images is managed in the form of datasets including the header and the image data set. Most often, DICOM images contain medical scans such as ultrasounds, MRIs and etc. which are exchanged between multiple entities to share the patient’s medical information.

In order to view the DICOM images, various offline and online DICOM viewers are available in the market. However, if you want to embed DICOM images in presentations or webpages, you will have to convert them into JPEG, GIF, PNG, BMP or some other image format. In accordance with this scenario, in this article, you will learn how to convert DICOM images programmatically in C#. Ultimately, you will be able to convert DICOM to the following image formats:

  • JPEG
  • GIF
  • PNG
  • BMP

C# DICOM Converter API

In order to convert DICOM images, we’ll use Aspose.Imaging for .NET which is an easy to use API for creating and manipulating various types of images within .NET applications. Aspose.Imaging for .NET is hosted on NuGet as well as available as downloadable binaries.

Convert DICOM to JPEG in C#

The following are the steps to convert DICOM to JPEG in C#:

  • Load the DICOM file into a FileStream object.
  • Create an object of DicomImage class and initialize it with the FileStream object.
  • Select the active page in DICOM that you want to convert to JPEG (if it is not set, the default active page will be converted).
  • Save the converted JPEG image using DicomImage.Save(string, ImageOptionsBase) method.

The following code sample converts a page in DICOM to JPEG in C#.

Input DICOM

DICOM to JPEG

DICOM to JPEG

Convert DICOM to JPEG C#

Convert DICOM to GIF in C#

Converting DICOM to GIF is as simple as pie. Just access the DICOM file and save it with .gif extension. The following are the steps to convert DICOM to animated GIF in C#:

The following code sample shows how to convert DICOM to GIF in C#.

DICOM to GIF

Convert DICOM to GIF C#

Convert DICOM to PNG in C#

Converting DICOM to PNG is as same as converting DICOM to JPEG. Simply access the DICOM file using DicomImage class and save it with .png extension. The following code sample shows how to convert a DICOM to PNG in C#.

Convert DICOM to BMP in C#

In order to convert DICOM to BMP, you can repeat the same steps to access the DICOM file using the DicomImage class. Once done, use DicomImage.Save(string, ImageBaseOptions) method to save DICOM as BMP. The following code sample shows how to convert DICOM to BMP in C#.

Learn more about Aspose.Imaging for .NET

Explore more about working with images using Aspose.Imaging for .NET API.

See also

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

AcroForms vs XFA Forms – Convert XFA to AcroForms in PDF

Convert XFA to AcroForms

AcroForms vs XFA Forms

AcroForms are the fillable forms that are used to integrate the form fields in PDF documents. It was the initial forms technology adopted by Adobe for the PDF documents starting from PDF 1.2 specification. AcroForms allow adding the form fields as an overlay to collect the data from the end-users or anyone using the document.

Later, Adobe adopted the XML-based XFA forms (XML Forms Architecture) as part of the PDF 1.5 specification after acquiring Accelio (a service provider). XFA used the capabilities of the XML for developing the e-forms in PDF documents. However, despite being a newer e-form technology as compared to AcroForms, XFA has a few limitations which include:

  • lack of JavaScript support with various PDF objects,
  • XFA forms can be created with Adobe LiveCycle Forms Designer only,
  • compatibility issues with the AcroForms,
  • lack of an automatic conversion from AcroForms to XFA,
  • limited accessibility as compared to AcroForms,
  • requires developer skills to build the forms,
  • and etc.

Since AcroForms technology is considered to be more accessible and easy to use, the upcoming section shows how to perform XFA to AcroForms conversion in PDF programmatically using C# and Java.

Convert XFA to AcroForms

Various XFA to AcroForms conversion tools are available that will let you perform the conversion. However, in order to integrate this feature within your .NET or Java application for automated conversion, you can use Aspose.PDF.

Convert XFA to AcroForms in C#

The following are the steps to convert XFA forms to AcroForm using Aspose.PDF for .NET.

The following code sample converts XFA forms in PDF to AcroForms using C#.

Convert XFA to AcroForms in Java

The following are the steps for XFA to AcroForms conversion using Aspose.PDF for Java.

The following code sample shows how to convert XFA to AcroForms using Java.

Learn more about Aspose.PDF

You can learn more about the Aspose.PDF API using the documentation. In case you would have any questions or queries, contact us via our forum.

See Also

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

Convert PSD to PDF, JPG, PNG and Other Raster Image Formats in C#

PSD to Image C# 2

The Photoshop Document (PSD) is a well-known file format used by Adobe Photoshop for saving the data in the form of layers. The layers are combined together to obtain the desired artwork or images. Adobe Photoshop allows the designers to export the PSD layers as a single image in the form of PNG, JPG, GIF, TIFF, and other formats.

In case you want to implement the feature of converting or exporting the PSD files to raster image formats without Photoshop, you will definitely look for some automation. For such a case, I am going to demonstrate how to convert PSD to PDF, JPG, PNG, BMP or other raster image formats programmatically using C#. Furthermore, you’ll also learn how to convert or export the desired layer/layer group in the PSD. This article covers the following PSD conversions in C#:

  • PSD to JPG
  • PSD to PNG
  • PSD to BMP
  • PSD to TIFF
  • PSD to GIF
  • PSD to JP2
  • PSD to PDF
  • PSD layer/layer group to image

C# PSD Converter API – Aspose.PSD for .NET

For converting PSD to PDF and image formats, we’ll leverage the capabilities of Aspose.PSD for .NET which is simple and easy to use .NET API for manipulation and conversion of Photoshop files (PSD). In addition to conversion features, the API also lets you create and edit the Photoshop PSD files, update layer properties, insert watermarks, and perform various graphics-related operations on PSD files. Aspose.PSD for .NET can be installed from NuGet as well as downloaded as DLL from the Downloads section.

Convert PSD to JPG in C#

The following are the steps to convert a PSD file to JPG image in C#:

The following code sample shows how to convert a PSD file to JPG in C#:

PSD File

PSD to JPG

Converted JPG Image

PSD to PNG

Convert PSD to PNG in C#

The following are the steps to convert a PSD file to PNG image in C#:

The following code sample shows how to convert a PSD file to PNG in C#:

Convert PSD to BMP in C#

The following are the steps to convert a PSD file to BMP image in C#:

The following code sample shows how to convert a PSD file to BMP in C#:

Convert PSD to TIFF in C#

The following are the steps to convert a PSD file to TIFF image in C#:

The following code sample shows how to convert a PSD file to TIFF in C#:

Convert PSD to GIF in C#

The following are the steps to convert a PSD file to GIF image in C#:

The following code sample converts a PSD file to GIF in C#:

Convert PSD to JP2 in C#

The following are the steps to convert a PSD file to JP2 image in C#:

The following code sample converts a PSD file to JP2 in C#:

Convert PSD to PDF in C#

The following are the steps to convert a PSD file to PDF document in C#:

The following code sample converts a PSD file to PDF document in C#:

Convert a Layer or Layer Group of PSD in C#

You can also convert a particular layer or layer group in the PSD file to raster image formats (JPG, PNG, etc.). The following are the steps to perform this operation.

  • Create an object of the PsdImage class and load the PSD file.
  • Access the layer or layer group using PsdImage.Layers array.
  • Render the layer as an image.

The following code sample shows how to convert a layer group of PSD to PNG in C#.

Learn more about Aspose.PSD for .NET

You can explore more about the Aspose.PSD for .NET using the documentation.

Related Article(s)

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