aboutsummaryrefslogtreecommitdiffstats
path: root/wkhtmltopdf/utils.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove extraneous try/except. Revert test run script changes, but set ↵Josh2016-02-261-12/+8
| | | | DEBUG=False.
* Fix premature file delete on DEBUG=False. Modify test runner to check both ↵Josh2016-02-261-28/+38
| | | | DEBUG options.
* Refactor to better support multiple pages.Josh2016-02-251-34/+47
|
* Merge pull request #99 from pauricthelodger/bytes-errorMax Peterson2016-02-191-2/+4
|\ | | | | Fix unidecode bytes error on python2
| * Fix unidecode bytes error on python2Padraic Harley2015-12-181-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `bytes` takes no additional args in python2 unlike it's taking an encoding in python3. Unidecode returns a unicode string in python3 and a bytestring in python2 which, I believe, was the main cause of error #71. Now, regardless of whether unidecode is included, all strings passing through http_quote will be encoded to ascii which should fix both issues. Also included is a fix for a failing test when unidecode is used. Unidecode's `_unidecode` function ignores characters greater than 0xefff, which '\xe2\x99\xa5' (the heart symbol) is. This caused users with unidecode to fail '.pdf' was produced rather than the expected '?.pdf'.
* | Remove dependency on Django template engineRyan Kaskel2016-02-171-9/+21
|/
* Merge pull request #95 from johnraz/extract-logicMax Peterson2015-12-011-1/+86
|\ | | | | Extract logic from views
| * Extracted logic from views - fixed tests.Jonathan Liuti2015-12-011-1/+86
| | | | | | | | | | | | | | | | | | | | | | The logic was coupled with the views which made things difficult to reuse if you wanted to use the pdf generation somehwere else than in a view. With this patch, the logic has been moved to `utils.py` and should be more easy to reuse. Tests have been adapted and made compatible with django > 1.7
* | Merge pull request #72 from ghost/masterMax Peterson2015-12-011-1/+1
|\ \ | | | | | | fix: Problem with filename
| * | fix #71Daniel Gatis Carrazzoni2015-01-051-1/+1
| | | | | | | | | fix https://github.com/incuna/django-wkhtmltopdf/issues/71
* | | Update utils.pyJoseph2015-11-261-1/+1
| | |
* | | Update utils.pyJoseph2015-11-261-1/+2
| |/ |/|
* | Merge pull request #85 from powderflask/masterJames Turnbull2015-07-311-2/+7
|\ \ | | | | | | Skip absolute path substitution where STATIC or MEDIA URL are empty or None
| * | Patch python3 / mod_wsgi incompatibility on sys.stderrr.fileno() callJoseph2015-07-281-1/+6
| | | | | | | | | | | | | | | Root cause of this issue is in python3 / mod_wsgi. See: https://github.com/GrahamDumpleton/mod_wsgi/issues/85 This patch detects if there is something screwy with fileno() and simply skips setting stderr if there is to avoid the AttributeError that occurs otherwise. Pull https://github.com/incuna/django-wkhtmltopdf/pull/40 fixed this same issue when it arose for python 2.7, but the nature of the issue seems to have shifted, making it trickier to detect that the fileno() method cannot be called.
| * | Skip absolute path substitution where STATIC or MEDIA URL is not setJoseph2015-07-161-1/+1
| |/ | | | | | | STATIC_URL or MEDIA_URL settings default to '' and None These default values cause the url match and replace algorithm to insert the *_ROOT setting in EVERY quoted string!!
* / WKHTMLTOPDF_CMD is properly split by the shlex module split() which properly ↵Brantley Harris2015-06-221-1/+2
|/ | | | accounts for quotes and escapes.
* Change the wkhtmltopdf urlDaniel Duong2014-10-271-1/+1
|
* First try py3k then fall back to python2Matt Lenc2014-06-181-3/+3
|
* Add support for Python3Matt Lenc2014-06-181-7/+14
|
* Fix tests for Travis by obtaining the WKHTMLTOPDF_CMD from env vars.mattack1082013-09-201-2/+3
|
* Test sys.stderr to ensure it hasn't been overriddenGreg McGuire2013-08-021-5/+8
|
* Move make_absolute_paths to utils so it can be used in testsmattack1082013-01-151-0/+35
|
* Merge pull request #21 from shadowrock/fix-extra-slashesJames Turnbull2013-01-101-1/+2
|\ | | | | Removed extra slashes so the local file paths work in Windows.
| * Removed extra slashes so the local file paths work in Windows.Matti Varjokallio2012-11-291-1/+2
| |
* | Fix for case when WKHTMLTOPDF_CMD consists of many parts.Matti Varjokallio2012-12-091-1/+1
|/
* Fix images path in PDFsmlen1082012-11-131-52/+0
|
* Pass --encoding utf8 to wkhtmltopdf to render Unicode characters to PDF.Simon Law2012-08-301-0/+3
| | | | | | Since we PDFTemplateResponse renders templates, and Django uses UTF-8 to do the rendering, we can safely assume that the result is in UTF-8.
* Tidy up imports.Marc Tamlyn2012-07-271-4/+1
|
* Remove more deprecated stuff and tests for them.Marc Tamlyn2012-07-271-13/+0
|
* Fix typo in docstring.Charlie Denton2012-07-271-1/+1
|
* Python 2.6 compatibility fixes.Simon Law2012-07-261-1/+1
| | | | Implicit position arguments for str.format() are a 2.7ism.
* settings.WKHTMLTOPDF_ENV can override environment variables.Simon Law2012-07-251-1/+6
| | | | | | This is most usefully set to {'DISPLAY': ':1'} in production. This allows wkhtmltopdf access to a specific X headless server, since the server will not be running under X.
* MEDIA_URL and STATIC_URL overrides PDFTemplateResponse.get_override_settings()Simon Law2012-07-251-0/+6
| | | | | | | | | | | | | | | | MEDIA_URL and STATIC_URL used to be set only in get_context_data(), but there are apps such as staticfiles and Django Compressor where this won't work well. Instead, they need to be overridden at the settings level, not at the context level. This allows template context processors to populate a RequestContext with the right values. In addition, MEDIA_URL and STATIC_URL are now overridden as file:// URLs, based on MEDIA_ROOT and STATIC_ROOT. This allows developers to access these views in runserver, against their current codebase. It also means faster access for wkhtmltopdf, since the files are stored locally.
* PDFTemplateView.cmd_options contains all the options to pass to wkhtmltopdfSimon Law2012-07-241-0/+8
| | | | | | | | | | | | | | | | | | | | Before, command-line arguments were class-based. Unfortunately, this means that you cannot add new command-line arguments without subclassing. Instead, PDFTemplateView.cmd_options is a dictionary of all command-line arguments. PDFTemplateView.as_view(cmd_options={...}) now works as expected. !!!! WARNING !!!! cmd_options is now empty, leaving wkhtmltopdf with its default behaviour. Explicitly add the options you want. Existing subclasses of PDFTemplateView will now break, but a PendingDeprecationWarning will be issued. Margins will now be wkhtmltopdf's default of 10mm. PdfTemplateView contains a compatibility shim with the old default values for margins and orientation.
* PDFTemplateResponse and PDFTemplateView now match Django's implementationsSimon Law2012-07-241-0/+55
| | | | | | | | | PDFTemplateResponse is like TemplateResponse in that it does dynamic rendering of a template on the fly. PDFTemplateView has a much smaller implementation, relying on PDFTemplateResponse to do the rendering for it. It also knows about the standard TemplateResponse when it needs to render the HTML version.
* PDFResponse is more robust:Simon Law2012-07-231-0/+30
| | | | | | | * Now matches HttpResponse in function signature. * Modern Django content_type/mimetype handling. * Sanitizes and quotes filenames in Content-Disposition header. * Tests.
* settings.WKHTMLTOPDF_CMD_OPTIONS sets default command-line options.Simon Law2012-07-201-3/+6
|
* settings.WKHTMLTOPDF_CMD is loaded on-the-fly, not at the module level.Simon Law2012-07-201-3/+2
| | | | This allows overriding this configuration option at run-time.
* Reliable command-line argument parsing for wkhtmltopdf().Simon Law2012-07-201-18/+37
| | | | | | The API for wkhtmltopdf has changed. Long arguments that take no parameters now use True and not the empty string. In addition, argument-parameters may now be Unicode.
* wkhtmltopdf() uses subprocess.check_output() instead of a custom Popen call.Simon Law2012-07-201-11/+5
|
* Be clear with template_to_temp_file's argumentsJames Turnbull2012-03-091-2/+2
| | | | | | | | | | | It's not obvious what template_to_temp_file is doing with its undefined arguments. The Zen of Python states: Explicit is better than implicit. Readability counts. An alternative solution would be to rename the function to loader_render_to_tempfile or similar, but this fix is more backwards-compatible.
* Refactor the main render method into a class based viewGeorge Hickman2011-10-301-30/+1
| | | | | | Use a PdfResponse to deal with the headers and response type. Make the margin_* and filename variables instance variables on the view with sane defaults.
* Code cleanupGeorge Hickman2011-10-301-3/+4
| | | | | Fix a spelling mistake Wrap a particularly long line
* Use with for file usageGeorge Hickman2011-10-301-6/+7
| | | | | Replace old style file open and close with a `with` block for clarity and it's error handling.
* Removed unised importv0.1.1Max Peterson2011-09-061-1/+0
|
* Added smart_strMax Peterson2011-09-061-1/+3
|
* fixed some bugs, added filename supportCharlie Denton2011-07-251-4/+10
|
* Added as newMax Peterson2011-07-081-0/+88