Skip to main content
New Participant
November 16, 2021
Question

Save Print To location from VB.NET

  • November 16, 2021
  • 2 replies
  • 1259 views

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

This topic has been closed for replies.

2 replies

Brainiac
December 8, 2021

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.

New Participant
December 8, 2021

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. 

Brainiac
December 8, 2021

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.

Karl Heinz  Kremer
Adobe Expert
November 17, 2021
New Participant
December 8, 2021

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

Karl Heinz  Kremer
Adobe Expert
December 8, 2021

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%2FDistiller_WinIntro%2FProgrammatic_control.htm) 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.