Printing a PDF silent

Printing a PDF silent

Postby reinaldocrespo » Mon Feb 23, 2009 1:35 am

Hi,

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

I'm at my wits end.

Can someone help?

Thank you,


Reinaldo.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Printing a PDF silent

Postby James Bott » Mon Feb 23, 2009 1:41 am

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Printing a PDF silent

Postby Richard Chidiak » Mon Feb 23, 2009 5:35 am

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Printing a PDF silent

Postby reinaldocrespo » Mon Feb 23, 2009 6:50 pm

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.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Printing a PDF silent

Postby reinaldocrespo » Mon Feb 23, 2009 7:44 pm

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.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Printing a PDF silent

Postby Enrico Maria Giordano » Tue Feb 24, 2009 11:06 am

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
User avatar
Enrico Maria Giordano
 
Posts: 8407
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Printing a PDF silent

Postby Richard Chidiak » Tue Feb 24, 2009 11:34 am

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Printing a PDF silent

Postby reinaldocrespo » Mon Mar 02, 2009 9:03 pm

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.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Printing a PDF silent

Postby James Bott » Tue Mar 03, 2009 2:57 am

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Printing a PDF silent

Postby Richard Chidiak » Tue Mar 03, 2009 9:40 am

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
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Printing a PDF silent

Postby reinaldocrespo » Tue Mar 03, 2009 5:57 pm

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.
User avatar
reinaldocrespo
 
Posts: 972
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: Printing a PDF silent

Postby James Bott » Wed Mar 04, 2009 1:28 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Printing a PDF silent

Postby goosfancito » Fri Jul 30, 2010 9:23 pm

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
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 111 guests