1. Tracy Lamb
  2. PowerBuilder
  3. Saturday, 1 February 2020 20:00 PM UTC

My database has a table with links to PDF documents.  Can I send those PDFs to the printer from within my application?

TIA,
Tracy

Accepted Answer
Tracy Lamb Accepted Answer Pending Moderation
  1. Wednesday, 4 August 2021 21:02 PM UTC
  2. PowerBuilder
  3. # Permalink

I finally figured this one out...

First, declare an External Function:

FUNCTION long ShellExecute (uint ihwnd, string lpszOp, string lpszFile, string lpszParams, string lpszDir, int wShowCmd ) LIBRARY "Shell32.dll" ALIAS FOR "ShellExecuteW"

Then call that function:

shellexecute(handle(this), "print", ls_filename, ls_null, ls_null, 0)

On my computer, shellexecute() opens an Acrobat Reader to do the printing... minimized in the task bar.  Not sure what it would do if I didn't have Reader installed... can't really test that. The 0 tells the program launched to hide the window, probably why it's showing minimized in my task bar?

~~~Tracy

 

Comment
  1. Armeen Mazda @Appeon
  2. Wednesday, 4 August 2021 21:26 PM UTC
Thanks for sharing the solution!
  1. Helpful
  1. Sivaprakash BKR
  2. Thursday, 5 August 2021 10:41 AM UTC
Have you tried PDFToPrinter.exe?
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 17:04 PM UTC
  2. PowerBuilder
  3. # 1

Hi Tracy;

  The easiest way (and what I do) is to use PB's "iNET" object class and the HyperLinkToURL() command to download the related PDF file into the App User's default web browser. Then from there, they can print all or part of the the PDF, change its size, font, orientation, etc as they desire from the browsers internal PDF / Print functionality.

Food for thought!  ;-)

HTH ... Chris

Comment
  1. Tracy Lamb
  2. Monday, 3 February 2020 17:44 PM UTC
Thanks Chris, that's a very good idea too.

My application allows users to "attach" external documents to their lab folder. They don't want to view the documents after they're attached. They just want to press a button and print them along with the other reports from my app.
  1. Helpful
  1. Chris Pollach @Appeon
  2. Monday, 3 February 2020 18:36 PM UTC
Hi Tracy;

I have not tried this with a PDF but - "in theory" - using the new built-in Web Browser control in the PB2019 R2 release one could download the PDF to that control and then command it to print. Keeping the new Web Browser control invisible - should accomplish the PDF printing transparently. You can download the PB2019R2 Beta and try that today.

Also, you could try this today with any Appeon PB using Roland's web browser control ...

FYI: https://www.topwizprogramming.com/freecode_webbrowser.html

HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
Georg Brodbeck Accepted Answer Pending Moderation
  1. Monday, 3 February 2020 09:39 AM UTC
  2. PowerBuilder
  3. # 2

Possible - yes. But you probably need to use some tricks:

Option 1: Use the run() function to print the PDF from command line (Adobe Reader or another PDF tool required) - just google "windows print pdf from command line".

Option 2: Embed Adobe Reader as OLE object (so you even have a print preview) - a print button is integrated in the OLE.

Hope this helps.

I think there's no PB native way to do this - or does anyone know a way?

Comment
  1. Tracy Lamb
  2. Monday, 3 February 2020 16:06 PM UTC
Thanks... I'll look into that today.
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.