boazsegev / combine_pdf

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

Single pdf causing to_pdf to hang forever #107

Closed ThunderGuppy closed 7 years ago

ThunderGuppy commented 7 years ago

We're run into a strange issue, wherein a particular pdf from our production server is causing an infinite hang when being generated into a pdf.

Code snippet is as follows:

def create_pdf_package
    combined_pdf = CombinePDF.new
    add_schedule_docs_to_pdf_package(combined_pdf)
    add_all_pdfs_docs_to_pdf_package(combined_pdf)
    # Suddenly decides to just stop dead right here
    combined_pdf.to_pdf
  end

def add_all_pdfs_docs_to_pdf_package(combined_pdf)
    all_pdf_docs.each do |doc|
      pdf_data = doc.document.data
      begin
        combined_pdf << CombinePDF.parse(pdf_data, allow_optional_content: true)
      rescue => e
        Rails.logger.info "[PDF PACKAGE ERROR] Couldn't add #{doc&.document&.name} (#{doc&.title}) to package in project #{project.id}: #{e.message}"
        raise PdfPackageGenerationError.new(doc)
      end
    end
  end

If I give you the problem pdf in question, might you be able to provide some insight into what is causing this?

boazsegev commented 7 years ago

Hi @ThunderGuppy ,

Thank you very much for opening this issue.

I would love to have a look and hopefully resolve this issue.

Could you send me the PDF in question and minimal working example code, so I can replicate the issue on my machine, that would be great!

Thanks again, Bo.

boazsegev commented 7 years ago

Did the latest release resolve the issue (v. 1.0.0)?

boazsegev commented 7 years ago

I can't reproduce the issue with the new gem version. If you still experience issues, please reopen.

edsontrick commented 2 months ago

I can reproduce with the actual gem version 👍 test.pdf

Just use this pdf