# Parsing pdf file (not viewing) in Ignition

**URL:** <https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296>\
**Category:** General Discussion\
**Created:** [November 6, 2014, 12:57pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296 "2014-11-06T12:57:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fabrice\_CHAVEROT](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Fabrice\_CHAVEROT](https://forum.inductiveautomation.com/u/Fabrice_CHAVEROT)\
**Post date:** [November 6, 2014, 12:57pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/1 "2014-11-06T12:57:32Z")

</div>

Is it possible to parse pdf files with a python script in ignition with a 3rd party Library like pdfminer or  
Jython + pdfbox ?

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [November 6, 2014, 2:33pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/2 "2014-11-06T14:33:44Z")

</div>

Not trivial, but possible.

You could create a module with the Ignition SDK adding the pdfbox jars to it and then, call the functions from jython code.

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [November 6, 2014, 2:38pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/3 "2014-11-06T14:38:57Z")

</div>

A quick view on PDF Miner (I used pdfbox, not PDF Miner) seems to be a pure python 2.4 library (not a wrapper from CPython, like anothers third party librarys that are not compatible with Ignition), so, if you have Ignition 7.7.x, you could add this as a third-party python library. More info in [inductiveautomation.com/forum/vi … 12153&f=50](http://inductiveautomation.com/forum/viewtopic.php?p=46249&t=12153&f=50)

Regards,

---

<div class="post-metadata">

**Author:** ![Fabrice\_CHAVEROT](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Fabrice\_CHAVEROT](https://forum.inductiveautomation.com/u/Fabrice_CHAVEROT)\
**Post date:** [November 6, 2014, 4:05pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/4 "2014-11-06T16:05:39Z")

</div>

I have just tried exactly what you describe before with pdfminer  
I have added pdfminer folder in pylib (…\Inductive Automation\Ignition\user-lib\pylib)  
Ignition recognize the new python library (I have a message wich inform me Ignition has found a new library in pylib)

I have added without problem the following sample script on a button:

from pdfminer.pdfparser import PDFParser  
from pdfminer.pdfdocument import PDFDocument  
from pdfminer.pdfpage import PDFPage  
from pdfminer.pdfpage import PDFTextExtractionNotAllowed  
from pdfminer.pdfinterp import PDFResourceManager  
from pdfminer.pdfinterp import PDFPageInterpreter  
from pdfminer.pdfdevice import PDFDevice

# Open a PDF file.

fp = open(‘C:\PyhtonScripts\HelloWorld.pdf’, ‘rb’)

# Create a PDF parser object associated with the file object.

parser = PDFParser(fp)

# Create a PDF document object that stores the document structure.

# Supply the password for initialization.

document = PDFDocument(parser, password)

# Check if the document allows text extraction. If not, abort.

if not document.is\_extractable:  
raise PDFTextExtractionNotAllowed

# Create a PDF resource manager object that stores shared resources.

rsrcmgr = PDFResourceManager()

# Create a PDF device object.

device = PDFDevice(rsrcmgr)

# Create a PDF interpreter object.

interpreter = PDFPageInterpreter(rsrcmgr, device)

# Process each page contained in the document.

for page in PDFPage.create\_pages(document):  
interpreter.process\_page(page)

But unfortunately I have a Java run time error:

ERROR [ActionAdapter-MainThread] Error executing script for event:&nbsp;`actionPerformed`  
on component:&nbsp;`Button 3`.  
Traceback (most recent call last):  
File “event:actionPerformed”, line 5, in   
File “C:\Users\fabrice.chaverot.ignition\cache\gwlocalhost\_8088\_8043\_main\C0\pylib\pdfminer\pdfinterp.py”, line 8, in   
from cmapdb import CMapDB, CMap  
File “C:\Users\fabrice.chaverot.ignition\cache\gwlocalhost\_8088\_8043\_main\C0\pylib\pdfminer\cmapdb.py”, line 24, in   
from encodingdb import name2unicode  
File “C:\Users\fabrice.chaverot.ignition\cache\gwlocalhost\_8088\_8043\_main\C0\pylib\pdfminer\encodingdb.py”, line 5, in   
from glyphlist import glyphname2unicode  
java.lang.ClassFormatError: Invalid method Code length 85551 in class file pdfminer/glyphlist$py

```
at java.lang.ClassLoader.defineClass1(Native Method)

at java.lang.ClassLoader.defineClass(Unknown Source)

at org.python.core.BytecodeLoader$Loader.loadClassFromBytes(BytecodeLoader.java:119)

at org.python.core.BytecodeLoader.makeClass(BytecodeLoader.java:37)

at org.python.core.BytecodeLoader.makeCode(BytecodeLoader.java:67)

at org.python.core.imp.createFromSource(imp.java:353)

at org.python.core.imp.loadFromSource(imp.java:578)

```

…

---

<div class="post-metadata">

**Author:** ![pdibenedetto](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdibenedetto/32/6364_2.png) [@pdibenedetto](https://forum.inductiveautomation.com/u/pdibenedetto)\
**Post date:** [November 6, 2014, 4:24pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/5 "2014-11-06T16:24:11Z")

</div>

Mmmm… pretty strange… I’m not an expert but seems that java classes must not exceed a determinated size (according to jvm specifications, a class may not exceed 64KB) and maybe Ignition dynamically compile the python code (jython) to a java class and if the python code it’s too big, not work…

I can’t think a quickly workaround to this… maybe a more expert jython users or some guys from IA could help you…

You still have the pdfbox approach…

Regards,

---

<div class="post-metadata">

**Author:** ![Fabrice\_CHAVEROT](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@Fabrice\_CHAVEROT](https://forum.inductiveautomation.com/u/Fabrice_CHAVEROT)\
**Post date:** [November 6, 2014, 7:01pm UTC](https://forum.inductiveautomation.com/t/parsing-pdf-file-not-viewing-in-ignition/9296/6 "2014-11-06T19:01:50Z")

</div>

Yes I am going to look at the pdfbox approach, I’ve just downloaded the sdk. Thanks for your advices, Regards
