简体   繁体   中英

How to programmatically convert PostScript to PDF with the fewest steps?

Is there any way to just slap on a header and use a PS file as a PDF, assuming that the PS is very simple and do anything complicated?

I want to do this programmatically, not using ps2pdf.

Thanks.

You can certainly *try" "just slapping on a header"... but I don't think you'll get too far:-)

Personally, I'd suggest ps2pdf is the best solution (for example, invoke it with ShellExec() or system()).

But if you want a programmatic solution, ps2pdf is just a wrapper around Ghostscript. Have you considered using the Ghostscript libraries?

You cannot wrap a PostScript file into a PDF file.

Although a PDF file looks similar to a PostScript file, a PDF file must have a special structure, including a cross-reference table at the end with file offsets to different parts of the PDF file.

To understand the PDF file format you can download the PDF Reference from:

http://partners.adobe.com/public/developer/en/pdf/PDFReference.pdf

If your software generates the PostScript file, maybe you can extend it to write a PDF file too? It takes some time to understand the PDF file format but it is not especially difficult if you are familiar with PostScript.

If this is too difficult, then use pdf2ps to do the hard work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM