Arbeiten mit Dokumenten in PostScript | .NET

Contents
[ Hide Show ]

PS-Dokument erstellen

Aspose.Page für .NET bietet zwei Konstruktoren zum Erstellen der Klasse PsDocument. Der folgende Codeausschnitt erstellt ein einseitiges PS-Dokument:

 1// Create new multipaged PS document from scratch.  2  3string outputFileName = "document_out.ps";  4  5//Create save options  6PsSaveOptions options = new PsSaveOptions();  7//If you want to aassign page size other than A4, set page size in options  8options.PageSize = PageConstants.GetSize(PageConstants.SIZE_A4, PageConstants.ORIENTATION_PORTRAIT);  9//If you want to aassign page margins other empty, set page margins in options 10options.Margins = PageConstants.GetMargins(PageConstants.MARGINS_ZERO); 11//If you plan to use fonts that located in non system folders, set additional fonts folders in options 12options.AdditionalFontsFolders = new string[] { DataDir }; 13 14//Set variable that indicates if resulting PostScript document will be multipaged 15bool multiPaged = false; 16 17// Create new multipaged PS Document with one page opened 18PsDocument document = new PsDocument(OutputDir + outputFileName, options, multiPaged); 19 20//Close current page 21document.ClosePage(); 22//Save the document 23document.Save();

Wenn das PS-Dokument mehrseitig sein soll, setzen Sie die Variable multiPaged auf true.

Ein weiterer Konstruktor ermöglicht das Erstellen eines PsDocument-Objekts mit einer definierten Anzahl von Seiten:

 1// Create new PS document with defined number of pages.  2  3string outputFileName = "document_out.ps";  4  5//Create save options  6PsSaveOptions options = new PsSaveOptions();  7//If you want to aassign page size other than A4, set page size in options  8options.PageSize = PageConstants.GetSize(PageConstants.SIZE_A4, PageConstants.ORIENTATION_PORTRAIT);  9//If you want to aassign page margins other empty, set page margins in options 10options.Margins = PageConstants.GetMargins(PageConstants.MARGINS_ZERO); 11//If you plan to use fonts that located in non system folders, set additional fonts folders in options 12options.AdditionalFontsFolders = new string[] { DataDir }; 13 14// Create new multipaged PS Document with 2 pages. These two pages are not created. It must be added by OpenPage() method. 15PsDocument document = new PsDocument(OutputDir + outputFileName, options, 2); 16 17//Add the first page 18document.OpenPage(); 19//Close current page 20document.ClosePage(); 21//Save the document 22document.Save();

Siehe „Arbeiten mit PS-Dokumenten“ in Java.

Schauen wir uns die Klasse PsSaveOptions an, die mögliche Optionen kapselt, die beim Erstellen des richtigen PostScript-Dokuments helfen.

1options.PageSize = PageConstants.GetSize(PageConstants.SIZE_International, PageConstants.ORIENTATION_PORTRAIT);

Die Standardseitengröße ist „A4“ in der Ausrichtung „Hochformat“.

1options.Margins = PageConstants.GetMargins(PageConstants.MARGINS_SMALL); // 20 points for each margin

Die Standardränder sind „NULL“ (0, 0, 0, 0).

1options.BackgroundColor = Color.FromArgb(211, 8, 48);

oder:

1options.BackgroundColor = Color.Yellow;

Für Linux, MacOS und andere Nicht-Windows-Betriebssysteme bieten wir die Verwendung unseres Nuget-Pakets Aspose.Page.Drawing an. Es verwendet das Aspose.Drawing-Backend anstelle der System.Drawing-Systembibliothek.

Importieren Sie also den Namensraum Aspose.Page.Drawing anstelle des Namensraums System.Drawing. In den obigen Codeausschnitten wird Aspose.Page.Drawing.Color anstelle von System.Drawing.Color verwendet. Unsere Codebeispiele auf GitHub enthalten alle notwendigen Ersetzungen.

Der Standardwert ist „null“, was bedeutet, dass kein Hintergrund vorhanden ist.

1options.EmbedFontsAs = FontsConstants.EMBED_FONTS_TYPE3

Der Standardwert ist „TrueType“.

Sie können Beispiele und Datendateien herunterladen von GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.