Postscript to PDF conversion error: Incorrect File Header

Dear Madam, Sir,

We are looking for a PS to PDF converter and are currently trying AposePdf.
Every Ps file we try is giving a Incorrect File Header".
Even a Ps file created with tour online tool is giving the error.

Used code: var document = new Aspose.Pdf.Document(fileNaam);

What are we doing incorrectly.

@DirkMolman,

Please zip and attach the input PS file. We will check your issue soon.

Hope this is oké.
VS2019 solution + demo ps file

TestAsposePdf.zip (268.8 KB)

@DirkMolman

Please use the following code snippet in order to convert the PS file into PDF using Aspose.PDF for .NET:

string inFile = dataDir + "Testverslag versie 10.4.0.1 PEN ACC ( APF ).ps";
string outFile = dataDir + "Testverslag versie 10.4.0.1 PEN ACC ( APF ).pdf";
            
Document doc = new Document(inFile, new PsLoadOptions() { FontsFolders = new[] { "C:\\Windows\\Fonts" } });
doc.Save(outFile);

Testverslag versie 10.4.0.1 PEN ACC ( APF ).pdf (338.5 KB)

I changed the code into:

		var dataDir = @"c:\data\";
		string inFile = dataDir + "Testverslag versie 10.4.0.1 PEN ACC ( APF ).ps";
		string outFile = dataDir + "Testverslag versie 10.4.0.1 PEN ACC ( APF ).pdf";

		if (!File.Exists(inFile))
		{
			return;
		}

		Document doc = new Document(inFile, new PsLoadOptions() { FontsFolders = new[] { @"C:\Windows\Fonts" } });

		doc.Save(outFile);

But the error remeains the same:

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Aspose.PDF
StackTrace:
at #=z8kQPmMCMQiqYwLLtpxARbtg8nbUt.#=zf$tdttQ=(Document #=zev7n9N8=, Stream #=zTMIvp0u$XC5b, PsLoadOptions #=zjqkcKb_AEEKT)
at Aspose.Pdf.Document.#=zNLf_q1I=(Stream #=zgnMJO48=, LoadOptions #=zEKblAOo=)
at Aspose.Pdf.Document…ctor(String filename, LoadOptions options)
at AsposePdf.Form1.ConvertToPdf(String fileNaam) in C:\Dev\TestApps\AsposePdf\AsposePdf\Form1.cs:line 58

What is the difference between your en mine environment.

Dirk

I have tried to run the code with an x64 and x86 build in release and bedug mode.
Results are the same

@DirkMolman

We tested the scenario using the API with a valid license in an environment i.e. Windows 10 EN x64, VS 2019, Console Application x64 debug mode. Could you please share the environment details where you are facing this error. We will further proceed to assist you accordingly.

Trial version
Windows 10
Visual Studio 2019
.Net Framework 4.7.2 and 4.8
WinForm application

Tries: x86 release and debug, x64 release and debug, Any CPU release and debug

I have tried the conversion with a Console Application, but the result is the same…
A screenshot of the app + error is attached.AsposePdfConsole.jpg (512.0 KB)

Dirk

Tonight I wil try the same on my personale computer at home.
Dirk

When I convert a PDF to TIFF there are no errors…

		using (var converter = new Aspose.Pdf.Facades.PdfConverter())
		{
			converter.BindPdf(dataDir + "px.pdf");
			// initiate conversion
			converter.DoConvert();
			// create TiffSettings & set compression type
			var settings = new Aspose.Pdf.Devices.TiffSettings()
			{
				Compression = Aspose.Pdf.Devices.CompressionType.CCITT4,
			};
			// save PDF as TIFF
			converter.SaveAsTIFF(dataDir + "output.tiff", settings);

I did some further testing with some previous versions of AsposePDF.

When trying version 20.10.0.0 the conversion of a PS file works correct.
All the newer versions are giving the “Object reference not set to an instance of an object” error

Hope this info is helpfull???

@DirkMolman

Would you please make sure that you are using a valid license with the latest version of the API? In case you do not have one, please consider applying for a free 30-day temporary license and use it at your end to evaluate the API without any restrictions. Please share a sample console application that is able to replicate the issue if it still persists.