Skip to content

Conversation

@vpoulailleau
Copy link

Allow to call weasyprint CLI without output filename. The default output filename is input filename followed by .pdf.

(Everytime I use weasyprint, I forget to provide output filename…)

@liZe
Copy link
Member

liZe commented Mar 27, 2025

Hi,

Thanks for this pull request! 🙏🏽

That’s a good idea, but I have some concerns about the current implementation:

  • When document.html is given, I think I’d prefer to get document.pdf, not document.html.pdf.
  • When a URL is given (for example weasyprint https://weasyprint.org/), we currently get a crash.

We can first decide which "good" filename we want to get for these common cases (and maybe look at what other widely used tools do):

  • document
  • document.html
  • ../../folder/document.html
  • https://example.org/
  • https://example.org/index
  • https://example.org/index.php
  • https://example.org/index.php?a=b&c=d
  • … (you’ll for sure find other ones!)

And then, we’ll find a simple, clean and reliable way to get this! 😄

@luca-vercelli
Copy link
Contributor

Hello, who was that question for?
Here is my unrequested opinion:

source target
document.html ./document.pdf
document ./document.pdf
document.foo ./document.pdf
document.foo.bar ./document.foo.pdf
../../folder/document.html ./document.pdf (*)
https://example.org/ ./output.pdf (or some other default)
https://example.org/path/index ./index.pdf
https://example.org/path/index.php ./index.pdf
https://example.org/path/index.php?a=b&c=d ./index.pdf
https://example.org/path/index#a=b;c=d ./index.pdf

(*) not sure of this, but I think that's a good choice about write permissions on filesystem

@vpoulailleau
Copy link
Author

@liZe I don't have the time right now, maybe in july. The suggestions of @luca-vercelli look good to me. What do you think?

@liZe
Copy link
Member

liZe commented Jun 12, 2025

@liZe I don't have the time right now, maybe in july. The suggestions of @luca-vercelli look good to me. What do you think?

@vpoulailleau Looks good to me. You can write a dedicated function for that, so that we can easily test it.

(I really hope that it won’t be too complex though. Comments like the ones in this thread may help to find corner cases.)

@Firefly7-7
Copy link

about the case of ../../folder/document.html, I agree with you, not necessarily because of permissions but simply because the default behavior most users expect (and is what most programs implement, I believe) is that if you run a process in a directory, the output will be in that directory.

@liZe liZe marked this pull request as draft August 29, 2025 17:05
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.

4 participants