Questions tagged [pdfrw]

pdfrw is a pure-Python library that reads and writes PDF files

pdfrw is developed on github, and installable from PyPI. It works with Python 2 and 3, and has an extensive set of examples.

80 questions
3
votes
1 answer

How to Extract Image from PDF using PDFrw

I am using PDFrw and one of its example to extract the only image in a PFD file and save that image to a PNG or JPEG file. The code is too challenging for me to understand, what parameters should I pass to find_objects? from pdfrw.objects import…
Nyxynyx
  • 61,411
  • 155
  • 482
  • 830
2
votes
1 answer

How to merge pages of a pdf file into a single vertically combined page with python

I have tried merge_page method in pypdf and pdfrw but they stact one page over other, how do I proceed? below code which i tried, similar with both modules from pdfrw import PdfReader, PdfWriter, PageMerge def…
V Falcon
  • 25
  • 4
2
votes
1 answer

Writing a Python pdfrw PdfReader object to an array of bytes / filestream

I'm currently working on a simple proof of concept for a pdf-editor application. The example is supposed to be a simplified python script showcasing how we could use the pdfrw library to edit PDF files with forms in them. So, here's the issue. I'm…
2
votes
2 answers

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

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…
2
votes
1 answer

How to edit checkboxes and save changes in an editable pdf using the python pdfrw library?

I am trying to edit checkboxes on an editable pdf according to user input. I am able to edit text fields using pdfrw as shown here: https://bostata.com/how-to-populate-fillable-pdfs-with-python/ #! /usr/bin/python import os import…
2
votes
0 answers

Keep filled fields in PDF after inserting image - ReportLab and pdfrw

I have a fillable PDF and I have filled out some of the fields and saved it. I am able to add an image to the PDF using pdfrw and ReportLab; however, when the PDF is saved, the data entered into the fillable fields has disappeared. Can anyone point…
campo
  • 624
  • 5
  • 15
2
votes
0 answers

How to set the position of an image in reportlab using pdfrw?

I'm using reportlab to generate reports. I can define the creation process in four steps: 1) get the data via API, 2) filter the data, 3) generate the graphics with matplotlib and 4) insert information in PDF with reportlab. I found in this (thanks…
Murilo Sitonio
  • 270
  • 7
  • 30
2
votes
3 answers

Scraping PDF data into Excel *absolute beginner*

This is literally day 1 of python for me. I've coded in VBA, Java, and Swift in the past, but I am having a particularly hard time following guides online for coding a pdf scraper. Since I have no idea what I am doing, I keep running into a wall…
kidusk
  • 21
  • 1
  • 2
2
votes
3 answers

How to correctly decode/encode file names when using `pdfrw` to add metadata?

I'm writing a script that will add PDF metadata to a list of PDFs. My problem is dealing with PDFs with names that have certain characters in them -- in the example I tried, the name had an "en dash" in it, but I'm sure in the future (I don't…
jesskts
  • 21
  • 3
1
vote
0 answers

How to edit, radio button fillable PDF with PDFrw

for a project I will need to autofill over 1000 pdf forms and in the form there is radio button: I found a code: def radio_button(annotation, value): for each in annotation['/Kids']: # determine the export value of each kid keys =…
1
vote
2 answers

Reportlab and pdfrw with matplotlib imshow() error in python3

I've recently updated some code which worked in python2 to python3 and encountered an error using reportlab in conjunction with pdfrw and matplotlib imshow(). Can someone reproduce this error in py3? Also I am uncertain whether it is a reportlab…
Martin
  • 63
  • 5
1
vote
0 answers

How to add a signature into a specific field in a PDF document using Python?

I tried adding an image into a PDF in a specific field in a particular position, I also referred to another post in the community (How to add image to PDF file in Python?), This code allows us to overlay the entire Image over PDF, but we want to…
1
vote
4 answers

Python - How to properly fill a multiline text field in PDF form using pdfrw?

I'm filling a PDF form using python with pdfrw. I have no problem with any single line text field in the form. But when I try to fill a multi-line textfield it doesn`t render properly, it ignores break lines. This is part of my…
David Mendez
  • 157
  • 12
1
vote
1 answer

Why doesn't Preview on Mac respect the "read only" flag in PDF files?

I'm working on a django project using pdfrw to fill a fillable pdf form. I'm setting the Ff = 1 flag in order to make the fields read-only. for annotation in template_path.Root.AcroForm.Fields: # the code goes here …
Sebastian M
  • 471
  • 1
  • 4
  • 20
1
vote
0 answers

Can't update/displayed PDF Form with python pdfrw lib

I have some questions about pdf form filling. First let me give you some context : i am trying to make a 100% python pdf form filling service, and for that i am using the pdfrw lib. Here is my code, it takes as arguments a pdf path and data_dict…
andupuis
  • 21
  • 2