Hi,
I'm using pdfbox-app-1.6.0, and trying to print a PDF in landscape.
My test string shows up fine (roughly in center of doc) in a PDF
viewer but when I do print preview it is in very lower left bottom
edge of the preview page and when I print, no text is printed at all.

Here is my code:

        public static void main(String[] args) throws Exception {

                PDDocument doc = null;

                try {
                        doc = new PDDocument();
                        PDPage page = new PDPage();
                        page.setMediaBox(PDPage.PAGE_SIZE_LETTER);
                        page.setRotation(90);
                        doc.addPage(page);
                        PDRectangle pageSize = page.findMediaBox();
                        float pageWidth = pageSize.getWidth();
                        PDPageContentStream cs = new PDPageContentStream(doc, 
page, false,
                                        false);

                        // translation of pageWidth to use lower left corner as 
0,0
                        cs.concatenate2CTM(0, 1, -1, 0, pageWidth, 0);

                        PDFont boldFont = PDType1Font.HELVETICA_BOLD;
                        PDFont regFont = PDType1Font.HELVETICA;
                        float fontSize = 8;

                        cs.setFont(boldFont, fontSize);                 

                        cs.beginText();
                        cs.moveTo(306, 390);
                        cs.drawString("Test 1:");
                        cs.endText();

                        cs.close();
                        doc.save("TestPdf.pdf");
                } finally {
                        if (doc != null) {
                                doc.close();
                        }
                }

Thanks for the help.
Eric

Reply via email to