Delphi: How to print a PDF without showing it?

后端 未结 4 1508
隐瞒了意图╮
隐瞒了意图╮ 2020-12-08 16:23

I have been looking online for some time now, but I still haven\'t figured out how to print a PDF file in Delphi without showing the document itself, or a print dialog. I ju

4条回答
  •  孤街浪徒
    2020-12-08 17:10

    There are some different possibilities to print PDFs... it depends whether you can require Adobe Reader to be installed (I don't know if you want to distribute your tool or just use it yourself).

    1) It is possible to load the ActiveX control of Adobe Reader and use it for printing

    pdfFile.src := 'filename.pdf'; 
    pdfFile.LoadFile('filename.pdf'); 
    pdfFile.print;
    

    2) You can print PDFs with Adobe Reader itself (could be done with FoxIt too)

    ShellExecute(0, 'open', 'acrord32', PChar('/p /h ' + FileName), nil, SW_HIDE);
    

    3) You could also use Ghostview and Ghostprint

    ShellExecute(Handle, 'open', 'gsprint.exe', PChar('"' + filename + '"'), '', SW_HIDE);
    

    4) Or you could use a third party library... There are some available, but not all of them are free

    • http://www.wpcubed.com/products/pdfviewer/index.htm
    • http://www.quickpdflibrary.com/
    • http://www.gnostice.com/PDFtoolkit_VCL.asp

提交回复
热议问题