Solved

Printing PDF documents with Delphi

Posted on 2004-03-25
2
875 Views
Last Modified: 2008-11-25
Hi, everybody.

I need a snippet that will open an existing PDF document, and print an arbitrary page from it.
If it takes any library or component to do it, it must be available free of charge (or must ship with Delphi 7).

It would be most desirable if it was also possible to print several separate pages as one single print job.

In pseudocode, it would look like this:

PDF_File.Open('C:\MyDoc.pdf');
PDF_File.StartPrintJob('SomePrinter'); // Default printer is just fine. I don't care
PDF_File.PrintPage(34);
PDF_File.PrintPage(122);
PDF_File.PrintPage(345);
PDF_File.ClosePrintJobAndDamnPrintIt; // :-)

To print pages 34, 122, and 345 without giving the chance of other users sending anything to the printer between one of my pages and another.

I also don't care if it is done directly with Delphi, or if it uses Automation to have Acrobat Reader do it.

Thanks very much for your help:

Jack
0
Comment
Question by:JackNaif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 125 total points
ID: 10678132
You can use the ActiveX control of Adobe Acrobat

from Component menu > Import ActiveX control then choose
Acrobat Control for ActiveX, then press Install

the Pdf Activex control for Adobe acrobat will be added to ActiveX Tab of Delphi then
 drop pdf control to the form and try this code

procedure TForm1.Button1Click(Sender: TObject);
begin
  Pdf1.Visible := False;
  Pdf1.LoadFile('c:\test.pdf');
  pdf1.printPages(1,1);
end;

if you want to print the entire file Call pdf1.Print

Shane
0
 
LVL 15

Expert Comment

by:simonet
ID: 10686168

Just to add to Shane's comment:

everyone that has Acrobat Pro or Acrobat Viewer installed has the ActiveX control installed on their computer (nowadays that means basically everyone), so there is no need for you to redistribute the activeX control along with your app.

Alex
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question