Merge or Unmerge Cells in Excel Worksheet with C#

In this article, we will learn about merging and unmerging of cells in Excel sheet. Generally, merging cells refers to one or more cells joined together to form a large cell. However, the adjacent cells can be merged vertically or horizontally. Whereas, converting a large cell into multiple cells is known as unmerging or splitting cells in Excel worksheet. Let us explore the following use cases:

Merge Cells in Excel Worksheet with C#

You can easily merge cells in excel worksheet with Aspose.Cells for .NET API using C#. In this example, we will be creating a new excel worksheet from scratch and then merge a few cells by following below steps:

  1. Create a Workbook object
  2. Get first worskeet
  3. Merge specific cells
  4. Put value in merged cell
  5. Apply styles on the cell
  6. Save output excel worksheet

Below code snippet shows how to merge cells in Excel worksheet with C#:

The output file generated from this code snippet will contain merged cells as in the screenshot below:

Merge Cells

Unmerge Cells in Excel Worksheet with C#

We have learned how to merge cells in Excel file. Let us take this process another step further. Here we will be considering to unmerge cells in Excel worksheet by following the steps below:

  1. Load source Excel file
  2. Create Worksheet object and access first sheet
  3. Unmerge the cells
  4. Save output file

The code snippet below is based on these steps and shows how to unmerge cells in Excel file with C#:

The following image shows how do the unmerged cells look when you run the above code in your environment:

Unmerge Cells

Merge a Range of Cells in Excel Worksheet with C#

Sometimes there are several cells specified under different ranges of cells. You might want to merge a specific range of cells in Excel sheet. In such scenarios, please follow the steps listed below:

  1. Create a Workbook object
  2. Access the first worksheet
  3. Input data in a Cell
  4. Create and Merge the Range
  5. Save output excel file

The code snippet below shows how to merge range of cells into one larger cell in Excel file using C#:

Unmerge a Range of Cells in Excel Worksheet with C#

We have explored merging a range of cells in Excel in the previous example. Let us move on to unmerging the merged cells by following the steps below:

  1. Load source Workbook
  2. Access specific Worksheet
  3. Create a Range object
  4. Call UnMerge method
  5. Save output Excel file

The code snippet below follows these steps and shows how to unmerge a range of cells in Excel worksheet using C#:

Merge Cells in Named Range in Excel Worksheet with C#

Sometimes the Excel files contain several named ranges because it is easy to identify and manipulate accordingly. Therefore, you can also merge any named range by specifying its name. Resultantly, all the cells in that named range will be merged into one bigger cell. You need to follow these steps:

  1. Load source Excel Workbook
  2. Access the Worksheet containing the named range
  3. Define and Apply style
  4. Merge Named Range
  5. Save output file

The code snippet below explains how to merge cells in a named range in C#:

The output of the above code snippet will be the same as the following image:

Merge Named Range

Conclusion

Merging or unmerging cells in Excel Workbooks and Worksheets is an important and useful feature. We have compiled different possible use cases in this article along with all the steps and images. Now you can easily follow these steps and merge or unmerge cells, ranges, or named ranges in Excel files. In case of any query or concern, you may please contact us via Free Support Forum.

See Also

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

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

Convert PDF Documents to Excel XLS/XLSX using Java

PDF to Excel Java

There could be various scenarios when you need to export the data within the tables from PDF documents to Excel workbooks. PDF to Excel lets you edit the data, apply formulas, plot charts, and perform other operations that are supported by the spreadsheets. In this article, I’ll show you how to automate the PDF to Excel conversion and convert PDF to XLS to XLSX workbooks programmatically using Java. For this, we’ll leverage the capabilities of Aspsoe.PDF for Java API.

Java PDF to Excel Converter – Installation

Aspose.PDF for Java is available for download as a JAR file. In addition, you can install it in your Maven-based applications 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-pdf</artifactId>
    <version>20.5</version>
    <classifier>jdk17</classifier>
</dependency>

Convert PDF to Excel XLS using Java

In order to convert PDF to Excel XLS, you simply need to load the PDF document and save it with .xls extension. The following are the steps to perform this conversion.

The following code sample shows how to convert PDF to Excel XLS using Java.

Input PDF Document

Convert PDF to Excel

Output Excel Spreadsheet

PDF to XLS XLSX

Convert PDF to XLSX using Java

For converting PDF to XLSX spreadsheet, you need to define the output Excel format using ExcelSaveOptions class. The following are the steps to perform PDF to XLSX conversion using Aspose.PDF for Java.

The following code sample shows how to convert PDF to XLSX using Java.

Minimize the Number of Worksheets in PDF to Excel

By default, Aspose.PDF converts each page in the PDF document to a separate worksheet. However, you may customize the API to minimize the number of worksheets in case of large PDF documents. The following are the steps to perform this operation.

The following code sample shows how to convert PDF to XLSX with a minimized number of worksheets using Java.

Conclusion

In this article, you have seen how to convert PDF documents to Excel XLS or XLSX files using Java. Furthermore, the feature of minimizing the number of worksheets in PDF to Excel is also discussed with the help of the code sample. You can explore more about Aspose.PDF for Java using the documentation.

See Also

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

Convert Image to Text using C++ OCR Library

Perform OCR using C++

The OCR (Optical Character Recognition) technology lets you read and convert the text in the images or scanned documents to the machine-readable form. The OCR has various use cases that include reading codes from vouchers, making the text editable, self-service stores, converting printed documents into digital formats, and so on. Various OCR tools and libraries are available in the market, however, the reliability of the OCR results is a key factor. In this article, I’ll show you how to create your own OCR application and convert images to text programmatically using C++.

C++ OCR Library to Convert Image to Text

Aspose offers a powerful C++ OCR library that uses deep learning to provide you more reliable and near to accurate OCR results. You can download the library files as well as a sample project from GitHub.

Convert Image Page to Text using C++

Lets first check out the scenario in which the image contains a multi-line text. This could be the case when you have a scanned book where each page of the book contains a bunch of text lines. The following are the steps to convert image to text in this case.

The following code sample shows how to perform OCR and convert image to text using C++.

Perform OCR for an Image with Single Line using C++

In the previous example, we have converted an image having multiple text lines. However, there could be the case when the image contains only a single line of text such as the caption or a slogan. The following are the steps to perform OCR in such cases.

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

Convert a Particular Area of Image to Text in C++

You can also customize the API to limit the area of the image where you want to perform the OCR. In this case, you can create a rectangle on the image to access the desired area. The following are the steps to extract text from a particular area of the image.

The following code sample shows how to convert a particular area of the image to text using C++.

Conclusion

In this article, you have learned how to use Aspose’ OCR library to convert images to text in C++. We have seen how to perform OCR on an image with single or multiple lines of text as well as read text from a particular area of an image. You can learn more about Aspose.OCR for C++ using the documentation.

See Also

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

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