# Save reports as pdf under different names

**URL:** <https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938>\
**Category:** Ignition\
**Created:** [May 7, 2018, 6:28am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938 "2018-05-07T06:28:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 7, 2018, 6:28am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/1 "2018-05-07T06:28:03Z")

</div>

I found this code on the user manuel. but i want to save each report on the date when it’s saved, but i only can choose one name.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/39d0f2a4a91af75a4d1e6296d8c3b9153dd3c643.PNG)

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [May 7, 2018, 11:49am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/2 "2018-05-07T11:49:18Z")

</div>

> d = system.date.format(system.date.now(),"MM-dd-yyyy hh-mm-ss")  
> reportViewer.saveAsPDF(str('MyReport-'+d))

---

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 14, 2018, 6:21am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/3 "2018-05-14T06:21:49Z")

</div>

Great Thanks for the help!

---

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 14, 2018, 7:11am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/4 "2018-05-14T07:11:51Z")

</div>

Now i want to save it automatically when a bit is activeted.  
under a spicial path so i tought to do it this whey but it gives errors.  
 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/2/2680898e02d7a2dbe63fd6332f0727ae7ab0e6f1.PNG)

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [May 14, 2018, 2:24pm UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/5 "2018-05-14T14:24:42Z")

</div>

What is the error? For starters you will need a colon at the end of line 1 and you will need to indent everything underneath. And if “Essen/Extruder Laminator/TEST/opslaan” is a tag then you will need to read the tag value.

---

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 18, 2018, 7:09am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/6 "2018-05-18T07:09:07Z")

</div>

It says nothing, but nothing is happening. so i don’t know what i do wrong.

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [May 18, 2018, 1:56pm UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/7 "2018-05-18T13:56:44Z")

</div>

Did you implement the changes I suggested? If so, can you post the new code?

---

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 24, 2018, 12:54pm UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/8 "2018-05-24T12:54:55Z")

</div>

yes i did the chances, this is the script that i have now.  
i doesn’t give an error it just don’t save it

#Saves the file as a PDF to a user selected location.  
#The file selection window defaults to a name of “Daily Report”  
tagValue= “Essen/Extruder Laminator/Status/E\_EL1\_Einde afkapcyclus”

if tagValue != 0:  
reportViewer = event.source.parent.getComponent(‘Report Viewer’)  
d = system.date.format(system.date.now(),“MM-dd-yyyy”)  
reportViewer.saveAsPDF(str('parameters '+d))  
filepath = (“C:Gebruikers\jubstudent01\ignition”)

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [May 24, 2018, 1:36pm UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/9 "2018-05-24T13:36:02Z")

</div>

Where is the script executed? It needs to be executed from a GUI element (like a button) to work. you can’t execute it on a tag change f.e., as that doesn’t have access to the gui elements.

Next, there are some weird things about your code:

This will just store given string under the variable “tagValue”, not its value

```auto
tagValue= "Essen/Extruder Laminator/Status/E_EL1_Einde afkapcyclus"

```

to read a tag, you need to call a `system` method:

```auto
tagValue = system.tag.read("Essen/Extruder Laminator/Status/E_EL1_Einde afkapcyclus").value

```

The `filePath` you set is just a loose variable, you don’t seem to use it anywhere. Besides, it uses backslashes, which are escape characters in Python (f.e. `\n` means newline). You should either escape your backslashes `\\` or use forward slashes (Python should translate it correctly to backslashes for Windows).

When I fix those things, the rest of the code seems to work.

---

<div class="post-metadata">

**Author:** ![dgoetschalckx](https://avatars.discourse-cdn.com/v4/letter/d/67e7ee/32.png) [@dgoetschalckx](https://forum.inductiveautomation.com/u/dgoetschalckx)\
**Post date:** [May 25, 2018, 11:30am UTC](https://forum.inductiveautomation.com/t/save-reports-as-pdf-under-different-names/17938/10 "2018-05-25T11:30:04Z")

</div>

it still doesn’t save the file. is the filepath needed to be linked to the server or is it also possible to save it at your PC
