2 Replies Latest reply on Jun 6, 2017 9:49 PM by Frank Hoffmann

    Print an pdf document directy from Forms12c with Adobe DDE

    Frank Hoffmann

      Hi All,

       

      I have a task to investigate a possible direct printing with an Adobe DDE-call from Forms12c. I know there is a JAVA solution that works and I know there is a OLE solution if ADOBE is licensed.

      The DDE solution should still work for the free ADOBE Reader. The Job here is to find out if this could be an alternative. Has anyone a solution for this?

       

      My example starts Acrobat but always fails with "MESSAGE('DDE CANNOT ESTABLISH A CONVERSATION');"

       

      I am using local parameters

      [HKEY_CLASSES_ROOT\acrobat\shell\open\command]

      [HKEY_CLASSES_ROOT\acrobat\shell\open\ddeexec]

       

      And I took a solution from Oracle Support and modfied it with ADOBE commands.

       

      I want to open the PDF document, print it, and Close it again with DDE commands.

       

      -----------------------------------------------------------------------------------------------------------------------

       

      DECLARE
          x number(1) := 0;
           appid            PLS_INTEGER;
           convid           PLS_INTEGER;
           docid            PLS_INTEGER;

       

      /* Begin trigger DDE sample */
      BEGIN

      /* Start Acrobat */
      /* This line assumes that Excel is in the directory e:\msoffice\excel */
         APPID := DDE.APP_BEGIN('"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"',DDE.APP_MODE_NORMAL);
         --dbms_lock.sleep(2);
         synchronize;
         convid := DDE.INITIATE('AcroViewR10','control');
         --dbms_lock.sleep(2);

         DDE.Execute(ConvID,'[DocOpen(C:\temp\test.pdf)]',100000);
         DDE.EXECUTE(convid,'[APPExit()]', 100000);

         DDE.TERMINATE(docid);
         DDE.TERMINATE(convid);
         DDE.APP_END(appid);

      /* Handle exceptions */
      EXCEPTION
        WHEN DDE.DDE_APP_FAILURE THEN
          MESSAGE('WINDOWS APPLICATION CANNOT START.');
        WHEN DDE.DDE_PARAM_ERR THEN
          MESSAGE('A NULL VALUE WAS PASSED TO DDE');
        WHEN DDE.DMLERR_NO_CONV_ESTABLISHED THEN
          MESSAGE('DDE CANNOT ESTABLISH A CONVERSATION');
        WHEN DDE.DMLERR_NOTPROCESSED THEN
          MESSAGE('A TRANSACTION FAILED');

      /* End of trigger */
      END;

        • 1. Re: Print an pdf document directy from Forms12c with Adobe DDE
          Michael Ferrante-Oracle

          Are you aware that even if this is valid code, it will be executed on the server (mid tier) and not the user's machine?  This may be where you are having a problem.  On the server side, this would fail if you are starting the Oracle software (e.g. WLS, etc) with a Windows Service.  This is because Windows prevents Service started processes from having access to the Desktop space.  Because Acrobat requires access to the Desktop (as far as I know), the process may start but not be able to successfully complete the expected task.

          • 2. Re: Print an pdf document directy from Forms12c with Adobe DDE
            Frank Hoffmann

            Mike,

             

            thank you for this useful information. I was confused because it seemed the Acrobat session did start on the Client (APP_BEGIN) and I thought the first DDE command was at least successful but I forgot that

            Webutil has not Client_DDE and therefore could not handle this on Clientsite

             

            I found even an the explantion from Mr. Webutil for this:

            ===============================================

            Question to Duncan Mills 05-2004:

            Does webutil have any DDE related functionality?

            DM> No, this was something that we did not have time to put in

            ================================================

             

            I made the test on a Windows2012 Server, installed a local printer and got a result with a DDE.APP_BEGIN.

             

            This piece of code opens once two Acrobat processes and then no more. So if you can put your PDF Reports somewhere accessible on the Server you can use this call to direct print it on the local Printer of the W2012 Server.

            It is really fast, you do not need to kill Client-Tasks and it seems to work with mass calls. It works with every Acrobat Reader so no license needed. Maybe a solution to print out bills or other secure Papers on a single place.

             

            DECLARE
                 appid            PLS_INTEGER;

            /* Begin trigger DDE sample */
            BEGIN

            /* Start Acrobat */
            /* This line assumes that Acrobat is installed on the Windows2012 Server - the path can be found in the Registry [HKEY_CLASSES_ROOT\acrobat\shell\open\command] */
               APPID := DDE.APP_BEGIN('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /t "C:\temp\test1.pdf"',DDE.APP_MODE_MINIMIZED);
               APPID := DDE.APP_BEGIN('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /t "C:\temp\test2.pdf"',DDE.APP_MODE_MINIMIZED);
               APPID := DDE.APP_BEGIN('"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" /t "C:\temp\test3.pdf"',DDE.APP_MODE_MINIMIZED);

            /* Handle exceptions */
            EXCEPTION
              WHEN DDE.DDE_APP_FAILURE THEN
                MESSAGE('WINDOWS APPLICATION CANNOT START.');
              WHEN DDE.DMLERR_NOTPROCESSED THEN
                MESSAGE('A TRANSACTION FAILED');

            /* End of trigger */
            END;

             

            But I was still not able to establish a DDE Server Connection on a Windows2012 Server with Acrobat.