0

I need to edit metadata of PDF file created with minimagick, to be specific, title of pdf. I can set filename, no problem, but I haven't found any solution how to change that title. For example it apears in chrome pdf title thing when PDF is open.

This is snippet of my code:

pdf = MiniMagick::Image.open(template_image_path)

pdf.combine_options do |c|
  calibrate_name_text(c, name)
end
result.format 'pdf'

File.open(result.path, 'r') do |f|
  send_data f.read, type: 'application/pdf', filename: 'pdf_file.pdf'
end

This is title, even when pdf name if for example 'pdf_file': wrong title

When I use send_file function like this I got error in console:

send_file result.path, type: 'application/pdf', filename: 'pdf_file.pdf', url_based_filename: false

composite: gAMA: CRC error `' @ warning/png.c/MagickPNGWarningHandler/1746.

And pdf file has status 'Failed - Network error'

Thank you for your help

Qubis741
  • 283
  • 3
  • 12
  • Have you checked what the value of `file_name(name)` is? – Vidur Oct 23 '18 at 06:52
  • Alternatively, you can try using `send_file` and set the `url_based_filename` option to `false` - https://apidock.com/rails/ActionController/DataStreaming/send_file – Vidur Oct 23 '18 at 06:53
  • @Vidur I have edited my question, it was my function for stripping stuff – Qubis741 Oct 23 '18 at 07:07
  • 1
    It seems not possible with ImageMagick in the first place; see https://stackoverflow.com/questions/14921618/set-a-document-name-when-creating-a-pdf-from-an-image – Masa Sakano Oct 23 '18 at 13:37

0 Answers0