ralfstuckert / pdfbox-layout

MIT License
155 stars 74 forks source link

Using Indents causes warning messages in PDPageContentStream #68

Open Lichthupe opened 5 years ago

Lichthupe commented 5 years ago

Hi Ralf,

we are using you API in our current project and it helps us a lot. So first of all a big thank you for the time and effort you spend on this regularly.

We have one question remaining: When it comes to use lists, we are using Indents, as shown in

https://github.com/ralfstuckert/pdfbox-layout/wiki/IndentationAndLists

, but we are facing a lot of warning messages being logged by the underlying PDPageContentStream class.

Nov 15, 2018 3:40:18 PM org.apache.pdfbox.pdmodel.PDPageContentStream transform WARNUNG: Modifying the current transformation matrix is not allowed within text objects.

Is this expected behaviour or are we doing something wrong?

These warnings also occur when using your example Indentation.java directly, so we are wondering if you were facing this problem already before and know the trick how to solve this?

Any idea?

Codefragment (from your Indentation.java):

Document document = new Document(40, 60, 40, 60);
Paragraph paragraph = new Paragraph();
paragraph
    .addMarkup(
        "This is an example for the new indent feature. Let's do some empty space indentation:\n",
        11, BaseFont.Times);
paragraph.add(new Indent(50, SpaceUnit.pt));
paragraph.addMarkup("Here we go indented.\n", 11, BaseFont.Times);
    document.add(paragraph);

Many thanks,

Jan (&& several other team members)

arnthom commented 5 years ago

Hi Lichthupe ((O O)) I have used Indentation without any problem, but I have not tried to create a list. Can you be more specific? Can tell at what step this warning occurs? Does it happen every time you try to indent or just when using numbered lists or ...?

This IllegalStateException is thrown, when transform is called and PDContentStream is in text mode. So it may depend on the time and state of contentstream and document, if you get this warning.

Lichthupe commented 5 years ago

Hi Arnthom. Many thanks for your reply! Well, this warning (or exception message) occurs even when using the Indentation.java example provided by Ralf Stuckert. So the example I provided in my first comment above is already causing this message. In our case, what we are doing, is creating a container like shown above and add this container to a frame to have a background for this element. But as I said, already using the example above (the original one) causes this messages.

Fragment from my code:

/**

which is called for each list item I want to have on the page. like addListElement("some text", width, 20.0f, 0, PADDING_RIGHT);

What I do not understand is why this message already occurs when using Ralf's original example.

Anyway, many thanks already for having a look here.

Jan

arnthom commented 5 years ago

Sorry, there is no advice I can give you. Meanwhile I tested the indentation.java file and it runs without any problem or warning on my system. Maybe Ralf looks into this issue later ...

Lichthupe commented 5 years ago

Hi Arnthom,

don't worry and many thanks for your effort, highly appreciated. Maybe I will have some time during Christmas Time and I will dive deeper into this topic.

Have a good time!

Jan

david-forster10 commented 5 years ago

Was anything found with this issue? I seem to be having the issue when using bullet lists, same error. I validated it was the bullet list by commenting out the -+, it saved with no warnings, as soon as they're back in warnings again.