Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

not able to write text at bottom of file

See original GitHub issue

Hi, I am using pdfkit successfully and able to write text to multiple coordinates as shown in attached pdf.

I am having issues writing to the bottom/right side/edges of the pdf.

when writing to the right side of the page - it has a tendency to wrap and go to next line even if I see plenty of space in right side. Similarly, when writing to the bottom, it goes to next page even if sufficient space is available at the bottom.

As you see in the pdf attached, the image has plenty of space at the bottom where I want to write. But after certain coordinates (712 on Y-axis) text moves to next page.

`var doc = new pdf({ size: ‘letter’, layout : ‘portrait’,

	margin : {
		top : 0.095 * 72,
		left: 0.2 * 72,
		right: 0.2 * 72,
		bottom: 0

doc.pipe(fs.createWriteStream(__dirname + "/pdf/" + name));
// doc.pipe (fs.createWriteStream('foo.pdf'));
// doc.pipe(fs.createWriteStream(__dirname + "/pdf/" + name));

//add background image 
doc.image(__dirname + "/cms1500.png", {
	x: 0.2 * 72,
	y: 0.095 * 72,
	width: (612 - 2 *0.2 * 72),
	height: (792 - 2  *0.095 * 72)


for (var i=0; i< 713; i++){ doc.text (i + " => do you see me ", 380, i); }

doc.on('end', function() {
	console.log("pdf created");
	return cb(true);


58bdcd68b84b6c14900c1471.pdf `

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

prescottpruecommented, Apr 14, 2017

@quicksoftpro Thanks! That got me on the right track, but I had to pass the settings to the constructor when creating the doc like so:

const pdfDoc = new PDFDocument({
  margins: {
    bottom: 0,
quick-sortcommented, Sep 4, 2018

doc.text(text, x, y, {height:}) works for me. However I cannot change the color of the font

Read more comments on GitHub >

github_iconTop Results From Across the Web

Text wont go all the way to the bottom of the page
I have a document where the text on some pages goes right up to the footer at the bottom, but others sometimes leave...
Read more >
Word - How to stick text to the bottom of page - Stack Overflow
I want to stick some text of the bottom of the page, like on the screen, just before footer always. When there is...
Read more >
310. Why does my text wrap to the next line before reaching ...
Ensure that Indentation, both before and after text, are set to zero and that no special formatting has been set. Click on OK....
Read more >
vertical alignment - Putting text at the bottom of the page - TeX
I tried the \vfill option, but this does not seem to do the job. Any ideas? \documentclass{report} \begin{document} \vfill © Copyright by KU ......
Read more >
How to change alignment in Excel, justify, distribute and fill cells
Align to upper-left, Align to bottom-right, Center in the middle of a ... In Microsoft Excel, the Tab key does not indent text...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found