3 Replies Latest reply on Sep 9, 2009 6:58 AM by Patrick Leckey

    Save PDF in AxSHDocVw.AxWebBrowser

    Cadel12

      In my VB 2003 app, the browser control is AxSHDocVw.AxWebBrowser. The code checks to see if the incoming file is a pdf file.

       

      If TypeOf WebDisplay.Document Is AcroPDFLib.IAcroAXDocShim

       

      If the file is a AcroPDFLib.IAcroAXDocShim then I want to "save as" to a local file. C:\Test.pdf

       

      What is the code to do this?

       

      I've tried to interface CType(WebDisplay.Document, AcroPDFLib.IAcroAXDocShim).src but that returns the web page URL. I want to save the pdf file.

       

      I also tried using execCommand.

       

                                  Dim strArray(3) As String

                                  strArray(0) = "SaveAs"

                                  strArray(1) = 1

                                  strArray(3) = "C:\test.pdf"

                                  CType(WebDisplay.Document, AcroPDFLib.IAcroAXDocShim).execCommand(strArray)

       

      But I get a marshal error, excessively long string.

       

      I have read Adobe's "Developing Applications Using Interapplication Communication" and "Interapplication Communication API Reference", didn't see anything relevant.

        • 1. Re: Save PDF in AxSHDocVw.AxWebBrowser
          Patrick Leckey Level 3

          You can't.  The browser control doesn't provide any functionality for saving PDFs.  All the methods available to the browser control are listed in the IAC documentation available with the Acrobat SDK.

          • 2. Re: Save PDF in AxSHDocVw.AxWebBrowser
            Filosoft

            Hi Patrick

             

            The execCommand is not documented, but is actually a public accessible method on the AcroPDF.dll. Well it is easy to understand that it is not allowed to access the SaveAs from clientside scripting in a browser. But the very handy SendMail where the pdf-file is put in as an attachment in an email opened in the default email-client would be very nice to be able to access.

             

            On the client-side scripting in a web-browser we have the mailto-link that can be setup with all field filled from the scripting except for the attachment.

             

            But the Acrobat control has this feature builtin. Is there a way to access it, so you can make a javascript-function that sends a PDF-file in an email like the user is able to do by clicking on the toolbar on the PDF-document in the webbrowser?

            • 3. Re: Save PDF in AxSHDocVw.AxWebBrowser
              Patrick Leckey Level 3

              Filosoft,

               

              First of all, there is a reason execCommand isn't documented - it isn't supported and may (read: probably will) be changed/removed in future versions of Acrobat.  The only commands you should rely on for a production environment are the documented ones, unless you're OK with possibly being stuck with never being able to upgrade to the latest version/security fix without breaking your application.

               

              I'm not entirely sure I understand your last paragraph - I believe you are confusing the Arobat OLE interfaces with the ActiveX control.  The ActiveX control (what is loaded in the browser) only has a very limited set of methods.  The additional Acrobat OLE interfaces have a great deal more in terms of capability but these methods cannot be accessed from a browser context (and require a full version of Acrobat on the client machine - Reader won't do).

               

              If you are simply trying to have a button/link outside of the viewer ActiveX control that tells the currently loaded PDF to wrap itself up as an e-mail attachment for the local MAPI client and open an e-mail composition window, you can do this purely with JavaScript and the hostContainer object which allows your HTML page-level JavaScript to interact with the Acrobat/Reader JavaScript engine.  Keep in mind that if the client machine only has Reader, the document will need to be Reader Extended in order to allow the document to attach itself in PDF format, since save rights are required for this operation.