Git Product home page Git Product logo

pdfjinja's People

Contributors

jenselme avatar mauroeparis avatar rammie avatar yoongkang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pdfjinja's Issues

Can't select radio button

Hi,
I'm not able to select a radio button. My pdf analysis is:

FieldType: Button
FieldName: 4 IP
FieldNameAlt: {{ ip.4 | X }}
FieldFlags: 49152
FieldValue: 5
FieldJustification: Left
FieldStateOption: 5
FieldStateOption: Off

and my python is:

from pdfjinja import PdfJinja

pdfjinja = PdfJinja('test.pdf')
forms = {
    "ip": {
        "8":True
    }
}
pdfout = pdfjinja(forms)
pdfout.write(open('filled.pdf', 'wb'))

What am i doing wrong? Is it supported?

PDFJinja object creation using file stream/object.

Hi, Is there a way to initialize PDFJinja object using file stream/object instead of filepath and name.
I have a scenario where the PDF file is located in an URL which in need to load and file form attributes.

Thanks.

Unchecked checkboxes not exported in output

Hi,
Is there a way to keep checkboxes in output event if they are not checked ?

with thefollowing code my 2 checkboxes are shown and checked :

rendered_pdf = template_pdf({
    'ck1': 'Yes',
    'ck2': 'Yes'})

but using

rendered_pdf = template_pdf({
    'ck2': 'Yes'})

i thought the first checkbox would stay unchecked in te result, but it is not shown at all.

Thanks

Extra Example

Would you be able to put together a simpler example to follow?

pdf not filling in fields

I have a pdf I've created using libreoffice. Once I run the script to generate a new pdf with the values for the fields it's the same pdf form with nothing filled in.

UTF-8 text not being inserted into pdf template

Hi,
Thanks for this great package! I have successfully created a pdf template and populated it with data, but when I try to use Hebrew characters, it fails silently. All placeholders are replaced except those with Hebrew characters.
Script:

from pdfjinja import PdfJinja
import os
from forms.sample_data import data

file_path = os.path.join(os.getcwd(),"forms")
file_path = os.path.join(file_path, "templates")
file = os.path.join(file_path, 'havarat_gemel.pdf')
pdfjinja = PdfJinja(file)
pdfout = pdfjinja(data)
pdfout.write(open('filled.pdf', 'wb'))

PDF File:
havarat_gemel.pdf

Data:

# -*- coding: UTF-8 -*-
true = True
data = {
    "SHEM_GUF_MENAHEL_MAAVIRA"    : "Guf menahel maavira",
    "SHEM_KUPA_MAAVIRA"    : "shem kupa maavira",
    "MISPAR_KUPA_MAAVIRA"    : "mispar kupa maavira",
    "SHEM_KEREN"    : "shem keren",
    "KOD_KEEREN"    : "kod keren",
    "lastName"    : "Golo",
    "firstName"    : "Hdaassa",
    "idNumber"    : "123123123",
    "streetNumber"    : "12/11",
    "street"    : "Revivim",
    "city"    : u'בית שמש',
    "AMIT_PAIL"    : "",
    "AMIT_LO_PAIL"    : true,
    "SUG_HAAVARA_MELO"    : true,
    "SUG_HAAVARA_SCHUM"    : "",
    "SUG_HAAVARA_AD_2007"    : "",
    "SUG_HAAVARA_ME_2008"    : "",
    "SUG_TZVIRA_KOLEL"    : true,
    "SUG_TZVIRA_TAGMULIM"    : "",
    "SUG_TZVIRA_PITZUIM"    : "",
    "SUG_MASLUL_HASHKAA-KOLEL"    : "",
    "SUG_MASLUL_SPECIFIC"    : true,
    "MISPAR_CHESHBON_LEHAAVARA"    : "00000",
    "MISPAR_CHESHBON_MEKABELET"    : "909090",
    "SUG_MEKABELET"    : "hishtalmut",
}

Please help!

xrange NameError

I have been getting this issue with the example code and know it is in issue dealing with the conversion from python 2 to python 3. With xrange being defined as range in python 3. Having trouble figuring out this problem and have run the all python scripts for python 3 support in the main GitHub file. I am also using an anaconda environment in jupyter notebooks which may be causing some issues as well. Any advice would be greatly appreciated.

image

subprocess.Popen call can't find pdftk on Windows

We have been running pdfjinja and have ran into an interesting issue. When calling our python code directly from the command line everything works. However when our code is started by another calling process, in this case ArcGIS Server, it fails on the call to Popen.

If we hard code our path to pdftk into pdfjinja like so, it works.

args = [
r"C:\Windows\SysWOW64\PDFtk Server\bin\pdftk.exe",
self.filename,
"fill_form", "-",
"output", "-",
"dont_ask",
"flatten"
]

I believe it has something to do with the following Python bug, and isn't directly an issue with pdfjinja.
https://bugs.python.org/issue8557

Root cause seems to be that Popen isn't respecting anything on the System PATH variable in Windows.

However, perhaps there is a way around it in pdfjinja? Like perhaps passing down the current env into the process being opened. The issue is a bit of a maintainability nightmare for us.

Additionally, I've found a very similar issue that may be helpful.
https://gis.stackexchange.com/questions/234664/how-to-set-up-geoprocessing-service-to-fill-out-pdf-form-from-within-web-appbuil

Signature got stretched

When we are applying the signature on pdf. it gets stretched and fills the whole box. Can you please let me know how can I maintain the original size of a signature image?

Keep form items editable.

Great package.

I am wondering if there is a way we can keep the fields editable after the output happens.

Right now, the PDF will save but when opening using Adobe Acrobat, you are unable to change the values that are in the PDF.

Is this something that can be done?

Form example for address

Thank you for creating this capability.
What is the format of the key name for the Street Address in the demo form?
address.street is not a valid python key, "address.street" also not valid.
examples shown in example.py

Check box not working

Hi,

I'm having trouble getting check box to be checked. I tried the example, and it will not check the box.

Thanks

Example code for python 3.6 is not working on macOS 10.13.1

I always get the error-code:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pdfjinja.py", line 208, in exec_pdftk
p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 707, in init
restore_signals, start_new_session)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'pdftk'

I installed pdftk (even version 2.02 from here jkraemer/pdf-forms#30) and used the example code in python:

import os

from pdfjinja import PdfJinja
import pypdftk

dirname = os.path.dirname(file)
template_pdf_file = os.path.join(dirname, 'sample.pdf')
template_pdf = PdfJinja(template_pdf_file)

rendered_pdf = template_pdf({
'firstName': 'Faye',
'lastName': 'Valentine',
'address': {
'street': '223B Baker Street',
'apt': '6F',
'city': 'London',
'zipcode': 94455
},
'sig': os.path.join(dirname, 'sig.png'),
'spirit': 'Panda',
'evil': True,
'language': {
'english': True
},
'attachments': [{
'data': os.path.join(dirname, 'attachment.png'),
'text': 'Tux\nFriendly Penguin\nMascot :)',
'dimensions': [100, 200, 400, 400]
}]
})

output_file = os.path.join(dirname, 'output.pdf')
rendered_pdf.write(open(output_file, 'wb'))

Python 3, use range

pages = pages or xrange(filled.getNumPages())

I am using this Lib with Python 3 and it is breaking in this line.

For python 3 use this instead.
pages = pages or range(filled.getNumPages())

Error using Popen in debug mode but no error executing normally

I'm using this library successfully to fill in PDF form values when I execute my program normally (not in debug mode). However, if I execute my application in debug mode inside of my IDE (PyCharm), I get the following stack trace:

File "/Users/me/work/server/venv/lib/python2.7/site-packages/pdfjinja.py", line 220, in __call__ filled = PdfFileReader(self.exec_pdftk(self.rendered)) File "/Users/me/work/server/venv/lib/python2.7/site-packages/pdfjinja.py", line 194, in exec_pdftk p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__ errread, errwrite) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child raise child_exception OSError: [Errno 2] No such file or directory

It appears as though the snippet of code in question is inside pdfjinja.py at line 194:

        p = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        stdout, stderr = p.communicate(fdf)

I've done some googling that points to PIPE being a potential problem with Popen. Here is the blog article:

http://thraxil.org/users/anders/posts/2008/03/13/Subprocess-Hanging-PIPE-is-your-enemy/

Would it be possible to update the exec_pdftk function so that it addresses this?

Again, this only seems to be a problem when running my code inside my IDE in debug mode. Normal execution works just fine. Therefore, this might not be a high priority issue but I thought I'd report it anyway.

Thanks for providing this tool!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.