Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing PDF documents with Delphi

Posted on 2004-03-25
2
Medium Priority
?
880 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
2 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 375 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

927 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