Issues rendering annotations from pdf to image #293
-
Hi! I have a pdf with 4 annotations/field forms that are filled out on my pdf, and I wanted to convert it to an image, however when I convert it the image no longer contains the filled out values- I'm using python. I've tried specifying it here: render_args = (
bitmap, # the bitmap
page, # the page
# positions and sizes are to be given in pixels and may exceed the bitmap
0, # left start position
0, # top start position
width, # horizontal size
height, # vertical size
0, # rotation (as constant, not in degrees!)
pdfium_c.FPDF_ANNOT, # rendering flags, combined with binary or
)
# Render the page
pdfium_c.FPDF_RenderPageBitmap(*render_args) Any suggestions on why it might not be rendering in the image? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
On the support model example: Make sure to call On the raw API example, you'd need to call I agree the Readme's raw API rendering example is incomplete when it comes to forms. init_forms() pypdfium2/src/pypdfium2/_helpers/document.py Lines 150 to 183 in a584927 get_page() pypdfium2/src/pypdfium2/_helpers/document.py Lines 367 to 379 in a584927 render() pypdfium2/src/pypdfium2/_helpers/page.py Lines 439 to 440 in a584927 |
Beta Was this translation helpful? Give feedback.
On the support model example: Make sure to call
.init_forms()
on the parent pdf before the page is instantiated.On the raw API example, you'd need to call
FPDF_FFLDraw(...)
, which takes anFPDF_FORMHANDLE
and the render args.Setting up the form requires several other APIs, which is somewhat complicated.
The support model should be more straightforward for your use case.
I agree the Readme's raw API rendering example is incomplete when it comes to forms.
The support model's implementation is more exhaustive:
init_forms()
pypdfium2/src/pypdfium2/_helpers/document.py
Lines 150 to 183 in a584927