Learn how to convert BMP images to PDF using a C# REST API in just a few steps. This tutorial demonstrates the transformation of a BMP file into a PDF with the .NET‑based Cloud SDK, and shows how the ImageTemplate class lets you customize the image appearance in the resulting PDF.
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
With the sample code above, you’ve seen the BMP‑to‑PDF converter in action using the C# Low Code API. The ImageTemplate class lets you configure page margins, as well as the height and width of the output PDF, and you can set ImageSrcType to either Common or EMF to suit your specific requirements.
In this guide we walked through converting PNG images to PDF with the C# REST API. When you’re ready to embed an image directly into a PDF, check out our step‑by‑step tutorial Attach image to PDF using C# REST API.