Page 1 of 1

Print direct to printer with Acrobat Reader

Posted: Thu May 03, 2018 11:57 am
by Victorio
Hi,

I have in program direct print with Adobe Acrobat reader like this :
RunShell("/N /T "+cestatlac+ntsppdf,cestapdfview,.t.,.t.)

because after print stay open acrobat on bottom taskbar I realize kill it after print , using test if Acrord32 is in tasklist. Acrobad killed only when in tasklist not exist row with name of printed file.
This works fine to this moment, when I connect my new network printer.
Document "go" to printer, but immediately acrobat kill and print stopped.
This looks than document send to printer via LAN, Acrobat windows closed, blank acrobat on bottom taskbar stay and I do not know, when can kill acrobat process.

So, I want ask, who know how test if document was printed.
I found one solution, but no very elegant, used WMIC.EXE PRINTJOB GET >filequeue.csv
called via Runshell

after generate file filequeue.csv I search, if there is name of my printed file, when no, can kill acrobat, when yes, wait and after some time generate queuelist again.

But this is not very elegant system, because using runshell and generate files on disk etc.

Exist some DLL called function to list queues, or this (calling DLL) can be same as call exe ?

I do not want any other utilities, application because this need install on PC every users. This must be
universal and using internal OS functions.

Re: Print direct to printer with Acrobat Reader

Posted: Thu May 03, 2018 4:28 pm
by Auge_Ohr
Runshell is not the best Way to open other Windows Apps.

to open / print use this

Code: Select all

   lSuccess := @SHELL32:ShellExecuteA( APPDESKTOP() :GetHWND(), ;
                                       "open", ;       // "open" or "print"  
                                       cPath + cFile, ;
                                       0, ;
                                       CURDIR(), ;
                                       SW_NORMAL ) 

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 2:58 am
by Victorio
Jimmy, thanks this also works, but still I do not have control print process.
always stay opened Acrobat window on bottom taskbar.
when kill acrobat immediately after

lSuccess := DllCall("SHELL32.DLL", DLL_STDCALL,"ShellExecuteA",AppDesktop():GetHWND(),"open", pomsuborpdf,NIL,curdir(),SW_NORMAL)

print stopped, not realize.

I do not know, why compiler tell error when I write your syntax ?
lSuccess := @SHELL32:ShellExecuteA( APPDESKTOP() :GetHWND(), ;
"open", ; // "open" or "print"
pomsuborpdf, ;
0, ;
CURDIR(), ;
SW_NORMAL )

something with @ operator ?

I do not understand why Acrobat stay opened after print ...

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 4:25 am
by Victorio
when some other testing, I figured, than when print to network printer, some time is file SPL in
spool directory
c:\Windows\System32\spool\PRINTERS\

but after some time lost, because was sended to printer via network.

I mean use this to test , if files was printed, so here are other problems because when printer stopped, or offline, I cannot wait to print files.

I do not found moment, when can kill Acrord32.exe process. :think: , where is this moment when file is sended to printer. when kill them soon, print break, but set long interval do not want. because this slow down work with program.

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 5:12 am
by Victorio
now because long time I used for searching solution found one good idea, put buttom to user confirm, when document was printed.
this looks better solution, because some documents can be very large and need more time to print and early close acrobat can cause incompletly print document.

So if somebody can other idea, I like to try it. ;)

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 5:27 am
by skiman
Hi,

Any reason why you don't try to use the activex control?

In the samples\activex\acrobat.prg sample, you can add the following to test:

Code: Select all

DCADDBUTTON CAPTION 'Print PDF Document' SIZE 200,25 PIXEL PARENT oToolBar ;
      ACTION {|| oAcrobat:printall() }  

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 5:31 am
by Auge_Ohr
Victorio wrote:I do not know, why compiler tell error when I write your syntax ?
lSuccess := @SHELL32:ShellExecuteA( APPDESKTOP() :GetHWND(), ;
something with @ operator ?
sorry, that is ot4xb Syntax

Code: Select all

@SHELL32 -> SHELL32.DLL
if you want Control of other Windows App you need to know its Handle

you can try Pablos (http://www.xbwin.com) TRunShell where you get a Handle of Instance which you have start.
TRunProcess.zip
need ot4xb
(3.95 KiB) Downloaded 822 times
it have Method

Code: Select all

o:Wait( 1000 ) // Wait 1 seconds
o:Kill()
and

Code: Select all

o:lTestActiveById()
o:KillById()

Re: Print direct to printer with Acrobat Reader

Posted: Fri May 04, 2018 6:49 am
by Victorio
Thank you very much, Jimmy and Chris. I must try ...

Chris: I work with Active X , but I have some problems because not use this. One of problem is some notify windows when print to printer, adobe reader show confirm window to allow script , user must confirm, and cannot save to not show again (maybe in registry can set but modify registry on Windows 10 is problem when user is not admin).