Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options through meta tags only works while generating from string #254

Open
DeadlyJesus opened this issue Dec 1, 2023 · 0 comments
Open

Comments

@DeadlyJesus
Copy link

Hi,

I was trying to set options using meta tags while generating a pdf from an html file, but they were not used.
While looking at pdfkit's code I noticed that the meta tag parsing is only enabled when using from_string

if self.source.isString():
self.options.update(self._find_options_in_meta(url_or_file))

The documentation doesn't seems to mention this restriction.
Is there any reason to only allow meta tags options for string input ?

An easy workaround would be to read the html file and use from_string instead of from_file but it just seems weird.
Especially since _find_options_in_meta uses both strings and file-like objects

def _find_options_in_meta(self, content):
"""Reads 'content' and extracts options encoded in HTML meta tags
:param content: str or file-like object - contains HTML to parse
returns:
dict: {config option: value}
"""

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

No branches or pull requests

1 participant