Print external HTML file from NAV

alexjensenalexjensen Posts: 40Member
Hi all

I'm looking for a way to print an external HTML file to a specific printer using NAV code. The print must be done without any user interaction (e.g. by a NAS).

Any ideas?

AJ

Comments

  • XypherXypher Posts: 297Member
    I had created a solution for a situation like this using 'Internet Explorer' Automation (I created it to print UPS shipment labels without GUI interface.) But it would use the default printer.

    I do not know of any Automation's currently out there that will do what you wish. You may just need to create a custom .NET solution yourself.

    Hope at least I provided some clarity.

    (And by no means does NAV give you the freedom to do this straight from C/AL)
  • alexjensenalexjensen Posts: 40Member
    Xypher wrote:
    I had created a solution for a situation like this using 'Internet Explorer' Automation (I created it to print UPS shipment labels without GUI interface.) But it would use the default printer.

    I do not know of any Automation's currently out there that will do what you wish. You may just need to create a custom .NET solution yourself.

    Hope at least I provided some clarity.

    (And by no means does NAV give you the freedom to do this straight from C/AL)

    Hi Xypher

    Could You share You automation example so I can try that?

    AJ
  • tompynationtompynation Posts: 398Member
    Got this from somewhere on the forum here... prints every file you like i guess.


    lv_FileName := 'C:\TREM Kaarten\test.html';
    PrintFile(lv_FileName);

    SplitDirFile(FullString : Text[250];VAR JustDir : Text[250];VAR JustFileName : Text[250])
    ExitLoop := FALSE;
    PointBreak := STRLEN(FullString);
    WHILE (NOT ExitLoop) OR (PointBreak <= 1) DO
    IF COPYSTR(FullString,PointBreak,1) = '\' THEN BEGIN
    JustFileName := COPYSTR(FullString,PointBreak + 1);
    ExitLoop := TRUE;
    END ELSE
    PointBreak -= 1;
    JustDir := COPYSTR(FullString,1,PointBreak);

    PrintFile(PrintThisFile : Text[250])
    IF ISCLEAR(objShell) THEN
    CREATE(objShell);

    SplitDirFile(PrintThisFile,Dir,FileName);

    objFolder := objShell.NameSpace(Dir);
    objFolderItems := objFolder.Items;
    objFolderItem := objFolderItems.Item(FileName);
    objFolderItem.InvokeVerb('PRINT');
    objVerbs := objFolderItem.Verbs;

    Used variables:
    Name DataType Subtype Length
    objShell Automation 'Microsoft Shell Controls And Automation'.Shell
    objFolder Automation 'Microsoft Shell Controls And Automation'.Folder
    objFolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems
    objFolderItem Automation 'Microsoft Shell Controls And Automation'.FolderItem
    objVerbs Automation 'Microsoft Shell Controls And Automation'.FolderItemVerbs
    Dir Text 250
    FileName Text 250
  • alexjensenalexjensen Posts: 40Member
    Got this from somewhere on the forum here... prints every file you like i guess.


    lv_FileName := 'C:\TREM Kaarten\test.html';
    PrintFile(lv_FileName);

    SplitDirFile(FullString : Text[250];VAR JustDir : Text[250];VAR JustFileName : Text[250])
    ExitLoop := FALSE;
    PointBreak := STRLEN(FullString);
    WHILE (NOT ExitLoop) OR (PointBreak <= 1) DO
    IF COPYSTR(FullString,PointBreak,1) = '\' THEN BEGIN
    JustFileName := COPYSTR(FullString,PointBreak + 1);
    ExitLoop := TRUE;
    END ELSE
    PointBreak -= 1;
    JustDir := COPYSTR(FullString,1,PointBreak);

    PrintFile(PrintThisFile : Text[250])
    IF ISCLEAR(objShell) THEN
    CREATE(objShell);

    SplitDirFile(PrintThisFile,Dir,FileName);

    objFolder := objShell.NameSpace(Dir);
    objFolderItems := objFolder.Items;
    objFolderItem := objFolderItems.Item(FileName);
    objFolderItem.InvokeVerb('PRINT');
    objVerbs := objFolderItem.Verbs;

    Used variables:
    Name DataType Subtype Length
    objShell Automation 'Microsoft Shell Controls And Automation'.Shell
    objFolder Automation 'Microsoft Shell Controls And Automation'.Folder
    objFolderItems Automation 'Microsoft Shell Controls And Automation'.FolderItems
    objFolderItem Automation 'Microsoft Shell Controls And Automation'.FolderItem
    objVerbs Automation 'Microsoft Shell Controls And Automation'.FolderItemVerbs
    Dir Text 250
    FileName Text 250

    Thanks. I'll have a look at it.

    Alex
  • mgmmgm Posts: 126Member
    Works very fine, but is there a way not to open the application (eg. Word, Notepad) and choose a printer?
  • alexjensenalexjensen Posts: 40Member
    mgm wrote:
    Works very fine, but is there a way not to open the application (eg. Word, Notepad) and choose a printer?

    I ended up using a small (and not very expensive) utility like this:

    http://bersoft.com/htmlprint/index.htm

    If there's anything like it for free I don't know ....

    AJ
Sign In or Register to comment.