Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

fix(pdf-export): paginate array

as-op2e4462c8b803
diff --git a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
index ec197e257a9..ac3822e5dc9 100644
--- a/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
+++ b/app/models/work_package/pdf_export/work_package_list_to_pdf.rb
@@ -114,9 +114,11 @@ class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exports::Query
@batches_count = work_packages.length.fdiv(@work_packages_per_batch).ceil
batch_files = []
(1..@batches_count).each do |batch_index|
- batch_work_packages = work_packages.paginate(page: batch_index, per_page: @work_packages_per_batch)
- batch_files.push render_pdf(batch_work_packages, "pdf_batch_#{batch_index}.pdf")
- setup_page!
+ batch_work_packages = work_packages.slice(batch_index * @work_packages_per_batch, @work_packages_per_batch)
+ unless batch_work_packages.nil?
+ batch_files.push render_pdf(batch_work_packages, "pdf_batch_#{batch_index}.pdf")
+ setup_page!
+ end
end
merge_batched_pdfs(batch_files, filename)
end
@@ -124,9 +126,6 @@ class WorkPackage::PDFExport::WorkPackageListToPdf < WorkPackage::Exports::Query
def merge_batched_pdfs(batch_files, filename)
return batch_files[0] if batch_files.length == 1
- # All internal link annotations are not copied over on merging
- # TODO: is there a way to preserve them?
-
merged_pdf = Tempfile.new(filename)
# We use the command line tool "pdfunite" for concatenating the PDFs.