Follow this article to convert BMP to PDF using C# REST API. You will learn to transform the file format from BMP to PDF with the help of a .NET-based Cloud SDK. The ImageTemplate class allows the customization of the image in the output PDF file.
Prerequisite
- Create an account API credentials to convert a BMP file to a PDF
- Download Aspose.PDF Cloud SDK for Dotnet for changing BMP format to PDF
- Setup a C# project with the above SDK
Steps to Convert BMP in PDF using C# REST Interface
- Create an object of the PdfApi class by passing the secret key and user ID
- Upload the source BMP file into the Cloud storage by reading it into the memory stream from the disk
- Prepare the image template for the PDF creation
- Create as many templates as there are images to be added in a List object
- Create the ImageTemplatesRequest using the above-mentioned image templates collection
- Call the PutImageInStorageToPdf() method with the output PDF file name and the input request
- Download the output PDF file from the Cloud storage and save it on the disk
These steps have summarized the development of a Bitmap to PDF converter using C# REST API. Upload the BMP file(s) to the Cloud storage, create an image template for each BMP file, and create a collection of these image templates that is further used while creating the ImageTemplatesRequest object. Finally, call the PutImageInStorageToPdf() method to transform the collection of templates to multiple pages in the output PDF file.
Code to Change BMP to PDF using C# REST Interface
The aforementioned sample code has demonstrated the BMP file to PDF converter using C# Low Code API. The ImageTemplate class supports the configuration of the page margins and page height and width for the output PDF. You can also set the ImageSrcType as Common or EMF as per your requirements.
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.