Error: Undefined; Offending Command

I am trying to convert a ps file to a pdf and getting the error shown above.

Here is my code

 var input = "UCM21161714.ps";
        var output = "UCM21161714.pdf";

           
        var psStream = new System.IO.FileStream(input, System.IO.FileMode.Open, System.IO.FileAccess.Read);
        // initialize PDF output stream
        var pdfStream = new System.IO.FileStream(output, System.IO.FileMode.Create, System.IO.FileAccess.Write);
        // read PS file
        var document = new PsDocument(psStream);
        // create a device for output steram
        var device = new PdfDevice(pdfStream);
        try
        {
            var options = new PdfSaveOptions();
            options.SupressErrors = false;
            document.Save(device, options);
        }
        finally
        {
            psStream.Close();
            pdfStream.Close();
        }

file.zip (433.4 KB)
If i set supress errors to true then the document only generates part of the actual ps document.

@smooney1234

SupressErrors option allows the API to generate an output with ignoring the errors occur during the conversion of the document. If this value is set to true, you can print encountered error later from Exception Enumeration of PsConverterException.

Nevertheless, we have noticed the error in console output as well during the conversion in our environment and also observed that output PDF was not correctly generated. An issue for your this file has already been generated as PAGENET-202 in our issue management system. We will inform you as soon as we have some certain news about its rectification. We request for your patience. Please give us some time.

We are sorry for the inconvenience.

Thanks. Is the opposite conversion possible?

@smooney1234

The Aspose.Page is specialized to process PS/EPS/XPS documents and we are afraid that PDF to PostScript conversion may not be possible using it.

Update — this is resolved. Posting for anyone who finds this thread from a search.

PAGENET-202 was fixed in Aspose.Page for .NET 24.7. Apologies for not coming back to this thread when it shipped.

The affected PostScript file can now be converted to a complete PDF instead of failing with “Undefined; Offending Command” or producing only one page when errors are suppressed.

Update the package and rebuild:

dotnet add package Aspose.Page

The conversion call in the original snippet has since changed from PdfDevice plus Save to the current API:

using Aspose.Page.EPS;
using Aspose.Page.EPS.Device;

var document = new PsDocument("input.ps");
var options = new PdfSaveOptions(true);
document.SaveAsPdf("output.pdf", options);

Release notes: Aspose.Page for .NET 24.7 Release Notes

If you still see the problem on 24.7 or later, post your input file and the full stack trace and we will take a look.