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

Prevent Text Overflow #1525

Open
Sinterus opened this issue Jun 10, 2024 · 0 comments
Open

Prevent Text Overflow #1525

Sinterus opened this issue Jun 10, 2024 · 0 comments

Comments

@Sinterus
Copy link

Is it possible to prevent text overflow?

Description

I want to create a document, which has a big title-esque text field on the bottom. If I increase the y position just a bit further, it will be rendered on a new page despite having about 100pt left for the text to render. Is it possible to suppress overflow or violate the page margins?

My code:

const PDFDocument = require("pdfkit");
const fs = require("fs");

// Create a document
const doc = new PDFDocument({
  size: "A4",
  layout: "landscape",
});
doc.pipe(fs.createWriteStream("foo.pdf"));

//  Actual Content
//  Shapes
doc.rect(220.945, 50, 400, 400).stroke();
doc.rect(841.89 - 30 - 160, 50, 160, 50).stroke();
doc.rect(30, 50, 160, 50).stroke();
doc.rect(841.89 - 30 - 160, 595.28 - 250, 160, 50).stroke();

//  Text
doc.fontSize(20).text("Field 1", 30, 97.64 + 35);
doc.fontSize(20).text("Field 2", 841.89 - (160 + 30), 97.64 + 35);
doc.fontSize(20).text("Field 3", 841.89 - (160 + 30), 400 + 97.64 - 75);
doc.fontSize(25).text("Placeholder for description",40,490,{
  align: "center",
  lineBreak: "false",
});
doc.end();

My environment

  • pdfkit version: 0.15
  • Node version: 22.2
  • Browser version (if applicable): run as script
  • Operating System: Windows 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant