Print external HTML file from NAV

alexjensenalexjensen Member Posts: 41
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 Member Posts: 297
    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 Member Posts: 41
    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 Member Posts: 398
    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 Member Posts: 41
    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 Member Posts: 126
    Works very fine, but is there a way not to open the application (eg. Word, Notepad) and choose a printer?
  • alexjensenalexjensen Member Posts: 41
    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.