Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue while copying a specific pdf #186

Closed
mlecoq opened this issue Sep 9, 2019 · 1 comment · Fixed by #199
Closed

Issue while copying a specific pdf #186

mlecoq opened this issue Sep 9, 2019 · 1 comment · Fixed by #199

Comments

@mlecoq
Copy link
Contributor

mlecoq commented Sep 9, 2019

Hi,

I have an issue with the following pdf :
https://mle-sandbox.s3.amazonaws.com/1526.pdf

When I append it to an existing pdf, it fails due to an undefined value.

The code I use to append it


    const firstPlan = await PDFDocument.load(fs.readFileSync(`${__dirname}/pdf/firstPlan.pdf`), {
        parseSpeed: ParseSpeeds.Fastest
    });

  
        const doc = await PDFDocument.load(`${__dirname}/pdf/unsupportedPlan.pdf`, {
            parseSpeed: ParseSpeeds.Fastest
        });

        const pages = await firstPlan.copyPages(doc, [...doc.getPages().keys()]);

        for (let page of pages) {
            firstPlan.addPage(page);
        }

        fs.writeFileSync(`${__dirname}/results/result.pdf`, await firstPlan.save());

Making some modifications in the lib fix the issue. I will make a pull request soon

@Hopding
Copy link
Owner

Hopding commented Sep 25, 2019

Version 1.1.1 is now published. It contains the fix for this issue. The full release notes are available here.

You can install this new version with npm:

npm install pdf-lib@1.1.1

It's also available on unpkg:

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
2 participants