Announcement

Collapse
No announcement yet.

File Menu Expiration Date & Open PDF's that have a password

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • File Menu Expiration Date & Open PDF's that have a password

    I use the basic features of AMS and have not mastered any scripts, etc. so what I need may beyond what I can do without scripting.

    I am creating a DVD file menu that provides a point and click interface to open PDF documents; When the AMS program is executed, I need to be able to compare the current system date against a pre-determined date (i.e. say January 1, 2016) and if the current date is past January 1, 2016--the file menu does not appear but a dialog box that states that "the documents are no longer valid, please contact me" and the user would simply click the ok button and the program terminates.

    To keep the user from opening the PDF's directly in Windows explorer after the file menu expiry date, I thought that I would password protect the PDF's. What I have not been able to figure out is how to have AMS "pass" the password to the PDF reader program so that the password can remain unknown to the end user (i.e. I know there are hacking tools that could get the password from the AMS executable). Is there anyway to "pass" the pdf password to the pdf reader so that the AMS file menu program can open the PDF just as it would when there is no password in the PDF? This request may be impossible...but I thought I would ask anyway.

    Thank you for any advice......JimC
    Last edited by Waldo; 08-21-2015, 11:41 AM. Reason: Correct typo

  • #2
    Originally posted by Waldo View Post
    Is there anyway to "pass" the pdf password to the pdf reader so that the AMS file menu program can open the PDF just as it would when there is no password in the PDF? This request may be impossible...but I thought I would ask anyway.
    It depends on the PDF viewer you are using. Assuming that you are using Foxit PDF Reader, the command line it accepts is as follows:

    Click image for larger version

Name:	SCRN-2015-08-21-01.png
Views:	1
Size:	14.5 KB
ID:	284333

    In other words, you would pass the path to the document, then a space, then "/pwd " followed by the password. For example:
    Code:
    Shell.Execute("AutoPlay\\Docs\\FoxitReader.exe", "open", "AutoPlay\\Docs\\sample.pdf /pwd MySecretPassword", "", SW_SHOWNORMAL, false);
    Of course, if you use a different PDF viewer, the syntax would most certainly be different - check the documentation.

    Ulrich

    Comment


    • #3
      Ulrich----thank you so much for the response. This definitely gets me started. I have been trying to find it this was possible to do what I need with Adobe' default reader program as this is the program that will be on the end user's PC. Jim

      Comment


      • #4
        Ulrich,
        I have a follow-up question. I am so new at all of this--so hopefully this is not a "stupid" question.

        Do you know if any of PDF reader programs can be run from memory to display a PDF without the PDF program actually being installed on the end users PC? The reason I inquire is that I have been told to "make this work" regardless of the PDF Reader installed on the end user's PC.

        How to discern which PDF reader the end user has installed and then pass the correct command line for the installed PDF viewer to open a password protected PDF is way beyond my skillset. From my googling, it appears that one cannot view a PDF from "memory" and the end user must actually have some type of "pdf reader" software installed on their PC. I hope that I am wrong.

        Is there any other file type of file that could be used to accomplish the objective? Thank you. JimC

        Comment


        • #5
          You can bundle a stand-alone PDF reader with your project. Foxit Reader and SumatraPDF don't require installation, and can be run from the command line. (I am not sure that Sumatra can handle password protected documents.) If you bundle the reader, you can open all your files with it. If you look up the default PDF reader on the user's computer and compare it against a list of known programs, you may also be able to execute the proper command for that specific program - but I am not sure that it is worth the trouble.

          Ulrich

          Comment


          • #6
            Ulrich---thank you for your kindness and advice---both are greatly appreciated. All the best. JimC

            Comment


            • #7
              Ulrich--thanks for your continued patience.

              I decided to use Foxit Reader for my application---but I can't seem to locate the standalone "exe" file on their site---the exe file I downloaded wants to "install" the reader on the user PC and not just open password protected PDF. I have poked around Foxit's site for quite a while, but I just can't seem to find a "self-contained / standalone version" that will open the password protected PDF without prompting the end user to install it.

              Could it be that this "standalone" application is not available for download on Foxit's website but some other website? I apologize if I have missed the obvious---as I am really trying to learn as I go with this project---but I may have fallen into the "stupid" ditch along the way.

              Thank you. JimC
              Last edited by Waldo; 08-27-2015, 02:57 PM. Reason: fixed two typos

              Comment


              • #8
                Hi Jim,

                Once installed, you can copy the reader executable and run it elsewhere. However, the current release of Foxit has grown considerably. From what I saw, I believe that they have added edit capabilities for PDF documents. If you use an older release with less features (but still perfectly able to display a PDF document), you'll see that the program file is substantially smaller. For comparison, the current release (7.20) is about 42 MB, while the executable from release 3.1 is just 3.46 MB, and release 4.2 is 4.34 MB in size.

                Please note that, if you use version 3.1, the command line argument for the password was still "-ps", while 4.2 (and newer) use "-pwd".

                You can download these older releases from my server, where I have placed them temporarily:
                Foxit Reader 3.1
                Foxit Reader 4.2

                I hope this helps.

                Ulrich

                Comment


                • #9
                  Ulrich,
                  Thanks again for your help. I am getting closer. I elected to use the 4.2 Foxit Version. When I use the script you provided, as modified below:

                  Code:
                  Shell.Execute("C:\\Users\\jcc.KWGD\\Documents\\AutoPlay Media Studio 8\\Projects\\Copy of My Project_100\\Docs\\Foxit Reader 4.2.exe", "open", "C:\\Users\\jcc.KWGD\\Documents\\AutoPlay Media Studio 8\\Projects\\Copy of My Project_100\\Docs\\Password_test.pdf /pwd test", "", SW_SHOWNORMAL, false);
                  I have two questions. When Foxit Reader runs, I am presented with the Windows Open File Security Dialog box that says that the publisher cannot be identified. Is there anyway to avoid this dialog box? I know I can click "run" for my use, but I am sure this dialog box will alarm clients.

                  Secondly, I have validated that the "Password_test.pdf" is in the correct directory as noted in the script above...but after I click "yes" on Windows Open File security dialog box, Foxit opens but I get a message that the states "Could not open file. File not found". I can open this PDF manually using the "test" password so I "know" the password is correct. And again I have re-confirmed that the "password_test.pdf is in the Doc folder along with Foxit4.2.exe file.

                  Any ideas? Thanks
                  Jim

                  Comment


                  • #10
                    Ulrich,
                    When I remove the password from the Password_test.pdf and adjust the script to not pass the "password", Foxit reader opens after I click "Run" in the Microsoft security dialog box---but the Foxit reader does not display the PDF---it merely opens waiting for the user to do something. While Foxit 4.2 is displayed on the screen, I can manually open the file, going to File, Open and migrating to the directory where the pdf is stored. The PDF will then open correctly.

                    When I used the password as discussed in my previous post, after I click "RUN" on the MS security dialog box---Foxit starts to open but when I click the Foxit dialog box that states it "could not open the file.....", Foxit immediately closes. I wasn't sure if this additional information would be of value to you. Thanks.

                    Comment


                    • #11
                      Could you please create a small sample password protected PDF and attach it here? Also, please provide the password to open it, of course.

                      Ulrich

                      Comment


                      • #12
                        Ulrich,
                        Attached is the actual file I am working with...The password is: "test". Thanks again for your help.
                        Jim
                        Attached Files

                        Comment


                        • #13
                          I don't get any problems here. Please open and run the attached project and see if it works.

                          Ulrich
                          Attached Files

                          Comment


                          • #14
                            Ulrich,
                            Again, let say how grateful and thankful I am for your continued patience and advice.

                            Your project file does run for me as well. I will spend some time this weekend looking at your project to see where my error is. I will also try to run mine from my home computer. Perhaps the work anti-virus software is causing a problem--though the log files that I view do not indicate any intrusion from the AV application and the AV does not hamper your project files. Sometimes I wish the learning curve wasn't so steep.

                            Thanks again. Jim

                            Comment


                            • #15
                              Ulrich,
                              I am still plugging way at getting this project to work.

                              I seem to be down to eliminating the pop-up dialog (i.e., see attached jpg). When I uncheck the box "always ask before opening this file"---the box no longer appears for me. But my research indicates that the box is checked by default and if an end user, like me, has not previously unchecked the box, the dialog box will always appear.

                              I am worried that our clients will be nervous about this dialog box and click "cancel" to be safe and not view the documents. Is there anyway to "suppress" this dialog box even if the end user has not unchecked the box "always ask before opening this file" previously? I am fearful the answer is "no" as that is what I "think" I learned from my internet research but some of explanation/terms used on the intranet is confusing to me.

                              Thanks again for your patience and willingness to help those that need it. Jim
                              Attached Files

                              Comment

                              Working...
                              X
                              😀
                              🥰
                              🤢
                              😎
                              😡
                              👍
                              👎