pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andreas Lehmkuehler <andr...@lehmi.de>
Subject Re: Rotating the text using PDFBox
Date Fri, 07 Nov 2014 18:53:06 GMT
Hi,

Am 07.11.2014 um 18:34 schrieb Tilman Hausherr:
> |Hi,
>
> try using contentStream.setTextRotation() to rotate (you'll need to do a
> translation too, because it rotates around an axis, that is why it has 3
> parameters)
>
> for images,||use an AffineTransform as a parameter to drawXObject.
> |
> |https://stackoverflow.com/questions/23867451/image-rotation-with-pdfbox
>
> ||if you want to rotate everything, then better use|concatenate2CTM, use use an
> AffineTransform as a parameter to drawXObject.
>
> Makes me wonder if we should create an example.
How about this one :-) [1]

> |
> Tilman
> |


BR
Andreas Lehmkühler


[1] 
http://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/pdmodel/CreateLandscapePDF.java?view=markup
>
>
> Am 07.11.2014 um 13:48 schrieb Kernel freak:
>> 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();
>>          }
>>
>>      }
>>
>
>


Mime
View raw message