Free Support Forum - aspose.com

Product support for Post Script files

I am not a customer, but I am looking for a solution for the following use case:

We have post script files that we want to extract basic meta data from: Number of pages, Page size, whether there are bleeds, etc…

Do you have a product and code sample(s) that support this use case?

@justinhersh,
Thank you for your query.
Aspose.Page can be used for extracting basic information from post script files. Following sample code can be used to load the files and get the meta data. All the properties are written to device object which can be used to fetch this information.

// Initialize PDF output stream
System.IO.FileStream pdfStream = new System.IO.FileStream(dataDir + "outputPDF_out.pdf", System.IO.FileMode.Create, System.IO.FileAccess.Write);
// Initialize PostScript input stream
System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "collaps1.ps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
PsDocument document = new PsDocument(psStream);
Console.WriteLine(document.NumberOfPages);
// If you want to convert Postscript file despite of minor errors set this flag
bool suppressErrors = true;

//Initialize options object with necessary parameters.
PdfSaveOptions options = new PdfSaveOptions(suppressErrors);
// If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
options.AdditionalFontsFolders = new string[] { @"{FONT_FOLDER}" };

// Default page size is 595x842 and it is not mandatory to set it in PdfDevice
PdfDevice device = new PdfDevice(pdfStream);
// But if you need to specify size and image format use following line
//Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new System.Drawing.Size(595, 842));

try
{
    document.Save(device, options);
    //You may fetch the basic meta data here
}
finally
{
    psStream.Close();
    pdfStream.Close();
}

//Review errors
if (suppressErrors)
{
    foreach (PsConverterException ex in options.Exceptions)
    {
        Console.WriteLine(ex.Message);
    }
}

If you have any queries, please post your query at Aspose.Page forum. Note that without a valid license you may get file size limitation while loading a PS file. Please get a temporary license for testing the features without any limitation.
You may also visit the following links for more information:
Aspose.Page for .NET
Convert PostScript to Image
Convert PostScript to PDF