Skip to main content
Participating Frequently
October 25, 2007
Question

"AcroRd32.exe /t" print a PDF document ( print only, no need to open )

  • October 25, 2007
  • 10 replies
  • 33334 views
I'm using the following command to print a PDF document:
"D:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe" /t "D:\R104-20071025165656.pdf" "\\192.168.0.4\hp" "hp LaserJet 1000" "\\192.168.0.4\hp"

Now it works fine! But I have more request:
I want a command that only send the file to printer and no need to open the PDF file on local system.
So anybody can help me?

Thanks in advance!
    This topic has been closed for replies.

    10 replies

    Participant
    February 22, 2008
    Dear all,

    What if what is intended to print some other pdf file instead of a report generated from Jasper?

    Calling programs thru command-line arguments cannot be deprecated because is the simplest platform-independent way to call other programs.

    When I use Acroread32.exe /t file.pdf <UNCName> <printServName>, I send the command by another process that calls Runtime.getRuntime().exec(strExecution). The problem is that if I run the program, an Reader display shows to me (which is unnecessary), and if another app is calling this sentence, an Acro32.exe process is started upon Task Manager but it hangs-up, and remains "zombie". The printjob never completes.

    Please any help will be appreciated. Thank you very much.
    Participating Frequently
    October 28, 2007
    Pedja, you're welcome!

    If you want to achieve this function, you can use JavaScript. I remember sb. using javascript to resolve this problem. But I forgot where I find it. Good luck :)

    Muiz
    Participant
    October 27, 2007
    Thanks for the code, Muiz! I don't know if I can use this in my web app but I've already accepted this as 'not possible' so if I manage to do any progress - good for me! :) Thanks again!

    Pedja
    Participating Frequently
    October 26, 2007
    Dear Pedja,

    My program is a desktop application, no a web application. It's not the same as you. And hope the following codes can help you :)

    private void exportReportToPrinter(JasperPrint jasperPrint,int copyNum, String printerName, MediaSizeName mediaSizeName) throws Exception
    {
    // create the print service exporter so that we can print to a named
    // printer
    JRPrintServiceExporter exporter = new JRPrintServiceExporter();

    // set the report to print
    exporter.setParameter(JRPrintServiceExporterParameter.JASPER_PRINT, jasperPrint);

    // tell the exporter to print 1 copy on A4 paper
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new Copies(copyNum));
    aset.add(mediaSizeName);
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, aset);

    // let the exporter know which printer we want to print on
    PrintServiceAttributeSet serviceAttributeSet = new HashPrintServiceAttributeSet();
    serviceAttributeSet.add(new PrinterName(printerName, null));
    exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, serviceAttributeSet);

    // print it
    exporter.exportReport();
    }

    Muiz
    Participant
    October 26, 2007
    Hi Muiz,

    I am also using JasperReports and I have the same problem, I am developing a web application and I generate a report in a servlet. How can I send it directly to the client's default printer, without showing it?

    I am sorry if this is offtopic,

    Pedja
    Participating Frequently
    October 26, 2007
    > How can I send it directly to the client's default printer, without showing it?

    You can't. This would be considered a very bad thing.

    Imagine if you visited a web site and the advertisers could choose to
    start printing their adverts!

    Aandi Inston
    Participating Frequently
    October 26, 2007
    Dear all, now I use Jasperreport to generate the PDF file and then send it to printer.

    Just update to you.

    Thanks for you help!

    Muiz
    Participating Frequently
    October 25, 2007
    I use a JAVA program to create a PDF file and then just want to send the generated file to printer to print. That's all. I'm trying to find an easy way to achieve this request.

    Muiz
    Participant
    October 25, 2007
    > Command lines were declared obsolete by Microsoft around 1992.

    Fortunately, no one paid much attention, and the *nix guys simply chuckled.
    Participating Frequently
    October 25, 2007
    Thanks very much! Aandi Inston.

    So I think I need to study Acrobat SDK or find another method to resolve this problem.

    Thanks again!

    Muiz
    Participating Frequently
    October 25, 2007
    The Acrobat SDK has details on the supported interfaces to Acrobat
    (this isn't one of them). A few of them work with the free Reader too.
    Command lines were declared obsolete by Microsoft around 1992.

    Aandi Inston