0

I'm using the following syntax to generate PDF from URL:

wkhtmltopdf http://example.com/ example.pdf

Is there any way to generate filename automatically based on its page title?

So I'm expecting to not hardcode the filename as above.

List of option is extensive (-H) and maybe I've missed something, but the only one which I think could work is --read-args-from-stdin.

1 Answer 1

0

I've found the following workaround:

wkhtmltopdf http://example.com "$(curl -s http://example.com | grep -o "<title>[^<]*" | tail -c+8).pdf"

Which will generate file named: Example Domain.pdf.

The only downside is that the connection needs to be performed twice as well as you've to type URL twice, but in the script it can be a variable. And the filename it-self isn't printed to the output.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .