The short tutorial below elaborates how to convert BMP to PDF with Java REST API. A BMP file format (also known as a bitmap image file or device independent bitmap file) is a raster graphics image file used to store digital images. It is one of the most commonly used image file formats on the Windows operating system. BMP files are uncompressed, which means they contain a lot of detailed image data and take up significantly more disk space than other image file formats, such as JPEG or PNG.
While, PDF (Portable Document Format) is a file format developed by Adobe in the 1990s for viewing and exchanging documents reliably, independent of the software, hardware, or operating system used to create them. PDF files are commonly used for documents such as user manuals, eBooks, application forms, and scanned documents, which can be viewed on any computer with a PDF viewer. PDF files are also commonly used for printing, as they maintain the formatting of the original document regardless of the printer or paper size used.
If you’re interested in BMP to PDF Conversion in Java Low Code API then this can be accomplished with the help of the following sample.
Prerequisite
- Create account and get API credentials
- Download Aspose.Imaging Cloud SDK for Java
- Setup Java project with the above SDK
Steps to Convert BMP to PDF in Java REST API
- Set Client ID and Client Secret for the API
- Create an object of ImagingAPI class with client credentials
- Specify input and output files
- Read input BMP file and upload to cloud storage
- Create an object of ConvertImageRequest with input and output file formats
- Call convertImage method to Convert BMP to PDF using REST API
- Save the output PDF file on local disk
Code for BMP to PDF Conversion in Java Low Code API
String ClientID = Client.getID(); //replace Client.getID() with your own client ID here | |
String ClientSecret = Client.getSecret(); //replace3 Client.getSecret() with your own client secret here | |
String APIBaseUrl="https://api.aspose.cloud"; | |
String Local_Path = "C:/Temp/"; | |
ImagingApi imagingApiSdk = new ImagingApi(ClientSecret, ClientID, APIBaseUrl); | |
// Input & output file names | |
String inputFileName = "BMPtoPDF.bmp"; | |
String outputFileName = "BMPtoPDF.pdf"; | |
try { | |
// Upload local image to Cloud Storage | |
File inputFile = new File(Local_Path + inputFileName); | |
FileInputStream inputFileStream = new FileInputStream(inputFile); | |
byte[] inputImageData = IOUtils.toByteArray(inputFileStream); | |
UploadFileRequest uploadFileRequest = new UploadFileRequest(inputFileName, inputImageData, null); | |
FilesUploadResult filesUploadResult = imagingApiSdk.uploadFile(uploadFileRequest); | |
String outputFormat = "pdf"; | |
String remoteFolder = null; // Input file is saved at the root of the storage | |
String remoteStorage = null; // Cloud Storage name | |
ConvertImageRequest convertImageRequest = new ConvertImageRequest(inputFileName, outputFormat, remoteFolder, remoteStorage); | |
byte[] convertedImageData = imagingApiSdk.convertImage(convertImageRequest); | |
// Save exported image to local storage | |
FileOutputStream fileOutputStream = new FileOutputStream(Local_Path + outputFileName); | |
fileOutputStream.write(convertedImageData); | |
fileOutputStream.close(); | |
} catch (Exception e) { | |
System.out.println(e.getMessage()); | |
} |
The code snippet given on this page empowers you to convert BMP to PDF with Java REST API. You simply have to provide BMP file with the help of the Aspose.Imaging REST API SDK and download output PDF file to save it locally.
The above BMP to PDF Conversion can be put to use with any no code or low code apps on any device or computer.