Page 1 of 1

Printing a PDF silent

PostPosted: Mon Feb 23, 2009 1:35 am
by reinaldocrespo
Hi,

I need to print a PDF to a specific printer silently.

I'm at my wits end.

Can someone help?

Thank you,


Reinaldo.

Re: Printing a PDF silent

PostPosted: Mon Feb 23, 2009 1:41 am
by James Bott
Hi Reinaldo,

I haven't tried it, but you can try this:

http://www.verypdf.com/pdfprint/pdf-print-cmd.html

Let us know if it works for you.

Regards,
James

Re: Printing a PDF silent

PostPosted: Mon Feb 23, 2009 5:35 am
by Richard Chidiak
Reinaldo

Try sumatrapdf

http://blog.kowalczyk.info/software/sum ... nload.html

SumatraPDF -print-to-default -exit-on-print c:\MyPdfFile.PDF
SumatraPDF print-to-PRINTER_NAME -exit-on-print c:\MyPdfFile.PDF

HTH

Richard

Re: Printing a PDF silent

PostPosted: Mon Feb 23, 2009 6:50 pm
by reinaldocrespo
Thank you very much both, James and Richard.

I tested both and found both solutions to be simple and reliable. I'm going with Sumatra. It renders a better representation of the original PDF.

Here is the final code:
Code: Select all  Expand view

*-------------------------------------------------------------------------------------------------------------------------------
function PrintPdf( cFile, cPrinter, nCopies )
Local cSumatra  := getIniFilePath() + "SumatraPdf.exe"
local cCmd      := cSumatra + ' -Print-to "' + ;
                    alltrim( StrToken( cPrinter, 1, "," ) ) + ;
                    '" -exit-on-print ' + cFile

DEFAULT nCopies := 1

    TRY
   
        if !file( cSumatra )
            MsgStop( ...
        else
            winexec( cCmd, SW_HIDE )
        endif
       
    END 
RETURN Nil 
   


Again, thank you very much!


Reinaldo.

Re: Printing a PDF silent

PostPosted: Mon Feb 23, 2009 7:44 pm
by reinaldocrespo
I should mention that I also posted the same question to the xharbour ng and got some interesting answers. Apparently Adobe Reader itself can be used to print silently from the command line:

http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
I tried to test it, but found that it has many .dll dependencies making it awkward to distribute to all pc's at the customer's sites.

Patrick also suggested another solution worth noting:
http://www.silentprint.com/

Hope that these solutions help others as it has helped me.


Reinaldo.

Re: Printing a PDF silent

PostPosted: Tue Feb 24, 2009 11:06 am
by Enrico Maria Giordano
reinaldocrespo wrote:Apparently Adobe Reader itself can be used to print silently from the command line:

http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
I tried to test it, but found that it has many .dll dependencies making it awkward to distribute to all pc's at the customer's sites.


Is it not enough to install Adobe Reader in all customer's PCs?

EMG

Re: Printing a PDF silent

PostPosted: Tue Feb 24, 2009 11:34 am
by Richard Chidiak
Enrico

There are otjer considerations with Adobe acrobat reader related to i'ts version

Silent print will not be usable on all acrobat versions and at least with a different code ... which makes it more complex

Sumatrapdf is just one exe , nothing else to distribute with...

PS : Doesn't work on win 98 or win ME

HTH

Richard

Re: Printing a PDF silent

PostPosted: Mon Mar 02, 2009 9:03 pm
by reinaldocrespo
Richard;

I need to print a # of copies. So far I was trying to do it with a loop. But I'm finding that it almost brings Windows to a halt.

Code: Select all  Expand view

            For i := 1 to nCopies
                winexec( cCmd, SW_HIDE )
            Next
 


Any ideas how to print variable number of copies using Sumatrapdf?

Thank you,


Reinaldo.

Re: Printing a PDF silent

PostPosted: Tue Mar 03, 2009 2:57 am
by James Bott
Reinaldo,

I don't know how to do it with SumatraPDF, but pdfprint can do it.

http://www.verypdf.com/pdfprint/pdf-print-cmd.html

Regards,
James

Re: Printing a PDF silent

PostPosted: Tue Mar 03, 2009 9:40 am
by Richard Chidiak
Reinaldo

There is no available option for this in sumatrapdf

You can try setting the printer copies to xx whatever the number you want before printing with sumatrapdf, not tested but worth trying

HTH

Richard

Re: Printing a PDF silent

PostPosted: Tue Mar 03, 2009 5:57 pm
by reinaldocrespo
It is a little complicated. These pdfs are stored on a blob field of an .adt table. Depending on certain other fields, the pdf should print x number of copies on n number of printers. For example, certain pdfs need to print 5 copies on a color printer xyz, 3 copies on printer acme, and 1 copy on printer n; while another pdf might only print 8 copies on printer n. This is done with at least 500 documents each day. So I need to be able to control the printer as well as the number of copies from source.

With sumatraPdf I've been able to print the pdfs on a specific printer and the output is faithful to the stored document, but the I've learned that sumatraPdf is a memory hog when it comes to printing. It eats all available memory bringing windows to a crawl. The bigger the pdf the longer the time it takes and the slower the computer becomes. So placing the instruction inside a loop only complicates matters exponentially.

I tried verypdf, but the printout is not quite as the original pdf. The margins as well as the aspect is a bit distorted. Not much, but enough not to be acceptable.

I'm thinking that perhaps there is a way to convert the PDF back to emf that can then be managed with tprinter?


Reinaldo.

Re: Printing a PDF silent

PostPosted: Wed Mar 04, 2009 1:28 pm
by James Bott
Reinaldo,

>I tried verypdf, but the printout is not quite as the original pdf. The margins as well as the aspect is a bit distorted. Not much, but enough not to be acceptable.

verypdf has scaling options, perhaps you can correct for this. Also, have you contacted verypdf about the problem? Maybe they have a solution.

Regards,
James

Re: Printing a PDF silent

PostPosted: Fri Jul 30, 2010 9:23 pm
by goosfancito
James Bott wrote:Reinaldo,

I don't know how to do it with SumatraPDF, but pdfprint can do it.

http://www.verypdf.com/pdfprint/pdf-print-cmd.html

Regards,
James


interesante