Hi
In Nav2013R2 I want to embed files in XML as Base64 encoded binaries - we will confine to PDF-files. They should be embedded as Base64 encoded. I'm aware that I have to put the file into a stream, and then use the .Net Frameworks built-in support for Base64 converting with the System.Convert class (Convert.ToBase64String)...But how do I put all the things together?
0
Comments
http://mibuso.com/blogs/mandyk/2009/06/16/net-com-wrapper-to-extract-navision-picture-into-xml-format/
...but in nav2009!
In Nav2013R2 we can utilize the .Net interopt directly and have no need for creating a COM object.
But still: How to do :?:
I have done picture to encode64 and zip to use for web service. I haven't test same as your requirement. Please take a look is it meet with your requirement...?
Note : When you read back from your xml you need to unzip and decode it back.
Best Regards,
Yukon
Thx for your answer! I think this will do the trick a long way down the road The challenge for me lies in the fact that the file I want to embed is placed on a local drive or a network path. I could stream the file into a BLOB field and then just use you'r code, but it would be a more clean solution to stream directly from the file instead of streaming in and out of a BLOB field....
I had the same issue in NAV2013 R2. Converting PDF, Word or Excel files to base64 string and add to an xml-file for electronic invoices.
Yukon, your code example did the trick for me! I removed the zip-part as I did not need it and just added a parameter 'tFile' entering the function and set txtBase64Code as Return Value:
Thank you very much!
Steffan
Your code helped me the last step - thanks! With the zip-part in Yukons code, my binary-file went wrong but now it looks right. The only thing left would be, that i'm getting a bunch of filler-'A's at the end of the file (like this: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')?? Is there any way to get rid of them
Check out this link http://stackoverflow.com/questions/6916805/why-base64-encoding-string-have-sign-in-the-last. It should explain why.
can you give the example of the decode?
Nuno Silva