2 Replies Latest reply: May 15, 2014 10:13 AM by offpiste.reese _ RSS

    Programatically opening a PDF that has a password

    offpiste.reese _



      I am automating Monarch with C# to open PDF files, apply a model and export the data.  The PDF files I am receiving have passwords to open them.  Is there any way to programatically send the password?  I don't see any method in the api to do that.  I am using SetReportFile to open the PDF.  I see that SetPRFFile allows you to specify a password, but not SetReportFile.  Any suggestions would be appreciated.



        • Programatically opening a PDF that has a password
          Data Kruncher

          Hi Dan,


          This was a nice little challenge. I hadn't needed to try this before, and Monarch handled my test solution quite nicely.


          First, to create a secure test PDF I exported the Table from a Classic sample report to a PDF file, specifying an Open password. Then I closed all of the open documents, and opened the new PDF file. Monarch prompted for the password, and I entered it and proceeded through the PDF Import wizard. I then immediately saved the model, and a new project file[/I]. Upon receiving my direction to save the project file, Monarch prompted me that "One or more PDFs require a password. Do you want to encrypt and save the password(s) to the project?" I clicked Yes and saved the project.


          Now the real test: open the project. Monarch opens the secure PDF without prompting me for the required password. Nice!


          So that could be your solution. Save a new project file for your PDF, and then open the project file with your code, instead of opening the PDF file via SetReportFile.


          Will this be an acceptable solution for you?