question-mark
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.

createImage does not work with PDFs

See original GitHub issue

Hey there, hoping you could help me 😃

var myImage = pdf.createImage(fs.readFileSync(__dirname + '/mypdf.pdf')); doc.image(myImage);

Gives

Cannot read property ‘content’ of undefined",“stack”:"TypeError: Cannot read property ‘content’ of undefined\n at new module.exports (/node_modules/pdfjs/dist/pdfjs.js:2937:34

var contents = img.info.page.get('Contents').object

Gives

undefined

When using a jpg image everything works perfectly 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rkusacommented, May 10, 2017

Good point. I’ve published 1.0.0-alpha.6. 2.0.0-alpha.1 probably throws because it requires a Node version >= 7

1reaction
bergurcommented, Feb 8, 2017

Yeah same code expect I had express with

res.set('Content-Disposition','attachment');
// Same code
res.send(doc.render().toString())

Got it working with:

res.end(doc.render().toString(),'binary');`

Thank you again so much for all your help! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

python wand gives TypeError when trying to create Image ...
I can't seem to find any document or proper example that create Image from pdf, but some examples on the Internet did it...
Read more >
How to convert a PDF into an image with Adobe Acrobat
Convert a PDF file into an image to make sharing or storing easy. Adobe Acrobat makes converting PDFs into popular image formats (like...
Read more >
How to Create Image Field in pdf form using Adobe Acrobat Pro
In this Video, I will show you, How to Create Image Field in pdf form using Adobe Acrobat Pro. ... Your browser can't...
Read more >
How to Create a non-searchable (image only) PDF file?
To create a PDF Image Only document: •Open a document from a Windows application (Word, Excel, Edge, etc.) •Print the document and select...
Read more >
Create Image from PDF: Reactive Web App - OutSystems
Its only work with PDF URL which are in same domain. ... I don't think javascript is able to generate a thumbnail from...
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found