×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

PDF Printing in visual foxpro

PDF Printing in visual foxpro

PDF Printing in visual foxpro

(OP)
Hello all

I am developing an application in visual FoxPro where I have to open a PDF file and print specific page numbers from it and close the file. System will loop thru a list of PDF files and perform the above actions. I have searched online for such a solution but not able to find any. Could someone please help me on this?

Thanks in Advance

RE: PDF Printing in visual foxpro

You can use ShellExecute() to print the entire PDF (pass "print" as the second parameter), but unfortunately that won't let you print a specific page.

No doubt somebody else will have the answer.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: PDF Printing in visual foxpro

Have a look at Link
I THINK it can do what you want...

RE: PDF Printing in visual foxpro

Dan, you linked to XFRX. I don't think that will solve the problem. XFRX can convert a VFP report to a PDF, but as far as I know it has no ability to print an arbitrary PDF. You would need some other software for that. Mark's suggestion for Bullzip might be more appropriate.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: PDF Printing in visual foxpro

Another suggestion:

Run your standard PDF viewer from the command line. How you do that would depend on which utility you use to view and print PDFs. Here is some code that would work for the (free) SumatraPDF utility:

First, declare ShellExecute(). You only need to do this once.

CODE -->

DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, ; 
  STRING cAction, ; 
  STRING cFileName, ; 
  STRING cParams, ;  
  STRING cDir, ; 
  INTEGER nShowWin 

Then, to print specified pages from a given file:

CODE -->

cAction = "open"
cFileName = "C:\Program Files\SumatraPDF\SumatraPDF.exe" && substitute correct path
cParams = '-print-to-default -print-settings "1-2" c:\work\test.pdf'
              && this says: print pages 1 -2 of file test.pdf to the default printer
ShellExecute(0, cAction, cFileName, cParams, "", 1) 

You can use similar code to print to a printer other than the default, to print odd or even pages, to print duplex or single-side, to scale the printing, and several other options.

The disadvantage of this technique is that it depends on Sumatra being installed. Other command-line options might be available with other utilities.

Here's a link: https://www.sumatrapdfreader.org/docs/Command-line...

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: PDF Printing in visual foxpro

Hello,

I remember that there is a portable version of sumatra
which you could add to your program folder without installing.
Then use Mike's tips.

Regards
tom

RE: PDF Printing in visual foxpro

(OP)
Thanks so much Mike. Works like a charm

Just a query. If I need a different printer, can I just replace the -print-to-default with -print-to-<printer name>? or is there some other consideration?

Thanks in advance

Ravi

RE: PDF Printing in visual foxpro

Glad it worked, Ravi.

Quote:

If I need a different printer, can I just replace the -print-to-default with -print-to-<printer name>?

That should be fine. For exammple:

-print-to "HP LaserJet 400"

Be sure to use double-quotes for the printer name.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close