Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing PDF documents with Delphi

Posted on 2004-03-25
2
Medium Priority
?
879 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

660 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