pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cenk dundar <cenkdun...@yahoo.com>
Subject Re: I need help!!!! about Landscape Page Format printing
Date Mon, 23 Sep 2013 07:15:39 GMT
There is a pdf file that included some of page is Landscape format. When I print this document
landscape pages cannot be printed correctly. It is printed as portrait format.

I see that this problem fixed with Ver 1.8.0. I am trying with last version. But The result
is same.

My test source code is below

public static void main(String[] args) throws Exception {
        String password = "";
        String pdfFile = "D:/TestPdf.pdf";
        boolean silentPrint = true;
        String printerName = "HP";
        /*for (int i = 0; i < args.length; i++) {
            if (args[i].equals(PASSWORD)) {
                i++;
                if (i >= args.length) {
                    usage();
                }
                password = args[i];
            } else if (args[i].equals(PRINTER_NAME)) {
                i++;
                if (i >= args.length) {
                    usage();
                }
                printerName = args[i];
            } else if (args[i].equals(SILENT)) {
                silentPrint = true;
            } else {
                pdfFile = args[i];
            }
        }*/

        if (pdfFile == null) {
            usage();
        }

        PDDocument document = null;
        try {
            document = PDDocument.load(pdfFile);

            if (document.isEncrypted()) {
                document.decrypt(password);
            }
            PrinterJob printJob = PrinterJob.getPrinterJob();

            if (printerName != null) {
                PrintService[] printService = PrinterJob.lookupPrintServices();
                boolean printerFound = false;
                for (int i = 0; !printerFound && i < printService.length;
i++) {
                    if (printService[i].getName().indexOf(printerName) != -1)
{
                        printJob.setPrintService(printService[i]);
                        printerFound = true;
                    }
                }
            }

            if (silentPrint) {
                document.silentPrint(printJob);
            } else {
                document.print(printJob);
            }
        } finally {
            if (document != null) {
                document.close();
            }
        }
    }



Thank you for your help!



________________________________
 From: Andreas Lehmkuehler <andreas@lehmi.de>
To: users@pdfbox.apache.org 
Sent: Sunday, September 22, 2013 10:00 PM
Subject: Re: I need help!!!! about Landscape Page Format printing
 

Hi,

Am 22.09.2013 16:46, schrieb cenk dundar:
>
>
> Hi,
>
> I am sending second time, I havent any solution about this subject. I wish you may help
me!
Maybe you should give us more input first:

What exactly did you do?
What did you get?
How about a sample pdf?

> My problem is that;
> I see Fixed problem that to print landscape page in 1.8.0 version. But I am trying with
new version the problem is same. Is there any example to print landscape pdf page correctly.


BR
Andreas Lehmkühler
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message