cyxstudio Posted March 24, 2019 Posted March 24, 2019 Hi i am currently using cutepdf which is a program that acts as a printer to print into a pdf file. However everytime i do so a SaveFileDialog form pops up and i have to manually control where i wan to save my pdf. I would like this process to be automatic into a pre selected destination. I tried a few hours of googling to no avail so i hope someone can point me in the right direction Apart from simulating clicks to handle the SaveFileDialog, does autoit have the capability to create a program like cutepdf that can act as a printer and print into a pdf file?
FrancescoDiMuro Posted March 24, 2019 Posted March 24, 2019 (edited) @cyxstudio AutoIt has several UDFs through which you can create your PDF file directly from your script, or by using a third-part program like PDFCreator. You can find more about PDF UDFs here Edited March 24, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
Jfish Posted March 25, 2019 Posted March 25, 2019 (edited) You are trying to suppress the dialog to save the file on a shell execute for printing. I played around for a while and found a bit of a hack to do this. I have not played around with it too much for multiple files but you could probably move them and rename then as part of the script to solve that issue (edit: b/c I think your new printer will save them all with the same filename so you can save them to a temp location and rename/move them). It basically requires you to create a custom printer on Windows with the Windows Print to PDF print driver. But if you do that I can confirm you can print to the file location without the save dialog: #include <WinAPISys.au3> $result=_WinAPI_SetDefaultPrinter ( "jfishprinter" ); setup with https://support.microsoft.com/en-us/help/2528405/how-to-print-to-file-without-user-intervention $file=@ScriptDir&"\testfile.txt" ; whatever file you are trying to convert to the pdf Func _FilePrint($sFilePath, $iShow = @SW_HIDE) ; from Autoit's UDF for printing from a file Return ShellExecute($sFilePath, 2, @WorkingDir, "print", @SW_HIDE) EndFunc ;==>_FilePrint _FilePrint($file) The wizard to set the printer will vary a bit from the instructions in that link since it is a bit dated ... but you should be able to figure it out. Edited March 25, 2019 by Jfish Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now