Hello,

  I resolve my first problem by creating PdfTemplates and add content after.
But I want to add marked content in this template and it doesn't work.

For example :

*        Document document = new Document();

        document.setPageSize(new Rectangle(0, 0, 800, 500));
        FileOutputStream fos = new
FileOutputStream("/home/toinon/Bureau/multipages_essai3.pdf");
        PdfWriter writer = PdfWriter.getInstance(document, fos);

        writer.setTagged();
        writer.setUserProperties(true);

        document.open();
        PdfContentByte cb = writer.getDirectContent();

        PdfTemplate temp1 =
cb.createTemplate(document.getPageSize().getWidth(),
document.getPageSize().getHeight());
        cb.addTemplate(temp1, 0, 0);

        document.newPage();

        PdfTemplate temp2 =
cb.createTemplate(document.getPageSize().getWidth(),
document.getPageSize().getHeight());
        cb.addTemplate(temp2, 0, 0);

        //I add contain in the PdfTemplate temp2

        // I fill the PdfStructureTreeRoot and I create a
PdfStructureElement e


        temp1.beginMarkedContentSequence(e);
        PdfTemplate temp11 = temp1.createTemplate(100, 100);
        Graphics2D g2 = temp11.createGraphics(100, 100);
        g2.setColor(Color.yellow);
        g2.fillRect(0, 0, 100, 100);

        g2.dispose();
        temp1.addTemplate(temp11,100, 100);

        temp1.endMarkedContentSequence();


        document.close();*


If I use the PdfContentByte instead of temp1, it works well for the marked
content but I want to draw on the first page after I have created the second
page.
Does someone have an idea ?




2011/8/9 toinon vigier <[email protected]>

> thanks.
>
>
>
> 2011/8/9 1T3XT BVBA <[email protected]>
>
>> On 9/08/2011 11:27, toinon vigier wrote:
>> > I want to create a PdfDocument with several pages and I want to choose
>> > the current page of my writer to add contents.
>> > For instance, I create my document, add a PdfTemplate to the first
>> > page. I add a new page, add a PdfTemplate to the second page and
>> > after, I want to add a new PdfTemplate in the first page.
>> >
>> > I don't know how I can do this ?
>>
>> The simple answer is: you can't do this. Why not? Because the bytes of
>> the first page are already written to the OutputStream at the moment you
>> are writing the second page. The OutputStream can be a
>> ServletOutputStream and you can't go back to alter those bytes. However,
>> if you've read the book, you know that there's a workaround.
>>
>> > I looked for a solution in the forum and in the book but I didn't find.
>>
>> On page 89, you can read "Normally PdfTemplate objects are kept in
>> memory until you invoke Document.close(), unless you explicitly use
>> writer.releaseTemplate()." In other words: if you use a PdfTemplate, you
>> can write its contents immediately to the OutputStream using
>> releaseTemplate(), or you can postpone this process. By postponing the
>> process, you can add content at a later time as is explained on page
>> 151. If I understand your question correctly, that's what you want to do.
>>
>>
>> ------------------------------------------------------------------------------
>> uberSVN's rich system and user administration capabilities and model
>> configuration take the hassle out of deploying and managing Subversion and
>> the tools developers use with it. Learn more about uberSVN and get a free
>> download at:  http://p.sf.net/sfu/wandisco-dev2dev
>> _______________________________________________
>> iText-questions mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/itext-questions
>>
>> iText(R) is a registered trademark of 1T3XT BVBA.
>> Many questions posted to this list can (and will) be answered with a
>> reference to the iText book: http://www.itextpdf.com/book/
>> Please check the keywords list before you ask for examples:
>> http://itextpdf.com/themes/keywords.php
>>
>
>
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model 
configuration take the hassle out of deploying and managing Subversion and 
the tools developers use with it. Learn more about uberSVN and get a free 
download at:  http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to