Merge EPS files to PDF using .NET
You can check the quality of Aspose.Page EPS Merger and view the results via free online EPS Merger
Aspose.Page for .NET EPS Merger allows to merge Encapsulated PostScript (EPS) files to PDF document with using of any language supported by .NET platform: C#, VB, J#.
To merge EPS files into a single PDF, follow these steps:
- Create a
PsDocumentinstance by passing the path of the first EPS file to its constructor, which loads the EPS content for merging. - Define a string array containing the file paths of the additional EPS files to be merged, e.g.,
string[] epsFiles = { "second.eps", "third.eps" };. - Instantiate
PdfSaveOptions, setAdditionalFontsFolderto the folder with custom fonts, and optionally setSuppressError = trueto collect non‑critical errors. - Call
document.AddPage(epsFiles);(or use the appropriate merge method) and thendocument.Save("merged.pdf", pdfSaveOptions);to produce a single PDF. - When
SuppressErroris true, any warnings are stored indocument.Exceptions; you can iterate this collection after saving to review the issues.
The following code snippet shows how to merge EPS files to PDF document in C#:
1// Merge several EPS files to one PDF document.
2
3// Initialize PS document with the first EPS file
4PsDocument document = new PsDocument(DataDir + "input.eps");
5
6// Create an array of PostScript files that will be merged with the first one
7string[] filesForMerge = new string[] { DataDir + "input2.eps", DataDir + "input3.eps" };
8
9// If you want to convert Postscript file despite of minor errors set this flag
10bool suppressErrors = true;
11
12//Initialize options object with necessary parameters.
13PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
14// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
15options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };
16
17// Default page size is 595x842 and it is not mandatory to set it in SaveOptions
18// But if you need to specify the page size following line
19//PdfSaveOptions options = new PdfSaveOptions(suppressErrors, new Aspose.Page.Drawing.Size(595, 842));
20
21document.MergeToPdf(OutputDir + "outputPDF_out.pdf", filesForMerge, options);
22
23//Review errors
24if (suppressErrors)
25{
26 foreach (Exception ex in options.Exceptions)
27 {
28 Console.WriteLine(ex.Message);
29 }
30}Let’s consider PdfSaveOptions. Using this class we can assign different conversion parameters while merging EPS to PDF.
- Size specifies the size of the pages in resulting document.
- AdditionalFontsFolder specifies locations where to find fonts. System fonts folders are always included by default.
- SuppressError controls behaviour of EPS merger when non-critical errors are appeared. If value is true than it is possible to view a list of such errors after merging in Exceptions field. Default value is true.
- Debug allows outputting debug information to console. Default value is false.
Evaluate EPS merging online on our EPS Merger.
You can download examples and data files from GitHub.