Commit graph

64 commits

Author SHA1 Message Date
prssanna
a4d8161a87 fix: print pdf fixes 2020-11-24 12:29:27 +05:30
prssanna
76bb9fc608 feat: skeleton loading state for print preview 2020-11-10 11:03:13 +05:30
Aditya Hase
16fc29e48d
fix(pdf): frappe.local.request is not available in backgound jobs and tests
Use frappe.utils.get_host_name instead of frappe.local.request.host
2020-10-27 14:18:36 +05:30
Aditya Hase
3f5f6f3b21
fix(pdf): Remove in_test check from get_pdf 2020-10-27 14:18:35 +05:30
Suraj Shetty
d254933a7c fix: Build cookie jar only if request object is present 2020-10-24 14:12:59 +05:30
Marica
1ad3bb76a5
fix: Skip using cookie-jar to set cookies if via tests (#11700) 2020-10-13 13:35:42 +05:30
Aditya Hase
3c9f265091
fix(pdf): Restrict cookies to the host domain
Use wkhtmltopdf's cookie-jar options to set domain
Reference: 7952b0f3e7/src/lib/multipageloader.cc (L532-L536)
Cookie format Reference: https://doc.qt.io/qt-5/qnetworkcookie.html#parseCookies

Also, werkzeug 0.16.x shows port in the host attribute.
https://werkzeug.palletsprojects.com/en/0.16.x/wrappers/#werkzeug.wrappers.BaseRequest.host
2020-09-09 20:58:42 +05:30
Aditya Hase
8feba5fa9b
fix(pdf): Cleanup temporary files after pdf generation
This was removed in https://github.com/frappe/frappe/pull/7358
2020-09-09 20:52:45 +05:30
Rushabh Mehta
8c8f7313f4
fix(minor): make utils explicit in safe_globals (#11408)
* fix(minor): make utils explicit in safe_globals

* fix(minor): import subprocess

* fix(minor): fix globals in safe_eval;

* fix(minor): import subprocess

* fix(minor): add test

* fix(minor): webhook.py

* fix(minor): document_type_mapping.py
2020-09-03 14:26:01 +05:30
Suraj Shetty
49aba26696 fix: Use non-pretty version of HTML for pdf generation 2020-07-14 16:36:24 +05:30
dependabot[bot]
bdb77ba521
chore(deps): bump bleach from 2.1.4 to 3.1.2 (#9779)
* chore(deps): bump bleach from 2.1.4 to 3.1.2

Bumps [bleach](https://github.com/mozilla/bleach) from 2.1.4 to 3.1.2.
- [Release notes](https://github.com/mozilla/bleach/releases)
- [Changelog](https://github.com/mozilla/bleach/blob/master/CHANGES)
- [Commits](https://github.com/mozilla/bleach/compare/v2.1.4...v3.1.2)

Signed-off-by: dependabot[bot] <support@github.com>

* chore: use html.parser instead of html5lib

bleach no longer ships html5lib as a requirement and instead has
included it in the system. we can switch to using html.parser instead;
which is not an external dependency unlike html5lib.

source: https://github.com/mozilla/bleach/blob/master/CHANGES#L206

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

* chore: use html5lib from bleach

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

* chore: import html5lib from bleach._vendor

fixes issue where bs4 is unable to find html5lib in the tree:

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: bleach._vendor.html5lib. Do you need to install a parser library?

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

* chore: just give up and install html5lib as a dependency

Signed-off-by: Chinmay D. Pai <chinmaydpai@gmail.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Chinmay D. Pai <chinmaydpai@gmail.com>
2020-03-25 00:20:57 +05:30
Alirio Castro
23d3f0e63b
feat: Indicate orientation for PDF file (#9660)
Same as other attributes, we could indicate default orientation by indicating in the .print-format css class without hardcoding, which is useful for cloud users.

Co-authored-by: Suraj Shetty <13928957+surajshetty3416@users.noreply.github.com>
2020-03-16 17:31:28 +05:30
Rohan Bansal
67791ff194 fix(pdf): error when trying to print PDFs 2019-12-26 14:44:19 +05:30
Rohit Waghchaure
7494328106 fix: disable smart shrinking for version 0.12.5 2019-10-25 18:36:26 +05:30
Rohit Waghchaure
7fc55d2cbd fix: font size showing small after upgrade to 0.12.5 2019-10-14 17:43:41 +05:30
ci2014
f0b59df21c Let developers choose the margins (#8513)
* Let developers choose the margins

Let the developers choose the margins

* fix: remove trailing whitespace
2019-10-03 06:25:38 +00:00
Shivam Mishra
8bc753b881 chore: disable pdf encryption for multipdf 2019-06-06 16:26:44 +05:30
Suraj Shetty
d67bcd2212 fix: Define filedata before it is used 2019-05-05 12:23:46 +05:30
Shivam Mishra
87bb91b64f fix: key error on password 2019-04-30 09:41:25 +05:30
Shivam Mishra
8e29bc4bf7 fix: possible fix to encoding issues in py3 2019-04-27 18:03:00 +05:30
Shivam Mishra
01a2df7e5a feat: code imporvements 2019-04-27 16:26:13 +05:30
Shivam Mishra
02c6abe609 feat: minor changes to pdf.py 2019-04-27 16:22:56 +05:30
Shivam Mishra
a9ca81370b fix: encoded password 2019-04-25 18:22:14 +05:30
Shivam Mishra
d791285ac2 feat: Added encryption feature for pdfs 2019-04-25 17:23:38 +05:30
Sagar Vora
fe3fe0a4b8 Merge branch 'master' into staging-fixes 2019-01-29 17:08:58 +05:30
Aditya Hase
36bc812c94 fix(security): Make server-side PDF rendering tighter 2019-01-28 12:41:21 +05:30
Aditya Hase
6b72faf44f style: Linting fixes (#6809)
* style: Remove unused imports

* style: Remove unused local variables
2019-01-23 16:39:55 +05:30
Saif
25827755b5 PDF allow parsing header-spacing (#6286)
Simply allow parsing header-spacing from custom css.
2018-10-22 10:13:26 +05:30
Nabin Hait
854b068ee9 Fixed merge conflict 2018-07-31 13:15:15 +05:30
Shreya Shah
4c20d1f68f using regex instead of soup to parse pdf page margins (#5883)
* using regex instead of soup to parse pdf page margins

* Fix codacy
2018-07-30 14:32:33 +05:30
Sagar Vora
5ddcf40a11 [python3] let PdfFileReader handle file opening (#5878)
In Python 3, file() is deprecated. 
PdfFileReader can internally handle file opening and closing, so file() no longer necessary.

See description of stream parameter here:
https://pythonhosted.org/PyPDF2/PdfFileReader.html#PyPDF2.PdfFileReader

Alternatively, open() can be used.
2018-07-27 11:55:48 +05:30
Prateeksha Singh
d2dfda2711
Merge pull request #4973 from lasalesi/configurablepdfborder
using regex instead of soup to parse pdf page margins
2018-05-03 17:41:52 +05:30
Achilles Rasquinha
796348cd60 fix indentation 2018-03-29 15:39:49 +05:30
Austin Bischoff
bf7ad3f3f1 pdf.py does not handle output properly if ContentNotFoundError is thrown (#5296)
If wkhtmltopdf throws a ContentNotFoundError exception (even though there is content) or other catchable exceptions the output keyword is not updated properly as it is in the try: section if no exception is thrown.   This causes the PDF being returned to be empty, empty PdfFileWriter() created in print_format.py line 26. This causes issues like https://github.com/frappe/erpnext/issues/13124 to occur where the viewer.js throws an error due to a bad pdf file.  The ContentNotFoundError exception is happening due to no header image in the letterhead or its a bad link being used when multi printing. 

The whole get_pdf() function should be rebuilt to test for ContentNotFoundError and other errors from wkhtmltopdf and then use a secondary try/catch to check for any other IOErrors related to being able to read the PDF back in from the file.  Right now this is not DRY since I basically copy and pasted lines 18 - 22 under line 31 so that if there is an error but the file exists the output will still be appended properly.
2018-03-29 12:00:05 +05:30
lasalesi
a60002726a corrected trailing whitespace (codacy) 2018-03-08 11:18:21 +01:00
Faris Ansari
cd54b6f6a1 Query Report (#5097)
* [listview] Show freeze message

* Call refresh on same page

* Simplify query_report lifecycle, Print partially working

* PDF Print, frappe.render_pdf

* Show freeze message

* Export
2018-02-28 17:10:09 +05:30
lasalesi
70756cf3c6 using regex instead of soup to parse pdf page margins 2018-02-06 13:46:23 +01:00
Juan F Fernández
3c8689e4a2 [FIX] Fixed problem with margins in pdf (see #3451 #4235 #4239) (#4297) 2017-10-18 09:21:36 +03:00
rohitwaghchaure
192fae169c [Fix] Letter head not displaying proper in the pdf (#4251) 2017-10-05 13:01:35 +05:30
maxtorete
c4ab2de7fd Fixed problem with margin top and bottom overwritten in print format (#3451) 2017-09-23 03:46:13 +02:00
Aditya Hase
000d9a41b6 Use PyPDF2 instead of pyPdf 2017-08-11 00:39:24 +05:30
tundebabzy
6fbe20caaa Except and raise statement python 3 compatible style (#3216)
* changes exception and raise statements to python 3 style

* changes except statement to python 3 style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* changes except and raise statement to python 3 compatible style

* adds six.reraise to fix python 3 style raise statements with traceback

* fixes indentation
2017-05-11 10:51:59 +05:30
rohitwaghchaure
e03d56adb6 [Fix] Multiple letter head printing issue on print format (#2365) 2016-11-25 16:10:42 +05:30
Rushabh Mehta
ea9c92daa5 [hot] ignoring loading errors causes background images to not load 2016-09-30 16:20:20 +05:30
Rushabh Mehta
74c4cbdba8 [minor] ignore load issues in wkhtmltopdf 2016-09-20 17:12:25 +05:30
Rushabh Mehta
2491c3e335 [minor] fix for pdf print 2016-08-29 11:31:47 +05:30
Rushabh Mehta
e03d22bb37 [fix] change parser in pdf generation 2016-03-03 17:16:22 +05:30
kardmode
3679689d71 [fix] for html parser for multi doc printing
BeautifulSoup parser "html5lib" doesn't work well with multi doc
printing
2016-02-28 16:15:18 +04:00
Anand Doshi
f14683e91e [fix] pdf print: footer encoding and workaround to include bootstrap in footer 2016-01-28 16:41:11 +05:30
Anand Doshi
8b0b93a3a8 [enhancement] PDF: Footer option in Letter Head and show page number at the bottom 2016-01-28 15:56:45 +05:30