gutschilla / elixir-pdf-generator

Create PDFs with wkhtmltopdf or puppeteer/chromium from Elixir.
MIT License
332 stars 71 forks source link

Custom file name not working #24

Closed Xypus closed 7 years ago

Xypus commented 7 years ago

Hi,

I was trying to get the generator to return a pdf file with a custom name passed via shell_params: ["--title", "custom_filename"], but it seems to be impossible due to this:

pdf_file        = random_filebase <> ".pdf"
...
case status do
    0 ->
        case Keyword.get options, :open_password do
            nil     -> { :ok, pdf_file }
            user_pw -> ...
        end
    _ -> { :error, error }
end

If I'm reading this right if the pdf generation was successful, the generator returns the filename assigned long before any options were passed to wkhtmltopdf...

gutschilla commented 7 years ago

Honestly, I have to dive into this. The whole custom filename was a bad idea any way and whould be in another module instrumenting the base functionality of this module. Sadly, I will not find time to address this until end of May 2017. Meanwhile I suggest to simply use the random filename and then rename the file on your own. That's probably a bit cumbersome but should work.

gutschilla commented 7 years ago

@Xypus BTW: Thanks a lot for your report! I really appreciate your input.

gutschilla commented 7 years ago

This is being addressed in https://github.com/gutschilla/elixir-pdf-generator/pull/23

gutschilla commented 7 years ago

@Xypus https://github.com/gutschilla/elixir-pdf-generator/pull/23 Was merged. So it should work right now. Yeah and I should definitely add some tests ;-)