pdfrw

pdfrw checkbox AS values gets unwanted parentheses

随声附和 提交于 2021-02-20 02:42:28
问题 So I'm trying to mark checkboxes in a PDF file with pdfrw. That means changing the checkboxes "AS" value from the default "/Off" to "/Yes". pdfrw is currently forcing parentheses around my "/Yes" when it writes to file, so it doesn't work. How do I keep it from adding these parentheses? My code: template_pdf = pdfrw.PdfReader(input_pdf_path) annotations = template_pdf.pages[0][/Annots] for annotation in annotations: annotation.update(pdfrw.PdfDict(AS="/Yes")) pdfrw.PdfWriter().write(output

pdfrw checkbox AS values gets unwanted parentheses

江枫思渺然 提交于 2021-02-20 02:41:31
问题 So I'm trying to mark checkboxes in a PDF file with pdfrw. That means changing the checkboxes "AS" value from the default "/Off" to "/Yes". pdfrw is currently forcing parentheses around my "/Yes" when it writes to file, so it doesn't work. How do I keep it from adding these parentheses? My code: template_pdf = pdfrw.PdfReader(input_pdf_path) annotations = template_pdf.pages[0][/Annots] for annotation in annotations: annotation.update(pdfrw.PdfDict(AS="/Yes")) pdfrw.PdfWriter().write(output

pdfrw checkbox AS values gets unwanted parentheses

回眸只為那壹抹淺笑 提交于 2021-02-20 02:41:04
问题 So I'm trying to mark checkboxes in a PDF file with pdfrw. That means changing the checkboxes "AS" value from the default "/Off" to "/Yes". pdfrw is currently forcing parentheses around my "/Yes" when it writes to file, so it doesn't work. How do I keep it from adding these parentheses? My code: template_pdf = pdfrw.PdfReader(input_pdf_path) annotations = template_pdf.pages[0][/Annots] for annotation in annotations: annotation.update(pdfrw.PdfDict(AS="/Yes")) pdfrw.PdfWriter().write(output

pdfrw checkbox AS values gets unwanted parentheses

五迷三道 提交于 2021-02-20 02:40:54
问题 So I'm trying to mark checkboxes in a PDF file with pdfrw. That means changing the checkboxes "AS" value from the default "/Off" to "/Yes". pdfrw is currently forcing parentheses around my "/Yes" when it writes to file, so it doesn't work. How do I keep it from adding these parentheses? My code: template_pdf = pdfrw.PdfReader(input_pdf_path) annotations = template_pdf.pages[0][/Annots] for annotation in annotations: annotation.update(pdfrw.PdfDict(AS="/Yes")) pdfrw.PdfWriter().write(output

pdfrw checkbox AS values gets unwanted parentheses

柔情痞子 提交于 2021-02-20 02:40:07
问题 So I'm trying to mark checkboxes in a PDF file with pdfrw. That means changing the checkboxes "AS" value from the default "/Off" to "/Yes". pdfrw is currently forcing parentheses around my "/Yes" when it writes to file, so it doesn't work. How do I keep it from adding these parentheses? My code: template_pdf = pdfrw.PdfReader(input_pdf_path) annotations = template_pdf.pages[0][/Annots] for annotation in annotations: annotation.update(pdfrw.PdfDict(AS="/Yes")) pdfrw.PdfWriter().write(output

How to Save io.BytesIO pdfrw PDF into Django FileField

旧时模样 提交于 2021-01-27 13:39:17
问题 What I am trying to do is basically: Get PDF from URL Modify it via pdfrw Store it in memory as a BytesIO obj Upload it into a Django FileField via Model.objects.create(form=pdf_file, name="Some name") My issue is that when the create() method runs, it saves all of the fields except for the form . helpers.py import io import tempfile from contextlib import contextmanager import requests import pdfrw @contextmanager def as_file(url): with tempfile.NamedTemporaryFile(suffix='.pdf') as tfile:

Merging PDFs while retaining custom page numbers (aka pagelabels) and bookmarks

偶尔善良 提交于 2020-05-30 08:12:26
问题 I'm trying to automate merging several PDF files and have two requirements: a) existing bookmarks AND b) pagelabels (custom page numbering) need to be retained. Retaining bookmarks when merging happens by default with PyPDF2 and pdftk, but not with pdfrw. Pagelabels are consistently not retained in PyPDF2, pdftk or pdfrw. I am guessing, after having searched a lot, that there is no straightforward approach to doing what I want. If I'm wrong then I hope someone can point to this easy solution.

Merging PDFs while retaining custom page numbers (aka pagelabels) and bookmarks

妖精的绣舞 提交于 2020-05-30 08:12:07
问题 I'm trying to automate merging several PDF files and have two requirements: a) existing bookmarks AND b) pagelabels (custom page numbering) need to be retained. Retaining bookmarks when merging happens by default with PyPDF2 and pdftk, but not with pdfrw. Pagelabels are consistently not retained in PyPDF2, pdftk or pdfrw. I am guessing, after having searched a lot, that there is no straightforward approach to doing what I want. If I'm wrong then I hope someone can point to this easy solution.

Working with streams in PDFrw for Python?

自作多情 提交于 2019-12-13 15:17:59
问题 I'm trying to read in an example PDF with PDFrw. The PDF contains the phrase Hello Matthew in the bottom left corner at coordinates (100, 100) . When I attempt to output the text (if I even can?) I get a stream of data. I can't seem to figure out how to get that as text. >>> import pdfrw >>> file_object = pdfrw.PdfReader("Hello.pdf") >>> file_object {'/ID': ['<f643bc0910dfb67725d53e11054f4609>', '<f643bc0910dfb67725d53e11054f4609>'], '/Info': (5, 0), '/Root': {'/Outl ines': (8, 0), '/PageMode

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