Skip to Content
0
Former Member
Aug 12, 2016 at 09:32 PM

Print a PDF file from PB

1447 Views

Hi, I need to print a PDF file from PB. I am using the next approach

TRY

OLEObject o1

o1 = CREATE oleobject

rtncode=o1.ConnectToNewObject("AcroPDF.PDF.1")

//messagebox("R",rtncode)

o1.src="C:\aplicaciones\cheques\test.pdf"

lb_result=o1.LoadFile("C:\aplicaciones\cheques\test.pdf")

messagebox("b",lb_result)

if lb_result=true then

o1.PrintwithDialog()

end if

catch ( OLEruntimeerror mierror )

messagebox("Error","No se puede ejecutar consulta impresión PDf "+string(mierror),stopsign!)

rtncode = o1.DisconnectObject()

DESTROY o1

return 0

finally

rtncode = o1.DisconnectObject()

DESTROY o1

end try

  • Not documented but if o1.src="C:\aplicaciones\cheques\test.pdf" is not set before lb_result=o1.LoadFile("C:\aplicaciones\cheques\test.pdf")
  • the load function returns false
  • Loadfile returns true, but none of all print options from the ole object works.
  • if stoped after loadfile, Acrobat reader can be seen running in the task manager

Any clue to make it work?

Any other options to selet the printer and print the file?

Regards

Alfredo