- fixed chrome_pdf_backend arg by making it int and using it to properly override which pdf generator (chrome / wkhtmltopdf) to use.
- renamed new_pdf_backend to chrome_pdf_backend.
- added chrome_pdf_backend arg in local.from_dict to avoid passing it 4-5 functions deep
* chore: warn if wkhtmltopdf is invalid
wkhtmltopdf ( with patched qt ) is required to generate pdfs properly.
when user clicks on PDF, pdf will be generated and downloaded.
however, on print preview page warning will be shown.
* chore: refactor based on review comments
* chore: return False incase of exception
* chore: refactor and better naming
Co-authored-by: Ankush Menat <ankushmenat@gmail.com>
- Regex incorrectly fetches .print-format's child styles and also extracts the wrong attribute value
- A CssParser is more maintainable and more readable as well as less prone to errors while extracting values
- Method: We extract style tag contents out of the html and tokenize them. We then filter the styles for the right selector and extract the attributes we want from them.
- This way we make sure that the right value is extracted and only the ones applicable to .print-format directly
* refactor: Private images rendering in PDFs
Private images currently render fine if PDF is generated during a
request as we pass the cookiejar to WKHTML.
Background jobs however fail completeley because they can't retrieve
private images without cookiejar.
This PR converts all image types to base64 encoded sources in HTML
itself, so wkhtmltopdf doesn't have to a fire a request.
* test: private images in pdf
- Extract header/footer html into `content` first, then remove any instances from the main content since it is already rendered via the extracted header/footer html
- `frappe.get_print` calls `get_response_content("printview")` which calls `www/printview` that adds header and footer scripts
- Now it gets added again via `pdf_header_footer.html` which causes the script to run twice
- Header and Footer html are also added twice but then removed and handled in pdf.py (because printview + wkhtml processing)
- Misc: Use walrus operator
- Remove passed `letterhead` to insert script via pdf.py, printview handles it
- feat: Allow script injection into header/footer.html to allow manipulation of styles using page numbers/args received by wkhtmltopdf
- misc: also validate letterhead scripts
- Include scripts in printview as well as pdf
- Add helper instructions & re-arrange fields
refactor: clean up code to py39+ supported syntax
- f-strings instead of format
- latest typing support instead of pre 3.9 TitleCase
- remove UTF-8 declarations.
- many more changes
Powered by https://github.com/asottile/pyupgrade/ + manual cleanups
The license.txt file has been replaced with LICENSE for quite a while
now. INAL but it didn't seem accurate to say "hey, checkout license.txt
although there's no such file". Apart from this, there were
inconsistencies in the headers altogether...this change brings
consistency.
* Remove six for PY2 compatability since our dependencies are not, PY2
is legacy.
* Removed usages of utils from future/past libraries since they are
deprecated. This includes 'from __future__ ...' and 'from past...'
statements.
* Removed compatibility imports for PY2, switched from six imports to
standard library imports.
* Removed utils code blocks that handle operations depending on PY2/3
versions.
* Removed 'from __future__ ...' lines from templates/code generators
* Used PY3 syntaxes in place of PY2 compatible blocks. eg: metaclass