# Create Pdf of a Screen

**URL:** <https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023>\
**Category:** Ignition\
**Created:** [March 13, 2013, 11:33am UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023 "2013-03-13T11:33:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 13, 2013, 11:33am UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/1 "2013-03-13T11:33:47Z")

</div>

Hi!

I need to make a printscreen and save it as a pdf file.

I have tried “[color=#0000FF]system.print.printToImage(event.source.parent, “Screen.jpg”)[/color]” to generate an image.

And also I have tried this code:

[color=#0000FF]windowName = system.nav.getCurrentWindow()  
try:  
rc = system.gui.getWindow(windowName).getRootContainer()  
job = system.print.createPrintJob(rc)  
job.setMargins(0.5)  
job.showPageFormat = 0  
job.orientation = system.print.LANDSCAPE  
job.print()  
except:  
# window not opened  
pass[/color]

If I have the “Pdf Creator” as primary printer, it works. But I would like to ask if there is other way to generate a pdf file without using the “Pdf Creator”??

Maybe with “[color=#0000FF]fpmi.system.execute()[/color]” or importing a library…

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 13, 2013, 10:24pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/2 "2013-03-13T22:24:44Z")

</div>

I turned the free java library iText into a module. Then used their API to take all the components on the screen and turn it into a PDF.

[http://itextpdf.com/](http://itextpdf.com/)

Good luck.

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 14, 2013, 3:04pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/3 "2013-03-14T15:04:09Z")

</div>

Hi Jonathan,

I have tried to import an external library like you say but it doesn’t compile and I’m trying to make it work…

I have tried this one but it doesn’t seem to work:  
[blog.pythonlibrary.org/2012/ … n-library/](http://www.blog.pythonlibrary.org/2012/07/10/an-intro-to-pyfpdf-a-simple-python-pdf-generation-library/)

Is there a chance of sharing a sample code and the module you used with us?? It would be great!!

Thanks again!

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 14, 2013, 3:44pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/4 "2013-03-14T15:44:45Z")

</div>

you cannot just use the import in the script language. you have to first create a Ignition module that includes the jar files. then send the module to inductive automation to be signed and then you import the module into the Ignition gateway webpage. at that point you will then have access to the jar library imports.

1. download the itext jar
2. in the same location as the itext jar create a file called module.xml
3. in the module.xml file place the following text with the relevant information filled out. if there more than one jar repeat the jar scope line for each jar

```auto
<?xml version="1.0" encoding="UTF-8"?>
<modules>
	<!-- A module xml file can define multiple modules -->
	<module>
		<id>itext</id>
		<name>iText</name>
		<description>Adds the iText java library to the client, gateway, and designer scopes.</description>
		<version>Version of the Module goes here</version>
		<requiredignitionversion>version of ignition goes here</requiredignitionversion>
		<requiredframeworkversion>4</requiredframeworkversion>
		<freemodule>true</freemodule>
		<jar scope="DCG">itextpdf.jar</jar>
		<depends scope="G">fpmi</depends>
	</module>
</modules>
```

1. Zip the module.xml file and all the jar files together.
2. rename the extension on the zipped file to modl
3. send the module into inductive automation for signing
4. take the signed module you receive back and import it into the Ignition gateway

hope this helps

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 14, 2013, 4:51pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/5 "2013-03-14T16:51:55Z")

</div>

Hi Jonathan,

Thanks you for all the help. I have followed all your steps, but now I’m stuck trying to register the module I have created.

1. I have downloaded the latest “itext” file and uncompress all the jars in a Folder.
2. I have created the module.xml with the code:

[color=#0000FF]\<?xml version="1.0" encoding="UTF-8"?\>

 itext iText Adds the iText java library to the client, gateway, and designer scopes. 1.0.0 7.4.0 4 itextpdf-5.4.0.jar itextpdf-5.4.0-javadoc.jar itextpdf-5.4.0-sources.jar itext-pdfa-5.4.0.jar itext-pdfa-5.4.0-javadoc.jar itext-pdfa-5.4.0-sources.jar itext-xtra-5.4.0.jar itext-xtra-5.4.0-javadoc.jar itext-xtra-5.4.0-sources.jar [/color]
1. Finally, I have compressed all in a rar file, and named it “PDF\_Creator.modl”.

Now I’m trying to register the module at the Ignition Website → Configuration → Modules → Install a module… but appears the error “Error loading the module. See log for details”. I can’t find the log anywhere…

Can you help me in these final step? Thanks again.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3a16bfe74fb0538a3c8634f68b4a6a53a2e5271c.png)

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 14, 2013, 5:10pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/6 "2013-03-14T17:10:46Z")

</div>

did you fill out the highlighted parts in the xml file?  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/d/dcb7111e0d670602979c29cd6dfbb6dc4e14cd06.PNG)

when you download the file from itext you probably need to unzip it to get the jar files.

you cannot put itext.zip in the scope line you need to put the jar file there “jarfilename.jar”

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 14, 2013, 5:22pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/7 "2013-03-14T17:22:01Z")

</div>

Hi Jonathan,

I realized of what you said after I wrote the reply! I have actualized my post with the unzipped jars, but it doesn’t change the result at the Ignition Website!! Can you tell where is the log where I can see the details of the error?? In the Console doesn’t appear nothing…

Thanks again!!

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 14, 2013, 5:36pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/8 "2013-03-14T17:36:29Z")

</div>

did you send the module in to get signed. if not you need to get a developer license key.

you can register as a developer her

[https://www.inductiveautomation.com/developers/register](https://www.inductiveautomation.com/developers/register)

you can log in to get your module signed here

[https://www.inductiveautomation.com/developers/login](https://www.inductiveautomation.com/developers/login)

I am not sure were to look if your console is not showing any errors.

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 14, 2013, 6:30pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/9 "2013-03-14T18:30:46Z")

</div>

Hi again,

I have tried to Login at the “Developer Portal Login” and it says that I don’t have sufficient privileges to Loggin… what can I do with that?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://forum.inductiveautomation.com/u/Jonathan)\
**Post date:** [March 14, 2013, 8:33pm UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/10 "2013-03-14T20:33:40Z")

</div>

register as a developer first. you the top link i posted.

---

<div class="post-metadata">

**Author:** ![r.dominguez](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@r.dominguez](https://forum.inductiveautomation.com/u/r.dominguez)\
**Post date:** [March 18, 2013, 9:53am UTC](https://forum.inductiveautomation.com/t/create-pdf-of-a-screen/6023/11 "2013-03-18T09:53:17Z")

</div>

Hi again,

At last I made it!!

The key to register the modl in Gateway is: register as a developer, be careful with the tabulations in the xml file and use the example of Jonathan changing only the name of your jar. And then create the script using the names of your imports:

[color=#0000FF]import com.itextpdf.text.Document  
my\_file = com.itextpdf.text.Document()[/color]

Thanks again for all the support you have given me!
