reportlab

How to set the width of the page?

…衆ロ難τιáo~ 提交于 2019-12-11 05:11:27
问题 I have been trying to increase the width of pdf but nothing seems to work: <style type="text/css"> @page { size: a4 landscape; width: 27cm; /* not working */ @frame content { top: 2cm; width: 27cm; /* not working */ margin-left: 1.5cm; /* changing these values work!! */ margin-bottom: 2cm; /* changing these values work!! */ } } </style> No matter what I try, the content width doesn't seem to increase. All my <div> , <tables> are at 100%, and reducing the margin increases the size of the table

python reportlab - registerFont - django - font not available after some time

拟墨画扇 提交于 2019-12-11 03:55:47
问题 I'm wondering what is the best time to register a font for use in reportlab. I added the following line into my settings.py: pdfmetrics.registerFont(TTFont('Calibri', FONT_DIR + '/fonts/Calibri.ttf')) After this call the font is available for pdf generation. But it occurs that after a few days the font is not available anymore and I have to restart the django app, which leads to a re-registering of the font. One approach I already tried was registering the font before each pdf generation call

ReportLab and pdfrw: Importing Scanned PDF

≡放荡痞女 提交于 2019-12-11 03:39:35
问题 Using the code below, I am trying to import a pdf page into an existing canvas object and save to PDF. This usually works just fine, but I noticed that when I try it with a PDF generated from a scanned document, it results in a blank page. Any takers? from reportlab.pdfgen import canvas from pdfrw import PdfReader from pdfrw.buildxobj import pagexobj from pdfrw.toreportlab import makerl c = canvas.Canvas(Out_Folder+pdf_file_name) c.setPageSize([11*inch, 8.5*inch]) page = PdfReader(folder+'2

A simple method for rotate images in reportlab

拈花ヽ惹草 提交于 2019-12-11 02:22:58
问题 How can we rotate easily an image using reportlab ? I looked for and I do not found an easy method. The only way found comes from http://dods.ipsl.jussieu.fr/orchidee/SANORCHIDEE/TEMP/TEMP_LOCAL/cdat_portable/lib_new_wrong_gcc/python2.4/site-packages/reportlab/test/test_graphics_images.py using for example: >>> from reportlab.graphics.shapes import Image, Drawing >>> from reportlab.platypus import SimpleDocTemplate >>> from reportlab.lib.pagesizes import A4, portrait >>> from reportlab.lib

Python: Generating barcodes and accounting for duplicate PDF forms

寵の児 提交于 2019-12-11 02:05:26
问题 This is a bit involved, so please stay with me. I'm working on a "Court Watch" project, which involves asking volunteers to take forms with them and indicating what happens during a trial/hearing in specific Courtrooms. This is the form (redactions for privacy). We have hundreds of them filled out by volunteers. Now, as these are handwritten documents , they need to be transcribed by other volunteers into a spreadsheet. We're using Google Forms and volunteers to handle this. However, we need

How to add page number to a pdf file?

余生长醉 提交于 2019-12-11 00:14:08
问题 I've been trying all morning to add page numbers to a pdf document, but I can't figure it out. I'd like to use python, with pyPdf or reportlab. Does anyone have any ideas? 回答1: Here is my Python code to Add Page Number to PDF file. I have used both pyPdf2 and reportlab. #!/usr/bin/env python3 # -*- coding: utf-8 -*- helpDoc = ''' Add Page Number to PDF file with Python Python 给 PDF 添加 页码 usage: python addPageNumberToPDF.py [PDF path] require: pip install reportlab pypdf2 Support both Python2

python: pdf - set password protected print, copy, paste options?

烂漫一生 提交于 2019-12-10 21:05:33
问题 Hi I'm looking for a python lib that will allow me to set password protected print, copy, paste options on some existing pdfs I looked at the reportlab pdfencrypt module: this has exactly the options I need, but the open source version is heavily restricted - cant even set a real password, and the license is not an option (over £1000/year) - this will be relatively low volume (< 1000 docs processed per year), and the client is a non-profit organisation any suggestions greatly appreciated! 回答1

Reportlab [ Platypus ] - Image does not render

假装没事ソ 提交于 2019-12-10 18:51:45
问题 I am working on a report that includes a mixture of tables and images. The images [ graphs, actually ] are saved to the filesystem in .png form. The method that actually renders the PDF is: def _render_report(report_data): file_name = get_file_name() # generate random filename for report rpt = Report(settings.MEDIA_ROOT + os.sep + file_name) Story = [] for (an, sam, event), props in report_data.iteritems(): Story.append(Paragraph("%s - sample %s results for %s" % (an.name, sam.name, event

how to make fillable forms with reportlab in python [closed]

青春壹個敷衍的年華 提交于 2019-12-10 18:33:12
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . can anyone please help me with creating forms in python using the reportlab lib. i am totally new to this and i would appreciate sample code thanks 回答1: Apparently reportlab does not support creating fillable pdf

How can I add a png to a PDF with report lab

≡放荡痞女 提交于 2019-12-10 17:57:04
问题 I'm working with report lab, I can't get a way to add png image with platypus this is some sample code from here http://www.tylerlesmann.com/2009/jan/28/writing-pdfs-python-adding-images/, with the error for append that png Could you help me to get it working? #!/usr/bin/env python import os import urllib2 from reportlab.lib.pagesizes import letter from reportlab.platypus import SimpleDocTemplate, Image filename = './python-logo.png' def get_python_image(): """ Get a python logo image for