OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

showText isn't creating new lines if string is bigger than pdf width

Open TarunNanduri opened this issue 2 years ago • 4 comments

Describe the bug showText isn't creating new lines if string is bigger than pdf width

To Reproduce Code to reproduce the issue

String s1 = "OpenPDF is open source software with a LGPL and MPL license. It is a fork of iText version 4, more specifically iText svn tag 4.2.0, which was hosted publicly on sourceforge with LGPL and MPL license headers in the source code, and LGPL and MPL license documents in the svn repository. Beginning with version 5.0 of iText, the developers have moved to the AGPL to improve their ability to sell commercial licenses.";
contentByte.setFontAndSize(BaseFont.createFont(fontFileName, BaseFont.IDENTITY_H, false), fontSize);
contentByte.beginText();
contentByte.beginMarkedContentSequence(new PdfStructureElement(element2, PdfName.P));
contentByte.setTextMatrix(document.leftMargin(), 600);
contentByte.showText(s1);
contentByte.endMarkedContentSequence();
contentByte.endText();

Expected behavior I expect string to move to next line if page-end is hit.

Screenshots image

System (please complete the following information):

  • OS: Windows
  • Used Font:

Additional context Add any other context about the problem here.

TarunNanduri avatar May 23 '22 07:05 TarunNanduri

This holds true, even if I use an LayoutProcessor supported font.

TarunNanduri avatar May 23 '22 07:05 TarunNanduri

Hello @TarunNanduri , our group are interested in this issue, and we will try to fix it. ---- SE_SUSTech, group: Lanrand

youyumeimei avatar May 24 '22 13:05 youyumeimei

Great, Looking forward!

TarunNanduri avatar May 26 '22 13:05 TarunNanduri

Dont't use the low-level API directly. See e.g. https://github.com/LibrePDF/OpenPDF/wiki/Paragraphs

vk-github18 avatar Mar 09 '24 20:03 vk-github18