LibrePDF / OpenPDF

OpenPDF is a free Java library for creating and editing PDF files, with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository.
Other
3.5k stars 581 forks source link

Unable to insert text in Identity-H encoding using a subset font file #1191

Open SirishaGorasa opened 2 months ago

SirishaGorasa commented 2 months ago

Bug description

I am trying to insert one word of text into the PDF page. I have made use of BaseFont class, provided Identity-H as the encoding and the subset font file corresponding to this one word of text. I am not able to see any text that had got created on the page.

Code snippet

  String fontFile="CLQCTE+TradeGothic.otf";
 PdfContentByte cb = writer.getDirectContent();
        BaseFont bf1 = BaseFont.createFont(fontFile, BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
        cb.beginText();
        cb.setTextMatrix(70,804);
        cb.setFontAndSize(bf1,12);
        cb.beginMarkedContentSequence(e1);
        cb.showText("ent");
        cb.endMarkedContentSequence();
        cb.endText();

Expected behavior

I wanted to see the PDF with the text "ent" in it.

System

Even after so many trails, I am not able to see the text on the page. When I checked for the glyphs the font file supports, came to know that these three glyphs "e", "n" and "t" are supported by this subset font file.

Hence, I have tried with a different font, and it worked well. May I know the reason/resolution for the same?

mkl-public commented 2 months ago

Hence, I have tried with a different font, and it worked well. May I know the reason/resolution for the same?

Apparently, therefore, the issue is related to the font file. Can you share it?

SirishaGorasa commented 2 months ago

The file type is .otf. I am unable to share the file here.