Send a SaveAsPdf report to a printer

hi all

I am working with nav 2009 R2 in classic client. we have a web application connected to navision by WebService, my customer wants to print a report from the pda and send it to a navision configured printer. The report has a layout and i can create the pdf by report function SAVEASPDF but i don´t know how to send this file to a printer.

i have searched in mibuso but almost everything talking about pdf creator (but i have pdf file).

This is the link that convinces me the most, but doesn´t work for me

http://dynamicslancer.blogspot.com.es/2016/09/how-to-print-pdf-file-directly-to.html

there is another way to do this.

thanks. regards

Best Answer

  • ftorneroftornero Member Posts: 524
    Answer ✓
    Hello,

    If the file is a PDF you need to have installed Adobe Acrobat Reader, Foxit Reader or other application that deal with PDF files.

    You can try to print a Word file (.docx or .doc) in case you have Office installed.

    Regards

Answers

  • ftorneroftornero Member Posts: 524
    With this code you can print any kinfd of file if you have the application to print it.

    If your language is not English you must change the verb name from PRINT to yur local language,
    OBJECT Codeunit 50099 Print File
    {
      OBJECT-PROPERTIES
      {
        Date=07/11/17;
        Time=17:44:20;
        Modified=Yes;
        Version List=Print;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
    
        PROCEDURE PrintFile@1000000000(Fichero@1000000011 : Text[1024]);
        VAR
          _FileName@1000000000 : Text[250];
          Dir@1000000001 : Text[250];
          ObjShell@1000000002 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{13709620-C279-11CE-A49E-444553540000}:'Microsoft Shell Controls And Automation'.Shell";
          ObjFolder@1000000003 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{BBCBDE60-C3FF-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.Folder";
          ObjFolderItems@1000000004 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{744129E0-CBE5-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItems";
          ObjFolderItem@1000000005 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{FAC32C80-CBE4-11CE-8350-444553540000}:'Microsoft Shell Controls And Automation'.FolderItem";
          ObjVerbs@1000000006 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{1F8352C0-50B0-11CF-960C-0080C7F4EE85}:'Microsoft Shell Controls And Automation'.FolderItemVerbs";
          ObjVerb@1000000008 : Automation "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE} 1.0:{08EC3E00-50B0-11CF-960C-0080C7F4EE85}:'Microsoft Shell Controls And Automation'.FolderItemVerb";
          i@1000000007 : Integer;
          Nombre@1000000009 : Text[1024];
          total@1000000010 : Integer;
        BEGIN
          IF NOT EXISTS(Fichero) THEN
            EXIT;
          CREATE(ObjShell, TRUE);
          SplitName(Fichero, Dir, _FileName);
          ObjFolder := ObjShell.NameSpace(Dir);
          ObjFolderItems := ObjFolder.Items;
          ObjFolderItem := ObjFolderItems.Item(_FileName);
          ObjVerbs := ObjFolderItem.Verbs;
          i := -1;
    
          total := ObjVerbs.Count;
          REPEAT
            i += 1;
            IF i < total THEN BEGIN
              ObjVerb := ObjVerbs.Item(i);
              Nombre := ObjVerb.Name;
            END;
          UNTIL (STRPOS(UPPERCASE(ObjVerb.Name), 'PRINT') > 0) OR (i > total);
    
          IF i <= total THEN BEGIN
            ObjVerb.DoIt;
          END ELSE
            ERROR('The file %1, can not be printed');
        END;
    
        PROCEDURE SplitName@1000000001(Fichero@1000000000 : Text[1024];VAR Path@1000000001 : Text[1024];VAR Nombre@1000000002 : Text[1024]);
        VAR
          Donde@1000000003 : Integer;
          Pos@1000000004 : Integer;
          Fichero1@1000000005 : Text[1024];
        BEGIN
          Fichero1 := Fichero;
          Pos := STRPOS(Fichero1, '\');
          Donde := Pos;
          WHILE Pos <> 0 DO BEGIN
            Fichero1 := COPYSTR(Fichero1, Pos+1);
            Pos := STRPOS(Fichero1, '\');
            Donde := Donde + Pos;
          END;
          Path := COPYSTR(Fichero, 1, Donde);
          Nombre := COPYSTR(Fichero, Donde+1);
        END;
    
        BEGIN
        END.
      }
    }
    
  • gorvega79gorvega79 Member Posts: 73
    thanks so much for the code. i will try to do this and let you know if it works...thanks again. regards.
  • krikikriki Member, Moderator Posts: 9,115
    [Topic moved from 'NAV Three Tier' forum to 'NAV/Navision Classic Client' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • gorvega79gorvega79 Member Posts: 73
    edited 2017-11-09
    hi kriki

    The problem i have is how to print a pdf but i have to do this by WS as i have wrote in my topic.

    i don´t know why you have moved the topic. maybe a solution works for classic client but maybe doesn´t work for web services. because of this i put the topic in 'NAV Three Tier' forum.

    regards.
  • gorvega79gorvega79 Member Posts: 73
    hi ftornero

    i have tried your code but NAV send me this error

    "the call to member Star failed: No application is asssociated with the specified file for this operation"

    i can´t asociate a file when whe have to print. maybe in the Arguments i have to put the printer name.

    thanks.Regards


  • ftorneroftornero Member Posts: 524
    Answer ✓
    Hello,

    If the file is a PDF you need to have installed Adobe Acrobat Reader, Foxit Reader or other application that deal with PDF files.

    You can try to print a Word file (.docx or .doc) in case you have Office installed.

    Regards
  • gorvega79gorvega79 Member Posts: 73
    this works!!!! thanks so much ftornero.
Sign In or Register to comment.