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:
- Create an instance of PsDocument from PS file.
- Use PdfSaveOptions(or ImageSaveOptions if you convert to an image format) to specify AdditionalFontsFolder and SuppressError boolean values.
- Call SaveAsImage to save PostScript document as image with image save options ( or call SaveAsPdf to save PostScript document as PDF with PDF 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 PNG 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 PDF and saved in the Exceptions list.
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.