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 not printable #69

Closed
ghost opened this issue Apr 3, 2012 · 22 comments
Closed

PDF not printable #69

ghost opened this issue Apr 3, 2012 · 22 comments

Comments

@ghost
Copy link

ghost commented Apr 3, 2012

First of all: Great Library. Thank you for that.
It was really easy to generate some decent PDFs.
Unfortunately some strange errors are happening when i try to print them.
One Printer in my office freezes as soon as i try to print a generated pdf,
another one acts like he is printing but does not produce anything. (Not even put a paper through)

Both Printers are working fine when i print anything else.
The problem occurs when i open an pdf I generated with doc.write()
same as when i use doc.output() to write the code straight to to an http response.

I tried to compare the data of another pdf which is printing with no problems, but couldn't find anything suspicious.
Anyone with same experiences or even a solution?

Thanks!

@devongovett
Copy link
Member

This sounds like an issue with the PDF viewer and your printer setup. If the PDF displays fine on screen but doesn't print properly, I think the PDF is probably OK but whatever software you're using to print the PDF probably has a bug.

@ghost
Copy link
Author

ghost commented Apr 3, 2012

well, i used OSX's Preview and Chrome. Both with the same result.
And it's even the same with the example PDF. I even tried different Macs.

@devongovett
Copy link
Member

So it happens with all PDFs generated by PDFKit? And other PDFs print OK? Did you try a different printer? Just trying to get to the bottom of this.

@devongovett devongovett reopened this Apr 3, 2012
@ghost
Copy link
Author

ghost commented Apr 3, 2012

yes. it happend with different PDFs that i created with PDFKit as well as with the example PDF i got from http://pdfkit.org/example.pdf.

I tried an HP Color Laserjet 5550dn which freezes when i try, so i have to turn it off and on again.
And i tried a HP Digital Sender 9250c, which makes some sounds that sounds like printing, but in fact does nothing.

Tested on OS X 10.7.3 and 10.6.7

Edit:
I got an 49.4c02 Error Message on the Printer when it freezes.
According to HP that means the printer received a corrupted print job.

@ghost
Copy link
Author

ghost commented Apr 3, 2012

Update: Just found out that the error only occurs when I change the font.
It's the same with all fonts, even the build-in. As soon as i use the doc.font() method i run into this problem.

@devongovett
Copy link
Member

Interesting. Thanks for looking into this more.

@ghost
Copy link
Author

ghost commented Apr 3, 2012

Sorry, wrong information: There are fonts that are working. Just tested a lot of fonts and found one that's okay. Can't say what the difference is, yet.

@ghost
Copy link
Author

ghost commented Apr 3, 2012

and: you're welcome. as i said, this is an awesome library. thanks for sharing. i'm glad if i can help.

@xk
Copy link

xk commented Apr 3, 2012

I'm having a similar problem.

When I send the .pdf to a PostScript printer it fails and the error that gets printed is

ERROR: invalidfont
OFFENDING COMMAND: xshow
STACK: [ lots of numbers here ]

OTOH, I can send it to a non-postcript printer and it prints fine, and I can open it in preview at it looks all right.

The difference is who renders the .pdf, when done by the (postscript) printer it fails, when done by the Mac it works.

HTH.

@devongovett
Copy link
Member

Hmm, not sure. Must be something specific to the printer because I can't reproduce it. Can both of you send examples of PDFs generated by PDFKit that produce this error? If you can send source code as well that would be best. Thanks!

@ghost
Copy link
Author

ghost commented Apr 16, 2012

Sorry, i overread your last comment. You can find the files here: http://dl.dropbox.com/u/480539/Issue69.zip
My apologies for the bad code practice. It is only meant as a test so i did not put a lot of effort in.

@HughePaul
Copy link
Contributor

I'm getting this problem when I use an embedded TTF. If I register the font but then only use Times-Roman it prints fine.
The document displays perfectly in mac preview.
The printer is RICOH Aficio C3000.
I'll get a small demo pdf together that refuses to print and attach that here

@HughePaul
Copy link
Contributor

Here is the test script that is producing a problem:
https://www.dropbox.com/s/ukab93wabzh3bpd/test.zip

var PDF = require('pdfkit');

var doc = new PDF();
doc.registerFont('OpenSans-Regular', 'OpenSans-Light.ttf');
doc.font('OpenSans-Regular');
doc.text('Hello World');
doc.write('embeded.pdf');

var doc = new PDF();
doc.registerFont('OpenSans-Regular', 'OpenSans-Light.ttf');
doc.font('Times-Roman');
doc.text('Hello World');
doc.write('standard.pdf');

The standard.pdf prints fine, the embeded.pdf crashes the printer and it needs to be unplugged from the mains and plugged back in to print anything else.

@HughePaul
Copy link
Contributor

Finally managed to get an error out of the printer, but with OpenSans-Regular.ttf instead of OpenSans-Light.ttf:

ERROR: invalidfont
OFFENDING COMMAND: xshow

STACK:
[8.859 6.732 3.036 3.036 7.248 3.12 11.112 7.248 4.896 3.036 0.0 ]
(!"##$%&$'()

@HughePaul
Copy link
Contributor

The official printer driver is a PS driver.
If I choose Generic PCL is prints (but in black and white) and if I choose Generic PS it fails.

@HughePaul
Copy link
Contributor

I'ver been trying out lots of fonts from fontsquirrel and other places and a lot of them crash the printer. Some of them work with "Hello world" but then crash when I use them in a document, so I assume one of the font glyphs contains something that the printers don't like. If I create a document with the problem fonts with open office and the print from there it prints fine on the same printer.
I might create pdfs with one of each letter and see what one crashes the printer :)

@HughePaul
Copy link
Contributor

I've compiled and installed fontforge from http://fontforge.org and:

  • opened the TTF font
  • generate font as SVG
  • opened the SVG font
  • generate font as TTF
    And this seemed to iron out the errors in the font and the generated pdf now prints on all printers i've tested :D

@talktough
Copy link

Hi HughePaul

I did what you suggested with fontforge and it worked as you found so that is good and thanks for the suggestion.

Unfortunately it had the side effect that it seems to mess up the doc.widthOfString function so now I have problems with underlining and justification.

I was wondering - did you run in to the same problem and if so how did you get around it ?

Thanks

Chris

@ToniTornado
Copy link

I had all the problems described here, too. Some fonts worked, some didn't and killed the printer. I found that converting a non-working font to .otf and then back to .ttf with http://www.freefontconverter.com turned this font into a working font with a bit larger file size. Simply "converting" it .ttf in one step resulted in bigger file size as well but didn't remove the error.

@devongovett
Copy link
Member

There hasn't been any activity on this for a while, so I'm closing it. If anyone still has issues with this, let me know!

@optikfluffel
Copy link

I had that issue a while now and didn't really knew where it came from (especially because it just causes some laser printers from HP to fail here), but the tip from @HughePaul helped for now ^^

@devongovett
Copy link
Member

The font engine has changed significantly in v0.8.0. Please try again with that version and report back how it goes.

dgdavid added a commit to dgdavid/resume-like-a-test that referenced this issue Dec 4, 2016
Using a http://www.freefontconverter.com/ since there was a problem
rendering on OSX plattform.

More info: foliojs/pdfkit#69 (comment)
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

6 participants