Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf.drawText is not supporting with custom font #1506

Open
2 tasks done
ldilshan opened this issue Aug 12, 2023 · 1 comment
Open
2 tasks done

pdf.drawText is not supporting with custom font #1506

ldilshan opened this issue Aug 12, 2023 · 1 comment

Comments

@ldilshan
Copy link

ldilshan commented Aug 12, 2023

What were you trying to do?

	           const pdfDoc = await PDFDocument.load(pdfBase64, { ignoreEncryption: false });
	             
                    pdfDoc.registerFontkit(fontkit); // Register fontkit

			const fontPath = path.join(process.cwd(), 'src/fonts/arial.ttf');
			const fontBytes = await fs.readFile(fontPath);
			const customFont = await pdfDoc.embedFont(fontBytes);
			options.font = customFont
			options.color = rgb(0, 0, 0),
			pdfPage.drawText("Test", {x:300, y: 200, size: 10, font: customFont});

How did you attempt to do it?

Inside node backend

What actually happened?

Text is not displaying in the document with given position when we try to add a custom font. Standard fonts are working and need to use custom font here.

What did you expect to happen?

Needs to draw text with Custom fonts

How can we reproduce the issue?

try the above code

Version

"^1.17.1",

What environment are you running pdf-lib in?

Node

Checklist

  • My report includes a Short, Self Contained, Correct (Compilable) Example.
  • I have attached all PDFs, images, and other files needed to run my SSCCE.

Additional Notes

No response

@SanjaySRocks
Copy link

facing same issue using this custom font (https://fonts.google.com/specimen/Borel?query=borel&preview.text=Sanjay%20Singh&preview.text_type=custom)

pdf.drawText do not print text properly. screenshot is attached.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants