Open Tom-Kail opened 7 years ago
As far as I know, separate font files are needed for difference weight. However, file size will not be that large since only the glyphs that actually use will be embedded in the file.
Thank you to your quick response. Yes, it's not very large. We need both bold and normal font style to generate contract. For example, the PDF file generated by gopdf which embed two font files is 204 KB, but itextpdf (java) can shrink PDF file to 102 KB by only use one font and get bold font style by code. We love golang and want to use it to replace all java code. We even hope golang can have a better performance in file size(Please forgive my greed). We have millions of users and the number is growing, so we want contract files can be as small as possible.
Can you send me a sample pdf file that created from itextpdf.
https://zcmlccontract.zcmlc.com/TransferPDF/2020/20200206/hgypdf/pt_xwyswsqtxwuwyvxutrt.pdf Don't click it directly, please copy it to address bar first.
Did you use the code like this to bold the font ( in itextpdf )?
Chunk chunk = new Chunk("ABCDE", arial12);
chunk.setTextRenderMode(PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, 0.5f, null);
I only use code to create bold font:
public static final Font getChineseSectionFont() {
Font FontChinese = null;
try {
BaseFont bfChinese = BaseFont.createFont("STSong-Light",
"UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
FontChinese = new Font(bfChinese, 12, Font.BOLD);
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
return FontChinese;
}
then use it like:
content = new Paragraph("一、借款", PDFFront.getChineseSectionFont());
@oneplus1000 can you close this issue if it has been resolved?
If I embed both font of bold and normal, the size of PDF will larger than only embed one font. I want to embed one font only to shrink file size and get bold and normal font style by code. Currently the package only support "" and "U" font style, could you support bold font style or tell me how can I do to make a pr. ps: the project is awesome! you've done a great work!