Hello friends,

I am using PDFBox to create PDF's. Thanks to some members in the mailing
list, especially : Maruan Sahyoun, I am nicely acquainted with the
platform, and now know how to achieve basic tasks.

While creating the PDF, I am looking for the page size to be A4(already set
by PAGE_SIZE.A4), the page rotation in potrait mode, which is by default.

Problem : I would like to enter data in landscape mode. So basically, the
text should start from left bottom end of the page which is in potrait mode
and 90 degree tilted.

This is my first step of creating the document, as I have found functions
for creating tables, inserting images and all. Kindly let me know. Find the
code below(pretty basic)

PDF creation :

PDDocument document = new PDDocument();

        PDPage blankpage = new PDPage(PDPage.PAGE_SIZE_A4);

        blankpage.setRotation(270);
        document.addPage(blankpage);

        PDFont font = PDType1Font.COURIER_BOLD_OBLIQUE;

        try {
            PDPageContentStream contentStream = new
PDPageContentStream(document,blankpage);
            contentStream.beginText();
            contentStream.setFont(font,15);
            contentStream.moveTextPositionByAmount(100,700);
            Notes note = getNoteById(7600);
            String abc = note.getNotetext();
            contentStream.drawString(abc);
            contentStream.endText();
            contentStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            document.save("blankpage.pdf");
        } catch (IOException e) {
            e.printStackTrace();
        } catch (COSVisitorException e) {
            e.printStackTrace();
        }
        try {
            document.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

Reply via email to