Multi Page pdf conversion
See original GitHub issueFirst of all, this project is amazing.
I have a question is about sharp
api.
I am converting multi-pages pdf files to jpeg (each page is a separate file). What would be most efficient way to do this? This is a sample implementation that I am using now.
const input = getBufferSomeHow()
const metatada = await sharp(input).metadata()
const conversions = []
for (let i = 0; i < metadata.pages; i++) {
conversions.push(
sharp(input, {
density: myDensity,
pages: 1,
page: i,
}.jpeg().toBuffer())
}
const buffers = await Promise.all(conversions)
When I say most efficient I mean that “given an input buffer that is a multipage pdf, what is the best way to use that buffer to convert its pages in single jpeg files? Is the approach of instantiating sharp
every time valid?”. Would sharp.clone
help in any way?
Thank you 😄 .
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (1 by maintainers)
Top Results From Across the Web
Multiple pages per sheet online & free
PDF Layout: You can easily set multiple pages per sheet (e.g. for printing) in your PDF with this online tool - just in...
Read more >PDF N-up tool - multiple pages per sheet - PDFResizer.com
PDF multiple pages per sheet (N-up) converter. Welcome to a free online tool for rearranging PDF document layout to print multiple pages per...
Read more >Merge PDF Pages Into One Page - AvePDF
Convert multiple PDF pages into one page. Drop in your multipage PDF and merge all PDF pages into 1 single page. 100% free...
Read more >PDF N-up tool - multiple pages per sheet - DeftPDF
Plan PDF Layouts for printing. You can easily set multiple pages per sheet (e.g. for printing) in your PDF with this Free online...
Read more >How to Make a Multi Page PDF with Simple Clicks - EaseUS
To make multi-page PDF files, Soda PDF Editor is an excellent option. It has a fantastic online "Merge" tool that lets you instantly...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Both your approaches look good to me given the complete PDF/GIF is already in memory, or at least on a fast local filesystem. libvips’ default caching should help too - use
sharp.cache()
to check.@brecke Last thing, you might find this useful