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?

2. Is it possible to tag an imported page or pages?

In the example MarkedContent, each paragraph is mapped to an PdfName.P. Will I 
have to map each imported
page to a PdfName.Page? 

I had the following in mind:
  tag:Document
     tag:Part
       tag:Sect
          import page(0) //title page
      tag:Part
        tag:Sect
          import page(1) //introduction page 1
          import page(2) //introduction page 2
      tag:Part
        tag:Sect
           import page(3) //chapter 1
        tag:Sect 
           import page(4) //chapter 2

....etc.

These tags are found in the PdfName class.
  PdfName.Document
  PdfName.Part
  PdfName.Sect


3. I am using the tag names that Adobe recommends. (image p. 35 & Appendix F)

http://www.adobe.com/enterprise/accessibility/pdfs/acro6_pg_ue.pdf


Finally, I have combined the relevant code sample below from HelloWorldWriter 
and MarkedContent.


Thanks,
-Mike


Document document = new Document(PageSize.A4);
PdfReader reader = new PdfReader("HelloWorldToImport.pdf");
// step 2
PdfWriter writer = PdfWriter.getInstance(document,
    new FileOutputStream("HelloWorldFolded.pdf"));
// step 3
document.open();
PdfStructureTreeRoot root = writer.getStructureTreeRoot();
// we call the root "Everything"
PdfStructureElement eTop = new PdfStructureElement(root,
      new PdfName("Everything"));
// "Everything" is not a standard structure and must be mapped to a
// standard one like "Sect"
root.mapRole(new PdfName("Everything"), new PdfName("Sect"));
// "P" is a standard structure, no need to map
PdfStructureElement e1 = new PdfStructureElement(eTop, PdfName.P);
PdfStructureElement e2 = new PdfStructureElement(eTop, PdfName.P);
PdfStructureElement e3 = new PdfStructureElement(eTop, PdfName.P);
// step 4
PdfContentByte cb = writer.getDirectContent();
PdfImportedPage page;
page = writer.getImportedPage(reader, 1);
cb.beginMarkedContentSequence(e1);
cb.addTemplate(page, -0.5f, 0f, 0f, -0.5f, PageSize.A4.getWidth(),
         PageSize.A4.getHeight());
cb.endMarkedContentSequence();


      

-------------------------------------------------------------------------
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

Reply via email to