ralfstuckert / pdfbox-layout

MIT License
156 stars 74 forks source link

Stop ColumnLayout #9

Closed wutzebaer closed 8 years ago

wutzebaer commented 8 years ago

Hi is there a Way to stop the ColumnLayout and continue with a VerticalLayout?

doc.add(new VerticalLayout()); didn't work

ralfstuckert commented 8 years ago

But it should ;-) Confirmed this is a bug, will be fixed soon.

Here is my example to reproduce:

    String text1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
        + "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
        + "aliquyam erat, _sed diam_ voluptua. At vero eos et *accusam et justo* "
        + "duo dolores et ea rebum.\n\n Stet clita kasd gubergren, no sea takimata "
        + "sanctus est *Lorem ipsum _dolor* sit_ amet. Lorem ipsum dolor sit amet, "
        + "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
        + "ut labore et dolore magna aliquyam erat, *sed diam voluptua.\n\n"
        + " At vero eos et accusam* et justo duo dolores et ea rebum. Stet clita kasd "
        + "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n";

    Document document = new Document(40, 50, 40, 60);

    Paragraph title = new Paragraph();
    title.addMarkup("*This Text is organized in Colums*", 20, BaseFont.Times);
    document.add(title, VerticalLayoutHint.CENTER);
    document.add(new VerticalSpacer(5));

    Paragraph paragraph1 = new Paragraph();
    paragraph1.addMarkup(text1, 11, BaseFont.Times);

    // use column layout from now on
    document.add(new ColumnLayout(2, 10));
    document.add(paragraph1);
    document.add(ColumnLayout.NEWCOLUMN);
    document.add(paragraph1);

    // vertical again
    document.add(new VerticalLayout());
    document.add(paragraph1);
    document.add(paragraph1);

    // and column layout again
    document.add(new ColumnLayout(2, 10));
    document.add(paragraph1);
    document.add(ColumnLayout.NEWCOLUMN);
    document.add(paragraph1);

    // vertical again
    document.add(new VerticalLayout());
    document.add(paragraph1);
    document.add(paragraph1);

    final OutputStream outputStream = new FileOutputStream(
        "columns.pdf");
    document.save(outputStream);
ralfstuckert commented 8 years ago

Fixed in 0.8.0