Insert page into PS file
C++ API Solution to add pages to PS file
There are two ways to control how many pages your PostScript (PS) document has with the Aspose.Page API. You can either specify the exact number of pages upfront or choose to create a single-page or multi-page document. However, to add pages one by one, you must use the OpenPage() and ClosePage() methods. PS documents can have pages of different sizes, so you can set the size you want with OpenPage(). By default, pages are A4 size. It's important to note that you can only manage pages in newly created PS documents, not existing ones.
On this page, we show you two options for adding pages to a PS file using Aspose.Page for C++. But first, you need to:
Get Aspose.Page for C++ API which is a feature-rich, powerful and easy-to-use document manipulation and conversion C++ API.
Open the NuGet package manager, and search for Aspose.Page.Cpp and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Page.Cpp
C++ code to add pages to a PS file. Variant 1.
Steps to add pages to a PS file. Variant 1.
- Construct the path to the documents directory.
- Create an output stream for the resulting PS file.
- Create the save options with A4 size
- Create a PS file using the PsDocument Class , the outputstream and the number of pages.
- Create an empty page with the OpenPage() Method.
- App the content to this page and close it with the ClosePage() Method.
- If you need to add a page with a different size use the same OpenPage() Method with new size.
- Close the page with the ClosePage() Method.
- Save the PS document using the Save() Method.
Add images to PS
C++ code to add pages to a PS file. Variant 2.
Steps to add pages to a PS file. Variant 2.
- Construct the path to the documents directory.
- Create an output stream for the resulting PS file.
- Create the save options with A4 size
- Create a new PS file using the PsDocument Class .
- If you need to add a page with different size use OpenPage() Method with new size.
- After adding content to pages close them with the ClosePage() Method.
- Save the PS document using the Save() Method.
Add images to PS
PS What is PS File Format
PS format is one of the page description language (PDL) formats. It is capable to contain graphic as well as text information on the page. That is why the format was supported by most of the programs for image editing. The postscript file itself is a kind of instruction for printers. It contains information on what and how to print from its page.