I am having a problem with the combination of several PDF files.
I am generating the PDF using PrawnPDF on the "show" action.
I would like to be able to combine multiple selected items into a single PDF.
I am trying to solve it this way using the combine_pdf geam
def nested_jobs_multiply_pdf pdf_file_paths = params[:items] pdf_file_paths = pdf_file_paths.map! do |x| x.to_s +".pdf" end @pdfForms = CombinePDF.new pdf_file_paths.each do |x| @pdfForms << CombinePDF.parse(nested_job_path(x, format: "pdf")) end @pdfForms.save "combined.pdf" flash[:notice] = "Combined PDF successful" redirect_to nested_jobs_pathend
Unfortunately, I am getting an error
RuntimeError in NestedJobsController#nested_jobs_multiply_pdfUnknown PDF parsing error - malformed PDF file?Extracted source (around line #89):87 @pdfForms = CombinePDF.new88 pdf_file_paths.each do |x|89 @pdfForms << CombinePDF.parse(nested_job_path(x, format: "pdf"))90 end91 @pdfForms.save "combined.pdf"92