Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 26, 2025 13:46
Show Gist options
  • Select an option

  • Save aspose-com-gists/2e072e9d3fe54c6bf9a4bc97fad1835b to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/2e072e9d3fe54c6bf9a4bc97fad1835b to your computer and use it in GitHub Desktop.
Create PostScript file from scratch and add pages with .NET

Work with PS Document Examples

These snippets demonstrate creating and manipulating PostScript (PS) documents using Aspose.Page for .NET.

Key Use Cases

  • Create PS documents from scratch
  • Add pages to the PS document

How to Run Examples

  1. Reference Aspose.Page for .NET: Aspose.Page on Windows; Aspose.Page.Drawing on non‑Windows.
  2. Copy a snippet into your project or run the related test.
  3. Apply a temporary license as described in the licensing guide.
  4. Build and run.

Restrictions

In evaluation mode, the output PS or EPS file is limited to 1Mb and contains a red evaluation warning. Apply a valid license to unlock all features.

Related Documentation

Extra data about creating PS files and adding pages can be found in Working with Document in PostScript | .NET and Working with Pages in PostScript | .NET chapters of our tutorial.

Related Resources

Requirements

  • .NET 6.0+, .NET Core, or .NET Framework
  • Aspose.Page for .NET library
Aspose.Page for .NET – Create PS Examples
// Add page to PS document.
// Learn more: https://docs.aspose.com/page/net/ps/working-with-pages/
string outputFileName = "document1_out.ps";
//Create save options with A4 size
PsSaveOptions options = new PsSaveOptions();
options.Debug = true;
// Create new 2-paged PS Document
PsDocument document = new PsDocument(OutputDir + outputFileName, options, 2);
//Add the first page
document.OpenPage();
//Add content
//Close the first page
document.ClosePage();
//Add the second page with different size
document.OpenPage(400, 700);
//Add content
//Close the second page
document.ClosePage();
//Save the document
document.Save();
// Another way to add page to PS document.
// Learn more: https://docs.aspose.com/page/net/ps/working-with-pages/
string outputFileName = "document2_out.ps";
//Create save options with A4 size
PsSaveOptions options = new PsSaveOptions();
//Set variable that indicates if resulting PostScript document will be multipaged
bool multiPaged = true;
// Create new multipaged PS Document with one page opened
PsDocument document = new PsDocument(OutputDir + outputFileName, options, multiPaged);
//Add content
//Close the first page
document.ClosePage();
//Add the second page with different size
document.OpenPage(500, 300);
//Add content
//Close the second page
document.ClosePage();
//Save the document
document.Save();
// Create new multipaged PS document from scratch.
// Learn more: https://docs.aspose.com/page/net/ps/working-with-document/
string outputFileName = "document_out.ps";
//Create save options
PsSaveOptions options = new PsSaveOptions();
//If you want to aassign page size other than A4, set page size in options
options.PageSize = PageConstants.GetSize(PageConstants.SIZE_A4, PageConstants.ORIENTATION_PORTRAIT);
//If you want to aassign page margins other empty, set page margins in options
options.Margins = PageConstants.GetMargins(PageConstants.MARGINS_ZERO);
//If you plan to use fonts that located in non system folders, set additional fonts folders in options
options.AdditionalFontsFolders = new string[] { DataDir };
//Set variable that indicates if resulting PostScript document will be multipaged
bool multiPaged = false;
// Create new multipaged PS Document with one page opened
PsDocument document = new PsDocument(OutputDir + outputFileName, options, multiPaged);
//Close current page
document.ClosePage();
//Save the document
document.Save();
// Create new PS document with defined number of pages.
// Learn more: https://docs.aspose.com/page/net/ps/working-with-document/
string outputFileName = "document_out.ps";
//Create save options
PsSaveOptions options = new PsSaveOptions();
//If you want to aassign page size other than A4, set page size in options
options.PageSize = PageConstants.GetSize(PageConstants.SIZE_A4, PageConstants.ORIENTATION_PORTRAIT);
//If you want to aassign page margins other empty, set page margins in options
options.Margins = PageConstants.GetMargins(PageConstants.MARGINS_ZERO);
//If you plan to use fonts that located in non system folders, set additional fonts folders in options
options.AdditionalFontsFolders = new string[] { DataDir };
// Create new multipaged PS Document with 2 pages. These two pages are not created. It must be added by OpenPage() method.
PsDocument document = new PsDocument(OutputDir + outputFileName, options, 2);
//Add the first page
document.OpenPage();
//Close current page
document.ClosePage();
//Save the document
document.Save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment