1T3XT info, I see now that although I have achieved the first goal (tagged pdf), I have lost alot in the process.
PdfWriter is the only class that allows setTagged. Which means all the interactive features are lost. (_ITEXT in Action_ Table 2.2) There is also this thread: http://www.mail-archive.com/[email protected]/msg31334.html The good part of the story is that I am going from xhtml to xsl-fo to pdf and then using ITEXT to add xmp metadata. I thought I could also add tagging. However, since I am transforming from xhtml to pdf, maybe I can still use ITEXT to create the document. Thanks, -Mike code: Document document = new Document(PageSize.A4); // we create a PdfReader object PdfReader reader = new PdfReader("lcp.pdf"); int n = reader.getNumberOfPages(); //New Bookmarklist = Bookmarklist from Source PDF List<HashMap> bookmarks = SimpleBookmark.getBookmark(reader); // step 2 PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("lcpTagged.pdf")); writer.setTagged(); // step 3 document.open(); PdfStructureTreeRoot root = writer.getStructureTreeRoot(); // we call the root "Everything" PdfStructureElement eTop = new PdfStructureElement(root, PdfName.SECT); // "P" is a standard structure, no need to map PdfStructureElement e1; // step 4 PdfContentByte cb = writer.getDirectContent(); PdfImportedPage page; for (int i = 1; i < n; i++) { e1 = new PdfStructureElement(eTop, PdfName.PAGE); if(i > 1) { document.newPage(); }//end if // the paragraph is contained in a single sequence cb.beginMarkedContentSequence(e1); page = writer.getImportedPage(reader, i); cb.addTemplate(page, 1f, 0f, 0f, 1f, 0f, 0f); cb.endMarkedContentSequence(); }//end for //Set bookmarks in new PDF writer.setOutlines(bookmarks); //Show TreeView in PDF-Reader writer.setViewerPreferences(PdfWriter.PageModeUseOutlines); document.close(); ----- Original Message ---- From: 1T3XT info <[EMAIL PROTECTED]> To: Post all your questions about iText here <[email protected]> Sent: Thursday, August 14, 2008 12:30:45 PM Subject: Re: [iText-questions] Tagged PDF (Re-send) Mike Ferrando wrote: > Friends, > Ok, I guess I will have to start over. (not enough info) > > 1. The most basic problem I am having is that I need to import pages as > PageSize.A4 > > The HelloWorldWriter does not import pages (using PdfContentByte) with the > addTemplate > method settings. > > cb.addTemplate(page, -0.5f, 0f, 0f, -0.5f, PageSize.A4.getWidth(), > PageSize.A4.getHeight()); > > What would be the standard settings for a PageSize.A4 using the addTemplate > method? If you've read the book, you've skipped the algebra part in chapter 10. With the 0.5 you indicate that you want to scale the X and Y dimensions of the page to 50%. With the negative values, you indicate that you want to rotate them. You also define an offset. You probably want 1, 0, 0, 1, 0, 0 as values for the CTM. > 2. Is it possible to tag an imported page or pages? Er... First I thought you wanted to tag the content inside the pages; that would be difficult. Now I see you want to tag complete pages; I assume that's possible. -- This answer is provided by 1T3XT BVBA ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php
