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

Fix indent with continued #300

Merged
merged 1 commit into from
Sep 11, 2014
Merged

Conversation

ef4
Copy link
Contributor

@ef4 ef4 commented Sep 11, 2014

continued: true and indent don't work correctly together. This change fixes the problem by properly shifting the continued text over by the indent amount.

Here is a sample program that demonstrates the problem and fix:

var fs = require('fs');
var PDFDocument = require('pdfkit');
var doc = new PDFDocument();
var stream = doc.pipe(fs.createWriteStream('./out.pdf'));

var lorem = "Bacon ipsum dolor sit amet shankle spare ribs boudin kevin beef ribs cow short loin t-bone filet mignon swine. Pork chop strip steak pork loin tri-tip leberkas short ribs beef ribs rump sausage pork salami. Pastrami rump short ribs biltong tri-tip salami sirloin short loin cow brisket tail chicken shank meatloaf tenderloin. Tenderloin andouille jerky shoulder landjaeger tri-tip flank swine boudin shank. Salami short ribs pig sausage tail short loin jerky.";

doc.fillColor('#ff0000');
doc.text(lorem.slice(0, 10), {indent: 16, continued: true});
doc.fillColor('#000000');
doc.text(lorem.slice(10));
doc.end();

stream.on('finish', function() {
  process.exit(0);
});

@ef4
Copy link
Contributor Author

ef4 commented Sep 11, 2014

Oops, submitted a little too soon. This isn't ready to merge, it doesn't fully solve the problem. I will push another update when I figure it out.

@ef4 ef4 force-pushed the continued-indent branch 2 times, most recently from f446400 to 6f77beb Compare September 11, 2014 17:24
@ef4
Copy link
Contributor Author

ef4 commented Sep 11, 2014

Ok, now it works, ready for your consideration!

devongovett added a commit that referenced this pull request Sep 11, 2014
@devongovett devongovett merged commit 1d4c208 into foliojs:master Sep 11, 2014
@devongovett
Copy link
Member

Thanks!

@ef4 ef4 deleted the continued-indent branch September 12, 2014 19:10
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

Successfully merging this pull request may close these issues.

2 participants