# PDF Viewer - Saving Comments/Etc. to the PDF

**URL:** <https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [June 10, 2020, 1:45pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496 "2020-06-10T13:45:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 10, 2020, 1:45pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/1 "2020-06-10T13:45:54Z")

</div>

> [@PDF Viewer Issues - Missing Save button](https://forum.inductiveautomation.com/t/pdf-viewer-issues-missing-save-button/34886/2):
>
> The save button was recently-ish hidden from view, because it doesn’t actually work without buying IcePDF Pro.

@paul-griffith I'm looking to use the pdf viewer component to add comments etc. with the utility panel to a pdf report then save it to the current file path, not save as with a different name. Any suggestions on how to do this, any alternatives if not. If IcePDF Pro is required, where is that installed, on the gateway or every client that needs it? Thanks.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 10, 2020, 3:24pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/2 "2020-06-10T15:24:17Z")

</div>

You would have to purchase and provide an IcePDF Pro .jar on the classpath of every client; ICESoft separated the open-source core of their PDF viewer from their proprietary ‘font-engine’ and PDF write support. However, it looks like ICESoft is no longer selling new copies of IcePDF pro, so it’ s not really an option.  
Within Vision, I don’t think there are a lot of options. The PDF support inside of the web browser module is just whatever Chromium has, and doesn’t have any support for annotation/markup, to my knowledge. You’d have to find some other Java Swing compatible PDF viewer/editor; or install a separate PDF editor on client machines and launch it in an editing mode, which is obviously a much worse user experience than directly editing within Ignition.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 10, 2020, 3:44pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/3 "2020-06-10T15:44:06Z")

</div>

I did see that I can use the pdf viewer to mark up the report then use the print function to print to pdf. It isn’t ideal, but it’s something. Is there anyway to auto feed the file name and path during this process?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 10, 2020, 3:51pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/4 "2020-06-10T15:51:27Z")

</div>

Try exploring the `PrintHelper` object (`${referenceToPDFViewer}.controller.viewModel.printHelper`); specifically it has two methods `org.icepdf.ri.common.PrintHelper#getDocAttributeSet` and `org.icepdf.ri.common.PrintHelper#getPrintRequestAttributeSet` that might be useful to pre-populate information about the print job before the dialog opens.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 10, 2020, 6:24pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/5 "2020-06-10T18:24:05Z")

</div>

I looked at these links, but I have no idea on how to use them.  
[http://www.icesoft.org/wiki/display/PDF/Print+Services](http://www.icesoft.org/wiki/display/PDF/Print+Services)  
[http://res.icesoft.org/docs/icepdf/latest/viewer/index.html](http://res.icesoft.org/docs/icepdf/latest/viewer/index.html)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 10, 2020, 6:34pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/6 "2020-06-10T18:34:58Z")

</div>

Filename in particular looks like it should be set by [`DocumentName`](https://docs.oracle.com/javase/10/docs/api/javax/print/attribute/standard/DocumentName.html) - so setting it each time the file path changes would be something like:

```python
if event.propertyName == "filePath":
	from javax.print.attribute.standard import DocumentName, JobName
	printHelper = event.source.controller.viewModel.printHelper
	docAttributes = printHelper.docAttributeSet
	docAttributes.add(DocumentName("someDocumentName", system.util.getLocale()))

	printAttributes = printHelper.printRequestAttributeSet
	printAttributes.add(JobName("someJobName", system.util.getLocale()))

```

I have _no idea_ if this will work. I tested locally with the built-in-to-Windows ‘Microsoft Print to PDF’ driver, and it didn’t; some google suggests that it might just not be possible to prepopulate a filename for that dialog, which is a shame. Other print to PDF drivers may behave differently.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 10, 2020, 7:27pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/7 "2020-06-10T19:27:14Z")

</div>

Appreciate the script, but it doesn’t work like you mentioned. The save function pulls in the file name of the current pdf shown and would be the ticket. It is a total bummer that it can’t be used or even purchased for use. I can still use the print to PDF driver, but it would rely on the user selecting the correct save location and filename 😅

I also tried an external button with

```auto
job = system.print.createPrintJob(event.source.parent.getComponent('PDF Viewer'))
job.setPrinterName('Microsoft Print to PDF')
job.print()

```

It worked but the whole component was saved as an image in pdf format

Any way to get the pdf as bytes from the component and save that

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 11, 2020, 1:02pm UTC](https://forum.inductiveautomation.com/t/pdf-viewer-saving-comments-etc-to-the-pdf/35496/8 "2020-06-11T13:02:30Z")

</div>

@paul-griffith  
Using this snippet isn’t what I wanted, but it works pretty well. I have an edit button that opens the pdf in adobe where the user can mark up the pdf and save without entering any file paths or names. It is pretty quick and much less painful than the print to pdf method.

```auto
filePath = event.source.parent.getComponent('PDF Viewer').filePath
system.util.execute(["C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe", filePath])

```

One last question, is there a way to refresh the selected pdf without selecting another file then come back to the one edited to show the changes?  
**EDIT** To refresh I just set the file path to blank then set it back to what it was
