Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing whitespace on text-align right break #440

Closed
AnanasPizza opened this issue Jan 29, 2020 · 2 comments
Closed

Trailing whitespace on text-align right break #440

AnanasPizza opened this issue Jan 29, 2020 · 2 comments

Comments

@AnanasPizza
Copy link

AnanasPizza commented Jan 29, 2020

I am experiencing the following problem:

I have a specific structure in my source html, file attached (pdf.html.txt), that somehow creates a trailing whitespace when using text-align: right and the text is using more than one line.

When I use that html in my implementation like in the attached example.java.txt, it will add a trailing whitespace. Shown in the wrongOutput.pdf.

When I copy the html into your line-wrap-pre-wrap test case html and run the testLineWrapPreWrap() in TextVisualRegressionTest.java it works perfectly fine, also attached. Is there anything I am doing wrong in the preprocessing of the html or the implementation?

I figured out, that some html is not accepted in your test cases, like a normal
tag, while I dont get an error using something like that in my implementation.

Attachments:

example.java.txt

pdf.html.txt

line-wrap-pre-wrap---actual.pdf

wrongOutput.pdf

@AnanasPizza
Copy link
Author

There is a fix for this issue, which I guess could be noted somewhere:
In your test cases you are using a different TextBreaker:

SimpleTextBreaker implements FSTextBreaker

So what I did is copying the class from the test into my project and use it like this:

`byte[] pdf;

    try {
        os = new ByteArrayOutputStream();
        builder.toStream(os);
        builder.useFastMode();
        builder.useSVGDrawer(new BatikSVGDrawer());
        builder.useUnicodeLineBreaker(new SimpleTextBreaker());
        builder.run();
        pdf = os.toByteArray();
        os.close();
        os = null;`

It is important to have the SimpleTextBreaker after the SVGDrawer, otherwise its not rendering imported PDFs.

danfickle added a commit that referenced this issue Feb 20, 2020
This should fix the build which was erroring out in NonVisualRegressionTest when testing the box area of a link.
@AnanasPizza
Copy link
Author

Thank you for the effort and fixing this issue!
Any plans for a new release with the fix any time soon?
The solution with the SimpleTextBreaker won't work for japanese, as there are no whitespaces and any text is rendered in one line. But with your fix I can use the standard linebreaker again, which will solve the japanese problem as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants