djangosnippets.org: Latest snippets tagged with 'pdf'https://djangosnippets.org/tags/pdf/2013-07-19T02:13:35.464470-05:00Basic PDF view mixin and utils using reportlab.
2013-07-19T02:13:35.464470-05:00elequhttps://djangosnippets.org/snippets/2975/<p>Simplified version of the snippet that renders model to PDF <a href="http://djangosnippets.org/snippets/2540/">http://djangosnippets.org/snippets/2540/</a> </p>
<p>This PDF view mixin for Django Class Based Views.</p>
<p>See working project example: https://github.com/elena/django-pdfmixin-example</p>
<hr />
<p>This is based on the case scenario where you have a model which has a <code>DetailView</code>.</p>
<p>You then construct a bespoke PDF for the …</p>
Freely redistributableCustom 'save' method, automate creating pdf file from entry.
2011-09-28T10:08:16.464801-05:00I159https://djangosnippets.org/snippets/2557/<p>Save method, useful for automate pdf files creation if you want to use the file in database.</p>
Freely redistributableView mixin and utils to generate PDF documents from html using xhtml2pdf
2011-09-06T10:17:53.590136-05:00frankbanhttps://djangosnippets.org/snippets/2540/<p>View mixin and utils to generate PDF documents from html using <em>xhtml2pdf</em>.</p>
<p>The most interesting thing here is <em>PDFTemplateResponseMixin</em>.
Adding this mixin to class based views allows automatic pdf generation using
the view context and a customized template.</p>
<p>There is also the lower level function <em>render_to_pdf</em>, similar …</p>
Freely redistributableRML2PDF with Django
2010-03-26T09:31:09.970306-05:00meithamhttps://djangosnippets.org/snippets/1971/<p>This is a django view that can return a PDF made using rml2pdf from reportlab. This RML is written with django templating system, to view the rml code and download a fully working version visit <a href="https://www.reportlab.com/software/documentation/sample-projects/rml-with-django/">reportlab</a></p>
Freely redistributablepyText2Pdf - Python script to convert plain text into PDF file. Modified to work with streams.
2009-11-04T08:08:44.076934-06:00vsergeyevhttps://djangosnippets.org/snippets/1778/<p>This is "pyText2Pdf" - Python script to convert plain text into PDF file.
Originally written by Anand B Pillai.
It is taken from http://code.activestate.com/recipes/189858/</p>
<p>Modified to work with streams.</p>
<p>Example: produce PDF document from text and output it as HTTPResponse object.</p>
<pre><code>import StringIO
input_stream = StringIO.StringIO(text)
result = StringIO.StringIO()
pdfclass …</code></pre>
Freely redistributableA form field for valdating PDF and Microsoft Word document
2008-11-14T16:09:16.559010-06:00jimmylamhttps://djangosnippets.org/snippets/1189/<p>This is form field for PDF or Microsoft Word Document (both .doc and .docx)
It will validate the file uploaded as a valid PDF and MS Word Document.</p>
<p>It extends a forms.FileField, so you can put all the arguments relevant to FileField.</p>
<p>IMPORTANT NOTE: The method of validation is actually …</p>
Freely redistributableSomething like list_detail generic view but returns PDF document instead
2008-09-04T08:59:33.033165-05:00aurelijehttps://djangosnippets.org/snippets/1020/<p>This should work as a <code>django.views.generic.list_detail</code> generic view but will produce PDF version of given template.</p>
<p>This code is merged code from perenzo's <a href="http://www.djangosnippets.org/snippets/659/">example</a> and code from <code>django.views.generic.list_detail</code> module.</p>
<p><code>pisa</code> package is required from (http://www.htmltopdf.org/download.html) with <code>html5lib</code> package and Reportlab Toolkit 2.1+</p>
<p>NOTE: this is code for Django 0.96. In …</p>
Freely redistributablePDF generation directly using HTML
2008-03-23T14:01:15.291649-05:00perenzohttps://djangosnippets.org/snippets/659/<p>This is an extract of an example for use of "pisa" <a href="http://www.htmltopdf.org">http://www.htmltopdf.org</a> in "django". It shows the easiest way possible to create PDF documents just using HTML and CSS. In "index" we see the definition of the output of a form in which HTML code can be typed in and …</p>
Freely redistributableCreate nice looking PDFs from developer documentation
2007-12-18T17:38:19.616905-06:00henninghttps://djangosnippets.org/snippets/516/<p>You need htmldoc, rst2html, the Python Imaging Libraray, BeautfiulSoup
and spoon.
The Debian/Ubuntu-packages are called htmldoc, python-docutils, python-imaging and python-beautifulsoup
You can get spoon.py http://beautifulspoon.googlecode.com/svn/trunk/spoon.py</p>
<p>To create the pdf files you have to call the script from django_src/docs</p>
<p>Here is an example output: http://henning.cco-ev.de/django/essential.pdf</p>
Freely redistributableCreate PDF files using rml and django templates
2007-06-29T12:31:55.812550-05:00mporratohttps://djangosnippets.org/snippets/298/<p>It allows you to create pdf much like normal html code taking advantage of django's template engine. It requires the trml2pdf module from <a href="http://sourceforge.net/projects/openreport">OpenReport</a> and can be used like <code>render_to_response()</code>. <em>prompt</em> specifies if a "save as" dialog should be shown to the user while <em>filename</em> is the name that …</p>
Freely redistributableDownload images as png or pdf
2007-04-03T18:56:30.355117-05:00gkellyhttps://djangosnippets.org/snippets/151/<p>This is an example of how I am providing downloads of dynamic images in either PNG or PDF formats. The PDF format requires ImageMagick's <code>convert</code>, and temporary disk space to save the intermediary image. If anyone knows a way to avoid writing to disk, I'd be happy to include …</p>
Freely redistributableConvert LaTeX templates to various output formats
2007-03-11T20:38:57.324526-05:00blizzhttps://djangosnippets.org/snippets/102/<p><strong>The code is a bit messy and may include bugs ;-) Anyway, I want to clean it up and add features (see below).</strong>
</p>
<p>The <code>process_latex()</code> function will read the given template, render it with a custom context and convert it into the desired output format by running it through pdflatex. …</p>
Freely redistributable