Skip to content

Conversation

@orbanbotond
Copy link

@orbanbotond orbanbotond commented Dec 10, 2024

Add an endpoint to combine multiple pdfs into one single, without storing them anywhere.

I changed the ruby version to:3.3.0 because with the original:2.6.10 I've received this error from inside of combine_pdf: expected no Exception, got #<FrozenError: can't modify frozen String> with backtrace, while with 3.3.0 it is working perfectly.

It is needed currently by the Pop project and at later stages the same similar functionality will be extracted from the ORMS.

Open questions:

  • should we number the pages?
  • should we watermark the pages?
    # Combine Multiple PDF's into one single PDF
    #
    # POST params:
    #  pdf1     - the first pdf to combine
    #  pdf2     - the second pdf to combine
    #  ...
    #  pdf<n>   - the nth pdf to combine
    post '/combine_pdf' do

Test with cUrl:

curl -F 'pdf2=@/Users/orbanbotond/profession/ruby/clients/ifad/colore/spec/fixtures/pdfs/2.pdf' -F 'pdf1=@/Users/orbanbotond/profession/ruby/clients/ifad/colore/spec/fixtures/pdfs/1.pdf' http://0.0.0.0:9240/combine_pdf -K output.pdf >> output.pdf

@tagliala
Copy link
Member

Hi Botond,

I was speaking with Amedeo some days ago because we need an endpoint with the following features:

  • "Document merge", not restricted to PDFs
  • Avoid using the Ruby combine_pdf gem
  • Async processing
  • One-by-one document upload

We have encountered issues with combine_pdf and some Word documents, as outlined in this issue, and we want to explore alternatives.

For this specific implementation:

  • It uses combine_pdf
  • It involves passing several documents in a single POST with unknown sizes

Given these concerns, we prefer not to merge it and keep using combine_pdf locally at application level

@tagliala tagliala closed this Dec 11, 2024
@orbanbotond orbanbotond changed the title Add API encpoint /combine_pdf to combine multiple pdfs into one single pdf Add API endpoint /combine_pdf to combine multiple pdfs into one single pdf Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants