I’m interested in converting a postscript file, built from an outside process, into both PDF and HTML formats. I’ve followed all examples that I can find on the forums here and StackOverflow but result in a blank PDF document or blank HTML document each time.
I can provide code samples if needed but am primarily following this one:
I’m currently using a temporary license and an wondering if that is the issue? Any and all pointers greatly appreciated.
@MichaelWatXDI
Would you please share your sample source file(s) for our reference which you are trying to convert into PDF? We will test the scenario in our environment and address it accordingly.
Current code is posted here. This is basically what is shown in the example that I attached in the OP.
FileStream inputStream = new FileStream(qualifiedPsFileName, FileMode.Open, FileAccess.Read);
PsDocument psDocument = new PsDocument(inputStream);
FileStream outputStream = new FileStream(qualifiedPdfFileName, FileMode.Create, FileAccess.Write);
PdfDevice pdfDevice = new PdfDevice(outputStream);
Aspose.Page.EPS.Device.PdfSaveOptions pdfSaveOptions = new Aspose.Page.EPS.Device.PdfSaveOptions()
{
SupressErrors = false,
Debug = false
};
PdfDocument pdfDocument = new PdfDocument();
pdfDocument.Save(outputStream);
Here’s a typical PS file that should easily convert to PDF:
%!PS-Adobe-3.1
%%DocumentMedia: anything 612 792 0 white ()
%%Creator: XDI
%%BoundingBox: 0 0 612 792
%%DocumentNeededResources: font Helvetica
%%LanguageLevel: 2
%%Page: 1 1
%%BeginPageSetup
<</Duplex false>>setpagedevice
%%PageMedia: Type Color Weight
<<
/PageSize [612 792]
/MediaType (XDIP2)
/MediaColor (White)
>>setpagedevice
%%EndPageSetup
8.0 /Helvetica findfont exch scalefont setfont 25.00 25 moveto (Batch #82834 : 2023-05-18-029) show
24.0 /Helvetica findfont exch scalefont setfont 55.00 600.00 moveto (Foreign (One Ounce)) show
14.0 /Helvetica findfont exch scalefont setfont 55.00 575.00 moveto (Run Date: 05/18/2023) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 530.00 moveto (Workorder: ) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 500.00 moveto (Workorder Desc: ) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 470.00 moveto (Pages: ) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 440.00 moveto (Total Envelopes: ) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 410.00 moveto (Mail Piece Range: ) show
20.0 /Helvetica findfont exch scalefont setfont 55.00 380.00 moveto (Mail Piece Weight Range: ) show
20.0 /Helvetica findfont exch scalefont setfont 320.00 530.00 moveto (638975) show
15.0 /Helvetica findfont exch scalefont setfont 320.00 500.00 moveto (SDC XN Duplex) show
20.0 /Helvetica findfont exch scalefont setfont 320.00 470.00 moveto (4) show
20.0 /Helvetica findfont exch scalefont setfont 320.00 440.00 moveto (1) show
20.0 /Helvetica findfont exch scalefont setfont 320.00 410.00 moveto (1-1) show
20.0 /Helvetica findfont exch scalefont setfont 320.00 380.00 moveto (0.000-1.000) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 760 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 750 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 740 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 730 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 720 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 710 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 700 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 690 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 680 moveto (__) show
30.0 /Helvetica findfont exch scalefont setfont 0.00 670 moveto (__) show
showpage
Thanks for any suggestions.
-MW
@MichaelWatXDI
It looks like you have obtained the license for Aspose.PDF but in your code, you are using Aspose.Page. I order to convert Postscript file into PDF using Aspose.PDF, please use following code snippet:
string inFile = dataDir + "demo.ps";
string outFile = dataDir + "PStoPDF.pdf";
Document doc = new Document(inFile, new PsLoadOptions() { FontsFolders = new[] { "C:\\Windows\\Fonts" } });
doc.Save(outFile);
Also, please check below files generated in our environment.
PStoPDF_by_Aspose.PDF.pdf (4.3 KB)
PStoPDF_by_Aspose.Page.pdf (4.8 KB)