boazsegev / combine_pdf

A Pure ruby library to merge PDF files, number pages and maybe more...
MIT License
734 stars 156 forks source link

v0.2.23 Not combining PDF generated from Scribus #71

Closed Kagetsuki closed 8 years ago

Kagetsuki commented 8 years ago

v0.2.21 was combining Scribus PDFs without issue, now all Scribus generated pages are blank. I reverted to 0.2.21 to double check and it definitely worked before. Pages generated with ThinReports work absolutely fine. If needed I can provide a sample PDF and template file from Scribus. What's funny is 0.2.23 gives the following errors for each page generated from Scribus:

Form data might be lost when combining PDF forms (possible conflicts).
Form data might be lost when combining PDF forms (possible conflicts).
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.
Warning: parser advancing for unknown reason. Potential data-loss.

But 0.2.21, which again is working, gives an additional error:

couldn't connect a reference!!! could be a null or removed (empty) object, Silent error!!!
 Object raising issue: {:is_reference_only=>true, :indirect_generation_number=>0, :indirect_reference_id=>0, :referenced_object=>nil}
Form data might be lost when combining PDF forms (possible conflicts).
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Warning: parser advnacing for unknown reason. Potential data-loss.
Form data might be lost when combining PDF forms (possible conflicts).

Note also how Form data might be lost when combining PDF forms (possible conflicts). appears at the top and bottom in 21, whereas it appears twice at the top in 23.

If there's anything I can do to try and get more information or anything I can provide to help please tell me.

boazsegev commented 8 years ago

Hello Kagetsuki,

Thank you very much for discovering and opening this issue.

  1. Can you please send me an example PDF to work with? (I don't have Scribus)
  2. Can you check with the version on Github if the issue still exists? I'm fixing something else and I could be that it was a related to the same cause...

Again, thank you for opening this issue. Bo.

boazsegev commented 8 years ago

I found some old Scribus PDF files on the internet and released a patched... I don't know if it solves everything, but there was an issue with PDF style "inheritance" (pages inheriting data) and empty string data that CombinePDF didn't handle properly.

I hope this is now resolved, please let me know if the fix works for you.

Kagetsuki commented 8 years ago

Now I get

combine_pdf-0.2.24/lib/combine_pdf/pdf_protected.rb:332:in `merge_outlines': undefined method `delete' for nil:NilClass (NoMethodError)

I'll try and take a good look tomorrow if I have time.

Scribus I'm using is edge, "Scribus NG". Here's one of the actual files we're using: --redacted--

boazsegev commented 8 years ago

I fixed it to work as expected with the file you sent me. There was an issue with outline merging where the outline existed but had 0 entries (code expected the outline to either exist with some entries or not exist.

If the issue persists, please reopen the issue (or open a new one), so we can fix this.

Thank you for your input and the test file you sent.

Kagetsuki commented 8 years ago

@boazsegev confirming you've fixed it! Works perfectly! Thanks!!!

boazsegev commented 8 years ago

🎉 Thanks for letting me know. I'm happy it's fixed.