Page 1 of 1
PDF Printing
Posted: Tue Sep 13, 2011 11:59 am
by bsouthuk
Hi All I am in need of desperate help.
I need to be able to print to PDF but for the pdf to automatically save to a users desktop and for the PDF to automatically launch.
I am using the following code:
Code: Select all
put field "CompanyName" & field "Reference" card 2 & ".pdf" into it
replace " " with empty in it
open printing to pdf it & ".pdf"
put it & ".pdf" into target_file
repeat for each item i in Cards2print
print Card i
end repeat
close printing
launch document target_file
The PDF saves to the desktop automatically and then launches when testing before creating the standalone exe but as soon as i create the exe the PDF saves in the folder that the exe is in.
Could some help with my code so that the PDF automatically saves to the desktop?
Your help is most appreciated!
Daniel
Re: PDF Printing
Posted: Tue Sep 13, 2011 12:28 pm
by Klaus
Hi Daniel,
check the "specialfolderpath()" function in the dictionary!
If you don't specify any folder, then the "default" folder is used which is the folder where the EXE "lives"
in a standalone, unless you change/set the "defaultfolder"!
Code: Select all
...
put specialfolderpath("desktop") & "/" into tPDF
put field "CompanyName" & field "Reference" OF card 2 & ".pdf" AFTER tPDF
replace " " with empty in tPDF
## This line will add ANOTHER PDF suffix!
## open printing to pdf it & ".pdf"
open printing to pdf tPDF
repeat for each item i in Cards2print
print Card i
end repeat
close printing
launch document tPDF
...
Hint:
NEVER rely on IT! It may and WILL change when you least exspect it!
So use your own variables to store any info!
Best
Klaus
Re: PDF Printing
Posted: Tue Sep 13, 2011 12:52 pm
by bsouthuk
Fantastic!! Thank you Klaus, much appreciated

Re: PDF Printing
Posted: Tue Sep 13, 2011 6:14 pm
by bsouthuk
Hi Klaus
This works perfectly on my PC but when i have installed my software onto other pcs it does not work. The pdf file does not save to the desktop and it does not open at all.
Can you see what the reason for this is?
Thanks
Daniel
Re: PDF Printing
Posted: Tue Sep 13, 2011 9:17 pm
by Klaus
Hi Daniel,
did you check "PDF Printer" in the standalonebuilder settings "General" for your standalone?
Best
Klaus
Re: PDF Printing
Posted: Tue Sep 13, 2011 9:41 pm
by bsouthuk
Hi Klaus
Yes I did. I have since been able to make it work though by amending the coding slightly. Very strange as even though it now works on all pc's, I dont understand why it only worked on 1 pc before.
Anyway, I changed the code to the following - see if your expertise can see why it now works:
Code: Select all
put specialfolderpath("desktop") & "/" into tPDF
put field "CompanyName" & field "Reference" OF card 2 & ".pdf" into tPDF2
replace " " with empty in tPDF2
put tPDF & tPDF2 into tPDF3
For some reason, I dont think it liked the 'replace " " with empty...' when including the specialfolderpath("desktop") ... But now that I have made into 2 variables it works fine!
Very strange...
Re: PDF Printing
Posted: Wed Sep 14, 2011 2:07 am
by Klaus
Hi Daniel,
ah, yes, my fault, I oversaw this line that will of course also remove spaces
in the path to the users desktop, which may lead to invalid/non existing pathnames!
And yes, using two variables like you did is the correct solution
Best
Klaus
Re: PDF Printing
Posted: Wed Sep 14, 2011 11:29 am
by bsouthuk
Great thanks Klaus