How to send pdf to default printer in silent mode

1,298 views
Skip to first unread message

BD

unread,
Dec 2, 2016, 8:22:04 AM12/2/16
to Harbour Users
Hi Experts,

What is the Harbour function to send a pdf file to the default printer in silent mode ?

I have tried the shellexecute option, but Acrobat Reader would not close when the printing is done.

Thanks.

Jarosław Kądzioła

unread,
Dec 2, 2016, 8:26:41 AM12/2/16
to harbou...@googlegroups.com
hI
What is the Harbour function to send a pdf file to the default printer in silent mode ?

I have tried the shellexecute option, but Acrobat Reader would not close when the printing is done.


Try Sumatra PDF with '-exit-on-print' command

BR
JK

 

Toni Martins

unread,
Dec 2, 2016, 9:18:35 AM12/2/16
to Harbour Users

Hope this help:

Open Reader at a specific page of a pdf:

AcroRd32.exe /A "page=page_number" filename.pdf

Open Reader and display a file:

AcroRd32.exe filename.pdf

Open Reader and print a file:

AcroRd32.exe /p filename.pdf

Open Reader, print a file while suppressing the Acrobat print dialog box, then terminate Reader:

AcroRd32.exe /t filename.pdf printername drivername portname
  • printername – The name of your printer.
  • drivername – Your printer driver’s name. Whatever appears in the Driver Used box when you view your printer’s properties.
  • portname – The printer’s port. portname cannot contain any “/” characters; if it does, output is routed to the default port for that printer.

A few more options:
/n Launch a separate instance of the Acrobat application, even if one is currently open.
/s Open Acrobat, suppressing the splash screen.
/o Open Acrobat, suppressing the open file dialog.
/h Open Acrobat in hidden mode.



Can see some more info here:
http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_open_parameters.pdf

Paola Bruccoleri

unread,
Dec 2, 2016, 9:50:38 AM12/2/16
to harbou...@googlegroups.com
Hi..

two options:
1)
cRun := 'sumatrapdf.exe -print-to "'+cImpresora +'" ' + ' -print-settings "' + '2x' +'" ' + cArchTra   // 2 copy
hb_run( cRun)

2)
for i:= 1 to nCopy
  hb_run( 'foxit.exe /t ' + cArchTra + ' "' + cImpresora + '"')
next

works ok with the foxit reader 6.2; with newer versions not.
If you need it I'll send it to you.

With acrobat reader I found it impossible

byeeee

Toni Martins

unread,
Dec 2, 2016, 10:02:25 AM12/2/16
to Harbour Users
How to close acrobat:

cRun := 'TASKKILL /F /IM AcroRd32.exe'
hb_run( cRun)

Pete

unread,
Dec 2, 2016, 11:15:43 AM12/2/16
to Harbour Users


On Friday, 2 December 2016 15:22:04 UTC+2, BD wrote:

I have tried the shellexecute option, but Acrobat Reader would not close when the printing is done.



Then forget that cumbersome acrobat, and go open-source, portable and lightweight!

- download SumatraPDF from here:
 http://www.sumatrapdfreader.org/dl/SumatraPDF-3.1.2.zip
and unzip it into your program's folder.

- add this line to your code and you're done:

lPrinted := wapi_ShellExecute( 0, "open", "sumatrapdf.exe", "-print-to-default " + cPdf ) >= 32

(`cPdf` is the name of PDF file you want to print.)


Paul Smith

unread,
Dec 2, 2016, 6:30:55 PM12/2/16
to Harbour Users
No expert but as a rank amateur I call a second executable with the ability to email using win_mapisendmail() or print using wapi_shellexecute()
The second executable is called from the first using the run command. If something goes wrong with email or printing the first program doesn't freeze or fail,
it's clunky but works ok, I think that an expert could do it with multithreading but I haven't 

Cheers
Paul

BD

unread,
Dec 2, 2016, 8:27:28 PM12/2/16
to Harbour Users
Just tried out the SumatraPDF, it is very portable, but the printing takes a long time though !


Regards.
Reply all
Reply to author
Forward
0 new messages