Module: Gotenberg::PdfEngines::Files

Included in:
Gotenberg::PdfEngines
Defined in:
lib/gotenberg/pdf_engines/files.rb

Instance Method Summary collapse

Instance Method Details

#convert(format, *sources) ⇒ Object

Converts PDF(s) to a specific PDF format. Gotenberg will return the PDF or a ZIP archive with the PDFs. gotenberg.dev/docs/modules/pdf-engines#convert. gotenberg.dev/docs/modules/pdf-engines#engines.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/gotenberg/pdf_engines/files.rb', line 26

def convert format, *sources
  properties['pdfFormat'] = format

  sources.each.with_index(1) do |source, index|
    files << multipart_file(IO.binread(source), File.basename(source))
  end

  @endpoint = '/forms/pdfengines/convert'
  @pdf_engines_convert = true

  self
end

#merge(*sources) ⇒ Object

Merges PDFs into a unique PDF. Note: the merging order is determined by the order of the arguments. See gotenberg.dev/docs/modules/pdf-engines#merge.



12
13
14
15
16
17
18
19
20
# File 'lib/gotenberg/pdf_engines/files.rb', line 12

def merge *sources
  sources.each.with_index(1) do |source, index|
    files << multipart_file(IO.binread(source), merge_prefix(index) + File.basename(source))
  end

  @endpoint = '/forms/pdfengines/merge'

  self
end