kb47 / pdf-poppler

Convert PDF files into images using Poppler with promises. It achieves 10x faster performance compared to other PDF converters.
MIT License
50 stars 20 forks source link

Get access to converted file name #14

Open abulhuman opened 3 years ago

abulhuman commented 3 years ago

I was trying this out and it worked fine but when it converts a file it adds an additional -1 or -01 right before the file format. Like this, source filename: 1622204835226-ASSEMBLY LANGUAGE.pdf destination filename: 1622204835226-ASSEMBLY LANGUAGE-01.png or 1622204835226-ASSEMBLY LANGUAGE-001.png

This adds an unnecessary complication since there is no way to determine the destination filename from the source filename. Is there any way that enables me to get the destination filename or even modify it?

Soneliem commented 2 years ago

A little late but for future reference:

  1. Navigate to node_modules\pdf-poppler\lib\convert.js
  2. Replace the following lines:
    if (opts.page) {
    args.push(['-f']);
    args.push([parseInt(opts.page)]);
    args.push(['-l']);
    args.push([parseInt(opts.page)]);
    }
  3. With this: args.push(['-singlefile']);

Keep in mind this forces pdftocairo to only convert the first page and ignores all other pages.