Options

Calling Adobe Automations and/or OCX

rocatisrocatis Member Posts: 163
I'm trying to do what surely must be on the top 10 list of Simple Things That Should Be Easy To Implement. I want to print a PDF document from within NAV.

I used to run AcroRd32.exe with the /t parameter but in their infinite wisdom Adobe has decided to mess up this (albeit unsupported) feature, meaning that I cannot print multiple documents anymore.

My code looks like this:
OBJECT Report 99977 Test Adobe PDF Printing
{
  OBJECT-PROPERTIES
  {
    Date=12-08-08;
    Time=15:01:00;
    Modified=Yes;
    Version List=;
  }
  PROPERTIES
  {
    ProcessingOnly=Yes;
    OnPreReport=BEGIN
                  Filename := '<a random pdf file>';

                  CREATE(AdobeAutomation);
                  MESSAGE('%1',AdobeAutomation.LoadFile(Filename));

                  AdobeAutomation.printAll;
                END;

  }
  DATAITEMS
  {
  }
  REQUESTFORM
  {
    PROPERTIES
    {
      Width=9020;
      Height=3410;
    }
    CONTROLS
    {
    }
  }
  CODE
  {
    VAR
      AdobeAutomation@1060000 : Automation "{05BFD3F1-6319-4F30-B752-C7A22889BCC4} 1.0:{CA8A9780-280D-11CF-A24D-444553540000}:'Adobe Acrobat 7.0 Browser Control Type Library 1.0'.AcroPDF";
      AdobeOCX@1060003 : OCX "{CA8A9780-280D-11CF-A24D-444553540000}:'Adobe PDF Reader'";
      Filename@1060001 : Text[200];

    EVENT AdobeAutomation@1060000::OnError@1();
    BEGIN
    END;

    EVENT AdobeAutomation@1060000::OnMessage@2();
    BEGIN
    END;

    BEGIN
    END.
  }
}

This will display "No" (meaning that the file was not loaded) and do nothing else. I get the same result using the OCX (the example above uses the automation).

Can anyone point me in the right direction here?
Brian Rocatis
Senior NAV Developer
Elbek & Vejrup

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Maybe you can use the code posted by "detlef" in this thread: Print files with an associated application
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    ara3nara3n Member Posts: 9,256
    There are other pdf readers like Foxit pdf. It is much faster and lighter than pdf reader.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    rocatisrocatis Member Posts: 163
    Maybe you can use the code posted by "detlef"

    Indeed! Thanks for posting the link.

    I do however have an inkling that the commands in the context menu are language specific which could make the proposed technique a little cumbersome, but the bottom line is that it works.

    As an added bonus the method gives access to many of the commands in the context menu which could come in handy.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • Options
    rocatisrocatis Member Posts: 163
    ara3n wrote:
    There are other pdf readers like Foxit pdf. It is much faster and lighter than pdf reader.

    Maybe, but does it support printing from within NAV using automations?

    If not, I really couldn't care less if it's faster and lighter :mrgreen:

    Besides, the detlef-method will work with any pdf reader as long as the reader puts a (print) command in the context menu for pdf files.

    This is nice <tm>
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • Options
    ara3nara3n Member Posts: 9,256
    Why use automation when you can use shell cmd

    From Shell you can print the pdf document


    "Foxit Reader.exe" /p pdfdocument.pdf
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • Options
    rocatisrocatis Member Posts: 163
    ara3n wrote:
    Why use automation when you can use shell cmd

    Well, I was using the shell command and printing the document using Adobe Reader (albeit it's an unsupported command line parameter), but that option has been removed in the latest version (v9). Or, to be more precise, when printing several documents it will only print the first, then wait for the user to close the Adobe application before printing the next and so on, which kinda sucks.

    Initially I tried using automations to do the job as you can see in my first mail, as this is a supported interface that won't just disappear from one day to the next.

    However, the detlef-method is even smarter as it doesn't even require a specific pdf reader to be used - each user can install whatever he/she wants and I don't have to ensure that the right program with the right version is accessible at the right location.
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
Sign In or Register to comment.