Follow this article to convert PNG to PDF using C# REST API. You will learn to transform PNG to PDF using C# RESTful Service using the .NET-based Cloud SDK. This article will guide you to convert multiple images to PDF with the defined behavior.
Prerequisite
- Create an account API credentials to convert a PNG file to a PDF
- Download Aspose.PDF Cloud SDK for Dotnet for changing PNG format to PDF
- Setup a C# project with the above SDK
Steps to Convert PNG File to PDF using C# REST Interface
- Create an instance of the PdfApi class object to convert PNG to PDF
- Set the input image file name(s) and output PDF file name
- Read the image(s) into the memory stream and upload to the Cloud storage for conversion
- Create an image template to handle the uploaded image
- Add as many images as you want to the collection
- Create a conversion request by passing the image list and the flag for the OCR image
- Call the PutImageInStorageToPdf() method to transform the image to PDF
- Check the API response and download the resultant PDF if the operation is successful
These steps summarize the process of converting a PNG to a PDF using C# REST API. Create the PdfApi, define the names of the PNG images, output PDF file, upload the image to the Cloud storage, and create the image template to define the behavior of the image for the API. Create the conversion request, call the PutImageInStorageToPdf() to convert the image in the Cloud storage to PDF, and save the resultant PDF on the disk.
Code to Change a PNG to a PDF using C# .NET-based API
This sample code demonstrates how to convert a PNG to PDF using C# Low Code API. If you add multiple images, each image is converted to a separate PDF page in the output file. When we set the IsOCR to true, the PDF becomes searchable and selectable.
This article has taught us the process to convert PNG to PDF. To attach an image in the PDF, refer to the article Attach image to PDF using C# REST API.