Print direct to printer with Acrobat Reader

Xbase++ 2.0 Build 554 or later
Post Reply
Message
Author
Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Print direct to printer with Acrobat Reader

#1 Post 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.

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Print direct to printer with Acrobat Reader

#2 Post 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 ) 
greetings by OHR
Jimmy

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Print direct to printer with Acrobat Reader

#3 Post 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 ...

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Print direct to printer with Acrobat Reader

#4 Post 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.

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Print direct to printer with Acrobat Reader

#5 Post 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. ;)

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Print direct to printer with Acrobat Reader

#6 Post 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() }  
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Print direct to printer with Acrobat Reader

#7 Post 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 954 times
it have Method

Code: Select all

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

Code: Select all

o:lTestActiveById()
o:KillById()
greetings by OHR
Jimmy

Victorio
Posts: 633
Joined: Sun Jan 18, 2015 11:43 am
Location: Slovakia

Re: Print direct to printer with Acrobat Reader

#8 Post 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).

Post Reply