Hi,

i have the following piece of code:

public void myProblem(final OutputStream os, final JFreeChart
jFreeChart) {
    FontMapper mapper = new DefaultFontMapper();
    final Document document = new Document(PageSize.A4, 57, 57, 36, 36);

    try {
        final PdfWriter writer = PdfWriter.getInstance(document, os);
        document.open();

        document.add(new Paragraph("Text before 1"));
        document.add(new Paragraph("Text before 2"));

        PdfContentByte cb = writer.getDirectContent();
        PdfTemplate tp = cb.createTemplate(400, 300);
        Graphics2D g2 = tp.createGraphics(400, 300, mapper);
        Rectangle2D r2D = new Rectangle2D.Double(0, 0, 400, 300);
        jFreeChart.draw(g2, r2D);
        g2.dispose();
        document.add(Image.getInstance(tp));

        document.add(new Paragraph("Text after 1"));
        document.add(new Paragraph("Text after 2"));

    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        if (document != null) {
            document.close();
        }
    }
    document.close();
}


So far, so good. Everything works like I want it. 
In the generated PDF is "Text before 1", "Text before 2", the Image, and
then "Text after" 1 and 2.

BUT... when I replace "Text before 1" and "Text before 2" with content
that needs so much space, that the following Image has not enough space
on the Page the generated PDF looks so:

- The First Text block (former Text before 1)
- The Second Text block (former Text before 2)
- then till Page 1 is full the beginning of the "after" Text block
(former Text after 1)
- the first thing on the new Page is then the Image
- then the rest of the first "after" Text block
- the second "after" Text block (former Text after 2)


What I need is, that I can force iText that no "after" Text starts
before the Image was printed.
If the image has not enough space on the page than the space should be
empty and the Image should start on a new Page and then should start the
"after" content.
Is there a way that I can force this behaviour?
Now iText uses the empty space to start with the "after" content.

Thanks for your help and sorry for my bad english ;-)

Marco






 
Wichtiger Hinweis an alle Mitglieder der KVB:
"Leistungsgerechte Vergütung für Ihre nachgewiesene Qualität" - Profitieren 
auch Sie davon! Nähere Informationen finden Sie unter www.kvb.de - Rubrik 
Qualitätsprogramme/Ausgezeichnete Patientenversorgung oder unter 
www.ausgezeichnete-patientenversorgung.de.

Disclaimer:
Bitte beachten Sie: die obige Mitteilung ist ausschließlich für die in den
Adresszeilen benannten Personen bestimmt und enthält möglicherweise 
vertrauliche Informationen. Sollten Sie diese Nachricht fälschlicherweise 
erhalten haben, informieren Sie bitte den Absender. Bitte löschen Sie 
die Nachricht und sehen Sie davon ab, die Inhalte zu nutzen, 
aufzubewahren, weiterzuleiten oder zu reproduzieren.


Viren:
Unser Unternehmen verfügt über eine funktionierende Anti-Viren- 
Software und prüft jede abgesendete Email und deren Anhänge auf 
Viren. Trotzdem können wir nicht garantieren, dass die Email virenfrei 
ist und übernehmen keine Haftung für Schäden, die aus Viren entstehen.

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
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