Announcement

Collapse
No announcement yet.

Send PDF to laserprinter without preview?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Send PDF to laserprinter without preview?

    Tried the following but got Adobe on the taskbar. Is this way the best to directly print a PDF from a program.

    Code:
    #INCLUDE "WIN32API.INC"
    FUNCTION PBMAIN
    
      DIM zfName AS ASCIIZ * %MAX_PATH
      MSGBOX("Ready")
      zfName = "text_demo.pdf"
      ShellExecute 0, "print", zfName, "", "", %SW_SHOW
      
    END FUNCTION
    Bob Mechler

  • #2
    ShellExecute (filename to be opened by associated program) asks that the associated program - Adobe Acrobat in this case - be started, so the behavior of your program depends on the behavior of Acrobat.

    While I think using %SW_HIDE instead of %SW_SHOW will hide the Window, you should look in your Acrobat doc for the available command-line options and pass those giving the desired behavior as parameter three of your statement. (Assuming such options are even available from Acrobat).

    You could maybe install a PDF print driver, or use a program other than Acrobat to handle the printing... I'm sure others will suggest such things; but as long your program is asking for Acrobat (or whatever program is associated with the "print" command for "*.pdf" files) to do the job, you'll have to accept that program will do it "its way."

    MCM
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Kinda like I thought. We've had a problem with Ddoc and PDF printer drivers, don't know which is the problem at this point but there is a lot of spooling going on and some PDF's end up with nothing in them on long statement runs. I did an XPRINT work-a-like for just a few ddoc statements we were using and specifying a pdf printer driver. xpstartdoc instead of dpstartdoc, that type of thing.

      The case in point was a 68 megabyte single pdf file that held eight thousand statements with pie charts separated by a blank page that was headed to a mailing house with a printer farm where the single pdf was dissected and each statement was sent to whatever printer was free.

      Ddoc and the pdf printer driver got a couple of thousand statement into the job and started putting blank pages into the pdf, thousands of them.

      The XPRINT based work-a-like to the same PDF Printer Driver worked fine.

      I'm assuming the spooling of the ddc's and the spooling of the PDF's from PDF Creator just stopped communicating at some point. And it was probably something I didn't set up right, just not sure.

      I've been playing around with two options:

      1. XPRINT to a PDF Printer Driver instead of ddoc
      2. Libharu to PDF and straight to printer without adobe hanging around.

      Ddoc only fails for us on long print jobs and or multiple printer jobs where several jobs are being created at the same time. It gives the message the ddoc has a problem and needs to close on both Windows Vista Business and XP machines where 15 or more windows are open at the same time on two large monitors (my supervisor's machine).

      We used version 9i also to make sure my find function addon wasn't involved.

      We've gotten into a lot of PDF stuff lately by offering options of emailing statements or having them availabe from a web site where users can get up to date Trust account information.

      Bob Mechler

      Comment


      • #4
        >. Libharu to PDF

        I do this now for one client. What he had me do was limit the size of any one "*.PDF" file... primarily for emailing purposes. He mails approx 1500 invoice pages per day to a print/mail house for all invoices which are NOT emailed to customers, which are naturally already stored in separate files.

        But I don't see why you'd have to use LIBHARU to PDF... maybe just limiting the number of pages per physical file would solve your immediate problem, and it sure couldn't be that difficult to code into the application.

        Instead of "Print one [big] file" you'd just Print <number> [smaller] files, one at a time.

        MCM
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          The customer has no choice. The outside print,stuff and mail firm requires a single pdf file with one blank sheet between.

          Checked the command line switch possibility. With Adobe Reader 7 and AcroRd32.exe in the path the following command silently prints to any laser printer.

          Found this on the Adobe website.

          AcroRd32.exe /t text_demo.pdf \\servername\printername

          http://support.adobe.com/devsup/devs...docs/52080.htm

          So I have my answer. Hope someone else finds it useful.

          Bob Mechler
          Last edited by BOB MECHLER; 15 Jan 2009, 12:35 PM. Reason: added link

          Comment


          • #6
            Adobe Reader 9.0 issue

            Using the method above works fine with Adobe 7 but not with Adobe 9 reader on Vista Business. It stops after each command line /t invocaton and requires you to dismiss Adobe before the next one will print.

            Is there a way to print and number of pdfs silently. ex. /t parameter?

            Bob Mechler

            Comment


            • #7
              ???
              Code:
              for %%f in (foldername\*.pdf) do cmd /c AcroRd32.exe /t %f  \\servername\printername
              ???

              Or, program equivalent (DO, DIR$, if not "", shellexecuteEx/CreateProcess, LOOP) if you want.

              Or, I'm pretty sure Acrobat offers an API.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                I'm not familiar enough with shell scripting. I tried your example and it fussed over the %%f. I used simple text files instead of pdf's but it kept asking More? on the next line.

                I had put several of the
                Code:
                AcroRd32.exe /t text_demo.pdf \\servername\printername
                in a batch file and got the confirmation to close before the next would fire on Adobe 9 and Vista Business

                In Experts Exchange they dance all around the straightforward use of the ShellExecute repeatedly but not specifically about adobe 9 on Vista Business. Using the batch works fine with Adobe 7 on XP and silent printing.

                It was mentioned several times in posts that the API costs money from Adobe.

                Next I'll check out Foxit Reader to see if there is a silent print option.

                There are several inexpensive ones that indicate they support silent printing without the use of acrobat reader.

                Seems odd to me that at this stage of the game there isn't a way to create pdf's for preview with a silent print option in a freeware format that doesn't involve a pdf printer.

                I didn't see anything in libharu that offered a silent print option or it might make the perfect add-on.

                Bob Mechler
                Last edited by BOB MECHLER; 19 Jan 2009, 12:07 PM. Reason: Editing needed

                Comment


                • #9
                  If the prompt for "more" is coming from Acrobat, then your problem is with Acrobat. Maybe there is another command-line switch you need to use (many command-line utilities have a "quiet" or "silent" mode).

                  Or, Acrobat has an API, which surely includes "print" functions.

                  Or, may you can use the command interpreter to close the console when the print operation has completed. I think it's "cmd /k" but here is the A-Z command-line reference link: http://technet.microsoft.com/en-us/l.../bb490890.aspx
                  (I don't know that is a good idea but it is an idea).

                  Or, maybe you can use CreateProcess or ShellExecuteEx to get process/thread handles, then detect when Acrobat's main GUI window goes into idle with WaitForInputIdle(). But I'd guess Acrobat is smart enough to do its printing is a separate thread of execution. In that case maybe you'll have to monitor the thread count of the Acrobat process. (starter code here:Enumerate System Threads To Callback November 25, 2002)

                  Or maybe, you need to "Google" for "unattended print PDF files". Hard to believe if Acrobat does not support this someone hasn't come up with a utility you can use.

                  And AFAIK, LIBHARU does not offer ANY printing support... it just gets you a Portable Document Format file.

                  MCM
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Thanks for 'where to look' and 'what to try' clues.

                    I'm sure if I went through the apparent application process described on Adobe's site I could eventually find the answer there, but I'd like it to be a Adobe - less solution.

                    Libharu, in my simple tests, should be sufficent for us to produce the print preview half of the functionality we want. Since we are increasingly producing pdf's for more and more uses, I thought it would be a good time to see if there was a complete print/preview solution using pdfs instead of Ddoc which has been and still is a great product.

                    Some of our largest customer's IT departments look sideways when we talk about reports having a ddc extension. They are looking more toward standards than our smaller customers.

                    I'm trying to understand the relationship between Ghostscript, PS files and PDf, they all seem to be interrelated.

                    For special jobs before Ddoc we created checks using straight PCL including the security watermark, not that I'd want to switch to that for all printing.

                    I could just give the user a choice of Ddoc or Libharu PDF's where they have to preview it before printing or put up with closing the adobe taskbar item when using AcroRd32.exe and the /t option.

                    Thanks,

                    Bob Mechler

                    Comment

                    Working...
                    X