Please tell me how to leave the leading space in the paragraph of iText7.

Asked 2 years ago, Updated 2 years ago, 64 views

Change the chunk of iText5 to Paragraf of iText7.
Parograph removes the leading space.The current form is spaced out, so if the space is deleted, the layout will be corrupted.Is there any way to leave space?

I have confirmed in another question that the space will be deleted in the Parograph specification.

java pdf

2022-09-30 15:40

1 Answers

I solved myself by referring to the following.

Is there any way to keep spaces before text in iText7?
https://stackoverflow.com/questions/46970739/is-there-any-way-to-keep-whitespaces-before-text-in-itext7

By adding NULL characters to the front of the paragraph, we were able to prevent the left trim.
For NULL, "\u0000" is garbled, so I chose "\u00a0".

Before: Parograph p = new Parograph(line).setFont(font);
After modification: Parograph p=newParagram().add("\u00a0").add(line).setFont(font);

However, depending on the font you use, the file will be corrupted.

OK: PdfFont=PdfFontFontFactory.createFont("migu-1m-regular.ttf", "Identity-H";
NG: PdfFont=PdfFontFactory.createFont("HeiseiKakuGo-W5", "UniJIS-UCS2-H";


2022-09-30 15:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.