Alternative to BigText return value in nav 2009 R2

Hi,

I'm working on a webservice that returns invoices as PDF. In this I have a function that is supposed to flush a base64 enocoded PDF, which works fine i more recent version, but in 2009 R2 the text return value is limited to 1024 bytes. Is there anyway to work around this inside the codeunit? Plan b is to generate the PDF and have it moved by the middle ware based, but I would rather avoid that.

BR.
Lars

Answers

  • ftorneroftornero Posts: 149Member
    This is an example, you should elaborate a little, changing the PDFFIle parameter with the invoice code to get and then generate the PDF of this invoice or something like that.
    OBJECT Codeunit 86177 WebServices PDF
    {
      OBJECT-PROPERTIES
      {
        Date=01/10/18;
        Time=21:47:20;
        Modified=Yes;
        Version List=DS;
      }
      PROPERTIES
      {
        OnRun=BEGIN
              END;
    
      }
      CODE
      {
    
        PROCEDURE [email protected](VAR [email protected] : BigText;[email protected] : Text[1024]);
        VAR
          [email protected] : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v3.0'.DOMDocument";
          [email protected] : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v3.0'.IXMLDOMNode";
          [email protected] : Automation "{EF53050B-882E-4776-B643-EDA472E8E3F2} 2.7:{00000566-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.7 Library'.Stream";
          [email protected] : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Convert";
          [email protected] : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Base64FormattingOptions";
          [email protected] : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.IO.File";
        BEGIN
          IF ISSERVICETIER THEN
            BText.ADDTEXT(Convert.ToBase64String(ServerFile.ReadAllBytes(PDFFile)))
          ELSE BEGIN
            CREATE(XmlDoc);
            CREATE(AdoStream);
    
            XmlDoc.loadXML('</xml>');
            XmlNode := XmlDoc.createNode('element', 'ImgFile', 'SomeNamespace');
    
            XmlNode.dataType := 'bin.base64';
    
            AdoStream.Type := 1;
    
            AdoStream.Open();
            AdoStream.LoadFromFile(PDFFile);
            XmlNode.nodeTypedValue := AdoStream.Read();
            AdoStream.Close();
    
            BText.ADDTEXT(XmlNode.text);
    
            CLEAR(AdoStream);
            CLEAR(XmlNode);
            CLEAR(XmlDoc);
          END;
        END;
    
        BEGIN
        END.
      }
    }
    
    

    Regards.
  • larshslarshs Posts: 11Member
    Thanks a lot! I changed the code, so I pass the webservice response as val paremeter to the method, and then I can just use ADDTEXT and append the base64 stream. However, I'm facing an issue with actually generating the PDF through the codeunt. I'm getting this:

    The layout of this report has not been transformed to be viewed in the RoleTailored client. You can run this report from the Microsoft Dynamics NAV Classic client.

    It's a codeunit I'm migrating from 2016 to 2009 R2 which until now hasn't been that much of a struggle :smile:

    BR.
    Lars
  • ftorneroftornero Posts: 149Member
    Hello,

    You can not use SAVEASPDF if the report don't have a RDLC layout. I don't know if that is the case.

    If you could give more information of what you are doing I'll try to help you.

    Regards.
  • larshslarshs Posts: 11Member
    Thanks, I appreciate your willingness to help. The problem was that the client has the classic client and not the role tailored client. Then, as far as I could google, SAVEASPDF is a no-go.

    Thanks again:)
  • ftorneroftornero Posts: 149Member
    So, you need to use a PDF printer like BullZip or PDFCreator.

    Regards
Sign In or Register to comment.