Alternative to BigText return value in nav 2009 R2

larshs
Member Posts: 17
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
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
0
Answers
-
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 GetB64PDF@1000000004(VAR BText@1000000001 : BigText;PDFFile@1000000000 : Text[1024]); VAR XmlDoc@1000000005 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{F6D90F11-9C73-11D3-B32E-00C04F990BB4}:'Microsoft XML, v3.0'.DOMDocument"; XmlNode@1000000006 : Automation "{F5078F18-C551-11D3-89B9-0000F81FE221} 3.0:{2933BF80-7B36-11D2-B20E-00C04F983E60}:'Microsoft XML, v3.0'.IXMLDOMNode"; AdoStream@1000000007 : Automation "{EF53050B-882E-4776-B643-EDA472E8E3F2} 2.7:{00000566-0000-0010-8000-00AA006D2EA4}:'Microsoft ActiveX Data Objects 2.7 Library'.Stream"; Convert@1000000008 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Convert"; Base64FormatOptions@1000000010 : DotNet "'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Base64FormattingOptions"; ServerFile@1000000011 : 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.0 -
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
BR.
Lars0 -
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.0 -
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:)0 -
So, you need to use a PDF printer like BullZip or PDFCreator.
Regards0 -
Thanks0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions