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.

Merging 2 PDFs - Invalid key BSISpaces

See original GitHub issue

Hi,

I have 2 pdfs and I want to merge them to have one document

for (let page of result.getPages()) {
     doc.addPage(page);
} 

In the second one I have the following line

<</BSISpaces [36 0 R 37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R 50 0 R 141 0 R 142 0 R 143 0 R 174 0 R 175 0 R 176 0 R 284 0 R 285 0 R 286 0 R 287 0 R 288 0 R 289 0 R 290 0 R 291 0 R 295 0 R 296 0 R 297 0 R 298 0 R 299 0 R 300 0 R 301 0 R 302 0 R 391 0 R 392 0 R 393 0 R 424 0 R 425 0 R 426 0 R 431 0 R 432 0 R 433 0 R 434 0 R 435 0 R 436 0 R 437 0 R 438 0 R]/Contents 489 0 R/MediaBox [0 0 3370 2384]/Parent 3 0 R/Resources <</ExtGState 8 0 R/Font 21 0 R/Pattern 56 0 R/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/XObject 68 0 R>>/Type /Page>>

In src/core/pdf-objects/PDFDictionary.ts, the following check throws an error:

 if (
      validateKeys &&
      this.validKeys &&
      !this.validKeys.includes(keyName.key)
    ) {
      error(`Invalid key: "${keyName.key}"`);
    }

BSISpaces is not includes in validKeys

How are built valid keys ? Does it depend on first document ? I have noticed that if I reverse the merge (document with /BSISpaces is used as base to merge other documents), no error is thrown but the produced document is not readable.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mlecoqcommented, May 29, 2019

The second issue is mine 😃 - I will make a PR to remove this check

0reactions
mlecoqcommented, May 29, 2019

Like in the case when the document with BSISpaces was used as the base to add other documents. There is maybe 2 issues in this document.

Read more comments on GitHub >

github_iconTop Results From Across the Web

My PDF documents won't merge - Apple Community
(1) Open the first pdf file, (2) Open the thumbnails draw (3) Drag in the second pdf file and (4) Save the new...
Read more >
Combine or split existing PDF documents - Adobe Support
Here are two Pro Tips to help you combine multiple documents into a single PDF faster. Combine files within Acrobat. Open Acrobat. Choose...
Read more >
Merge PDFs | Help Center
Launch the PDF Expert app. Select File > Merge Files. Select the files you'd like to merge (hold Shift to select multiple files)....
Read more >
iText fails to propery merge signatures in PDF files
I am using the PdfCopyFields class to do the merging yet, the signatures of existing PDF files are not merged properly. It seems...
Read more >
How to Combine PDF Files On A Mac (MacOS Catalina)
Unlike Windows, macOS comes with high-powered PDF tools built in—provided by the macOS Finder ... 66K views 2 years ago # combine #mac...
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