Ok, well fun to know.
Do you mind taking a look at this code sample?
A code sample (I am trying with images now and hardcoding a imported
content height of 200), but now my content is all over the place.
Why doesn't img.setAbsolutePosition work as I expect?
// merge the input into the existing document
private float merge(Document document, PdfWriter writer, URL input,
float currentBottom) throws DocumentException, FileNotFoundException,
IOException {
PdfReader pdfReader = new PdfReader(input.openStream());
int pageOfCurrentReaderPDF = 0;
System.out.println("file="+input);
while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
pageOfCurrentReaderPDF++;
PdfImportedPage page = writer.getImportedPage(pdfReader,
pageOfCurrentReaderPDF);
Image img = Image.getInstance(page);
LOG.debug("imported page " + pageOfCurrentReaderPDF);
System.out.println("currentBottom="+currentBottom);
System.out.println("pageSize="+writer.getPageSize());
System.out.println("importedPageSize="+page.getBoundingBox());
float leftOverRows = writer.getPageSize().height() -
currentBottom;
System.out.println("leftOverRows="+leftOverRows);
float importedContentHeight = 200;
//importedContent.height();
if (leftOverRows < importedContentHeight) {
System.out.println("***starting a new page");
document.newPage();
currentBottom = 0;
} else {
System.out.println("***appending to the end of a page");
}
img.setAbsolutePosition(0, currentBottom);
currentBottom = currentBottom + importedContentHeight;
writer.getDirectContent().addImage(img);
//writer.getDirectContent().addTemplate(page, 0, 0); //,
newContentBox.left(), newContentBox.bottom(), newContentBox.right(),
newContentBox.top());
}
return currentBottom;
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Paulo Soares
Sent: maandag 2 april 2007 19:41
To: Post all your questions about iText here
Subject: Re: [iText-questions] Merging pages from a pdf where each
pdfcontainsonly a paragraph
That's not possible to do with iText or anything else for that matter.
PDF
works by pages.
Paulo
----- Original Message -----
From: "Dagmar Timler" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 02, 2007 6:18 PM
Subject: [iText-questions] Merging pages from a pdf where each pdf
containsonly a paragraph
Hi
I am about to start tearing my hair out! I have looked at all the
tutorials, examples and searched through the mailing list, but it seems
what I want to do is impossible.
I have a set of PDFs which only contain a paragraph (perhaps also
images). What I need to do is merge a subset of these PDFs, but
obviously the paragraphs need to be on one page if they fit.
I see I can use cropping, but the problem is I don't know what size
because the PDFImportPage reports a size nearly the page size.
So, how can I find out the size of my paragraphs and how can I position
them nicely on the page?
Any suggestions, pointers, code examples would be much appreciated.
Thanks
Dagmar
------------------------------------------------------------------------
-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share
your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDE
V
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/