FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Printing a PDF silent
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Printing a PDF silent
Posted: Mon Feb 23, 2009 01: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.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Printing a PDF silent
Posted: Mon Feb 23, 2009 01: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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Printing a PDF silent
Posted: Mon Feb 23, 2009 05: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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Printing a PDF silent
Posted: Mon Feb 23, 2009 06: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 (fw): Select all Collapse
*-------------------------------------------------------------------------------------------------------------------------------
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.
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Printing a PDF silent
Posted: Mon Feb 23, 2009 07: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.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Printing a PDF silent
Posted: 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
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Printing a PDF silent
Posted: 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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Printing a PDF silent
Posted: Mon Mar 02, 2009 09: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 (fw): Select all Collapse
            For i := 1 to nCopies
                winexec( cCmd, SW_HIDE )
            Next


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

Thank you,


Reinaldo.
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Printing a PDF silent
Posted: Tue Mar 03, 2009 02: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Re: Printing a PDF silent
Posted: Tue Mar 03, 2009 09: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
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Printing a PDF silent
Posted: Tue Mar 03, 2009 05: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.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Printing a PDF silent
Posted: Wed Mar 04, 2009 01: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 1956
Joined: Fri Oct 07, 2005 07:08 PM
Re: Printing a PDF silent
Posted: Fri Jul 30, 2010 09: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/

Continue the discussion