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?
reportBytes = system.report.executeReport(path=‘ReprotName’,project=‘ProjectName’,
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.
You need to make sure that the filepath is correct before running the
writeFile() function. The following worked for me:
data = "test"
Try printing your filepath to see if it matches the format above.
Thank you sir that was the issue had to modify the code to meet that format.
filePath = "\\\\\\serv\\\\dir1\\\\dir2\\\\"
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:
a = "\\\\\\serv\\dir1\\dir2\\"
b = r'\\\serv\dir1\dir2' + '\\'