Convert PostScript with Aspose.Page C++ API
This article explains how to convert PS files using C++ on the example of PS to BMP Conversion.
Aspose.Page lets you convert PS files using Java in high-quality BMP, JPG, TIFF, PNG, and PDF documents.
You can check the quality of Aspose.Page PS to BMP conversion and view the results via free online PostScipt to BMP Converter or PostScript Viewer
Aspose.Page for C++ PS to BMP converter allows to convert PostScript (PS) file to BMP image on Windows and Linux.
It is necessary to take several steps for PS to BMP conversion:
- Initialize an input stream for the input PS file.
- Create an instance of PsDocument from created earlier input stream.
- Use ImageSaveOptions(or PdfSaveOptions if you convert to PDF format) to specify AdditionalFontsFolder and SuppressError boolean value.
- Create an instance of ImageDevice(or PdfDevice if you convert to PDF format) specifying image type and size if it is necessary.
- Save the PostScript document as an image with image save options to an array of arrays of bytes. One array of bytes for one page of input document.
- Save resulting 2-dimensional arrays of bytes to BMP files creating for every byte array a new file output stream.
- If the SuppressErrors value was true, as it is by default, It is possible to see what errors were thrown during the conversion of PS to BMP.
The following code snippet shows how to convert PS to BMP files in C++:
For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-C
Let’s consider ImageSaveOptions. Using this class we can assign different conversion parameters while converting PS to BMP.
- AdditionalFontsFolder specifies locations where to find fonts. System font folders are always included by default.
- SuppressError controls the behavior of the PS to BMP converter if non-critical errors happen. If the value is true then it is possible to view a list of such errors after conversion in the Exceptions field. The default value is true.
- Debug allows outputting debug information to the console. The default value is false.
Have a look at PS online conversion in our PS cross-platform Converter. You can convert several PS files to BMP at once and download results in a few seconds.
Feel free download the examples and data files from GitHub.