Giter Site home page Giter Site logo

support for bold font style about gopdf HOT 6 OPEN

signintech avatar signintech commented on July 18, 2024 1
support for bold font style

from gopdf.

Comments (6)

oneplus1000 avatar oneplus1000 commented on July 18, 2024

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.

from gopdf.

Tom-Kail avatar Tom-Kail commented on July 18, 2024

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.

from gopdf.

oneplus1000 avatar oneplus1000 commented on July 18, 2024

Can you send me a sample pdf file that created from itextpdf.

from gopdf.

Tom-Kail avatar Tom-Kail commented on July 18, 2024

https://zcmlccontract.zcmlc.com/TransferPDF/2020/20200206/hgypdf/pt_xwyswsqtxwuwyvxutrt.pdf
Don't click it directly, please copy it to address bar first.

from gopdf.

oneplus1000 avatar oneplus1000 commented on July 18, 2024

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);

from gopdf.

Tom-Kail avatar Tom-Kail commented on July 18, 2024

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());

from gopdf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.