# Saving PDF with no user prompt. system.file.wirteFile()

**URL:** <https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [June 19, 2022, 2:42pm UTC](https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929 "2022-06-19T14:42:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Smtih](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Brandon\_Smtih](https://forum.inductiveautomation.com/u/Brandon_Smtih)\
**Post date:** [June 19, 2022, 2:42pm UTC](https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929/1 "2022-06-19T14:42:26Z")

</div>

I am looking to save a PDF to a file location without a user prompt. When Adding .pdf to the end of file  
error occurs. Is there a solution or way of changing so it saves the file as a pdf?

Using  
reportBytes = system.report.executeReport(path=‘ReprotName’,project=‘ProjectName’,  
fileType=‘pdf’)

To make PDF file.

I was able to do so using system.file.writeFile(filePath + fileNmae,reportBytes) then  
I found that it was writing to a text file. When I added a file extension of .pdf it gave  
me the below error. Without the PDF extension it has no error and creates the file.

IOError: File ‘\serv\folder1\folder2\filename.pdf’ doesn’t exist or isn’t a file.

Thanks

---

<div class="post-metadata">

**Author:** ![obober](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/obober/32/67865_2.png) [@obober](https://forum.inductiveautomation.com/u/obober)\
**Post date:** [June 21, 2022, 9:00pm UTC](https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929/2 "2022-06-21T21:00:13Z")

</div>

Hi Brandon,

You need to make sure that the filepath is correct before running the `writeFile()` function. The following worked for me:

```auto
data = "test"
system.file.writeFile("C:\\Users\\obober\\Documents\\test.pdf", data)

```

Try printing your filepath to see if it matches the format above.

---

<div class="post-metadata">

**Author:** ![Brandon\_Smtih](https://avatars.discourse-cdn.com/v4/letter/b/0ea827/32.png) [@Brandon\_Smtih](https://forum.inductiveautomation.com/u/Brandon_Smtih)\
**Post date:** [June 21, 2022, 9:47pm UTC](https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929/3 "2022-06-21T21:47:16Z")

</div>

Thank you sir that was the issue had to modify the code to meet that format.

`filePath = "\\\\\\serv\\\\dir1\\\\dir2\\\\"`

Much appreciated.

---

<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 21, 2022, 10:41pm UTC](https://forum.inductiveautomation.com/t/saving-pdf-with-no-user-prompt-system-file-wirtefile/60929/4 "2022-06-21T22:41:56Z")

</div>

If you prefix the string literal with `r`, you don’t need quite as much escaping (although Python won’t allow a string to end in backslashes without slight hurdles); that is, these two both create the exact same string:

```auto
a = "\\\\\\serv\\dir1\\dir2\\"
b = r'\\\serv\dir1\dir2' + '\\'

```
