Save Print To location from VB.NET
Copy link to clipboard
Copied
Hello,
We have a VB.NET application that opens PDFs for editing and a feature I am working on is using the Print To function to save selected pages to a new PDF, but we do not want the user to dictate where the file gets store. So what we want is to detect the Print To of the open PDF and control the actions of naming the file in a specific folder without the user seeing it happen. All they shouold see is a message that says the selection was saved.
Is this possible?
Thank you,
Anthony
Copy link to clipboard
Copied
Take a look here for a way to prevent the save dialog: https://khkonsulting.com/2013/01/prevent-the-save-dialog-when-printing-to-the-adobe-pdf-printer/
Copy link to clipboard
Copied
Thank you. My application opens PDFs and it is from those files that I want to force the Print To function to save to a specific location. This location is static to the application, but the user should not be navigating to this location to make updates. The application serves as the only method for creation and maintenance.
From my application I am using Process.Start to open the PDF and I am using a watcher for subsequent edits. I do that because the files on the server are copied down from a secure server and the saves on the local copy are then pushed back to the server so all is in sync.
Ths code:
Process.Start(sFileName)
'Add the file to the Watch file list.
WatcherFileList_Add(sFileName)
MasterWatcher = New FileSystemWatcher(Path.GetDirectoryName(sFileName), Path.GetFileName(sFileName).Trim)
MasterWatcher.EnableRaisingEvents = True
MasterWatcher.NotifyFilter += NotifyFilters.Attributes
MasterWatcher.NotifyFilter += NotifyFilters.Size
MasterWatcher.NotifyFilter += NotifyFilters.LastAccess
MasterWatcher.NotifyFilter += NotifyFilters.LastWrite
AddHandler MasterWatcher.Changed, AddressOf WatcherSave
Thread.Sleep(StartUp.nSleep)
'start monitoring the file to see if it is still open or not
While StartUp.OpenFileTest(sFileName)
'pause for a time to ease CPU usage
Thread.Sleep(StartUp.nSleep)
Application.DoEvents()
End While
MasterWatcher.EnableRaisingEvents = False
Thank you
Copy link to clipboard
Copied
In your application, you need to manipulate the registry as indicated in the Acrobat API documentation (linked to from my article, but unfortunately moved by Adobe, the new link is here: https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%... before you issue your print command. Make sure you also look at Kevin's comment on my blog post.
How this exactly works in your application is something you need to figure out. I provided sample code that should get you started, but how to do that in VB.NET is not something I am familiar with.
Copy link to clipboard
Copied
You should under no circumstances be printing PDF to PDF. There is a better way in almost every case. To make a new PDF from selected pages, use the Acrobat Pro API to copy pages to a new document.
Copy link to clipboard
Copied
To be clear, this is a case where a person selects multiple pages in one PDF and then selects Print To or Save to a new PDF.
Copy link to clipboard
Copied
Thanks, that's what I guessed. And this is absolutely the wrong way to get a new PDF with a selection of pages, in every case. Please see my suggested solution.

