Skip to content
This repository has been archived by the owner on Apr 15, 2020. It is now read-only.

PDF's over 10 pages are merged back into a single image out of order #45

Open
RoyHP opened this issue Oct 4, 2018 · 3 comments
Open

Comments

@RoyHP
Copy link

RoyHP commented Oct 4, 2018

As stated, when converting a PDF with more than 10 pages to a single image, the pages past 10 are appended to the 2nd and 3rd positions of the PDF, for example:

It seems that due to the file naming convention the images are appended in this order which is incorrect:
image0.png
image1.png
image10.png
image11.png
image2.png
image3.png
image4.png
image5.png
image6.png
image7.png
image8.png
image9.png

This is happening at least on macOS, not sure about Ubuntu. Node v8

@RoyHP
Copy link
Author

RoyHP commented Oct 8, 2018

I submitted PR #47 to resolve this issue.

@rainabba
Copy link

rainabba commented Feb 8, 2019

Been at this for days now with this library, the gm library and using gm directly with child.spawn (the only approach I can get working). Is there something blatantly wrong with this?

This is a snippet of a larger lab experiment to test various libraries. Notice that this example has live-testing.pdf[8]. Each time I run the test, I get a different number and I see no pattern. I imagine that behavior underlies my issue, but I'm not ready to go debugging at this point since I do have things working with child.spawn. I'd be happy to help though for the sake of others. I am using @RoyHP branch for the moment.

        // Test fails with the following. Each time I seem to get a randomly different .png though and out of sequence

        // error: {
        //   cmd: "gm convert \"/usr/src/test/temp/live-testing.pdf[8]\" \"/usr/src/test/temp/live-testing-8.png\"",
        //   code: 1,
        //   killed: false,
        //   signal: null
        // },
        // message: "Failed to convert page to image",
        // stderr: "gm convert: Unable to open file (/usr/src/test/temp/live-testing.pdf) [No such file or directory].\n",
        // stdout: ""

        return new Promise( (resolve, reject) => {
            const PDFImage = require("pdf-image").PDFImage

            let pdfImage = new PDFImage( pdfPath, { //pdfPath is set global to all tests and the path works for other tests
                graphicsMagick: true
            })
            .convertFile()
            .then( imagePath => {
                // Never hit because of the error above
                console.dir( imagePath );
                resolve( imagePath );
            })
            .catch( err => {
                reject( err );
            });
        });

@rainabba
Copy link

rainabba commented Feb 8, 2019

In an effort to help others with the same goal and context: https://gist.github.com/rainabba/d6298b46a01f2558fd06b8f8beea1a39

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants