Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a Pdf in Land Scape orientation from a html string using Itext 2

I am using this code to generate a PDF from HTML String.

ITextRenderer renderer = new ITextRenderer();
renderer.setDocumentFromString(new String(htmlString.getBytes("UTF-8")));

In table some row contains data of a very large length.Due to which the text is overflowing the PDF.I have used Word Wrap in HTML.But this is not working in PDF generated by the code. I want to know if there is any alternative in IText 2 to Word Wrap?

Or can i generate my PDF in Landscape Mode so that i could display the whole data in PDF.

Any suggestion is welcomed.

I have attached one image at following URL. http://www.mediafire.com/download/l19qa33myluaqj4/pw-4_(2).jpg

like image 544
Dexter Avatar asked Jul 08 '13 14:07

Dexter


2 Answers

You can set your page in landscape mode using CSS, using:

@page { size: A4 landscape;}

The page size is part of CSS 3 specification, and is supported by flying saucer.

like image 154
obourgain Avatar answered Oct 18 '22 22:10

obourgain


I got the answer as suggested by @Bruno Lowagie

We can set our page in landscape mode using CSS, using:

@page { size: A4 landscape;}
like image 27
Dexter Avatar answered Oct 19 '22 00:10

Dexter