Hi Inge and YOU ZHU.
Thank you very much, both!
I have found out that it is going to be made in NAV 2016 and not NAV 2015.
The base64 codeunit is not available in these old versions.
I have made a procedure that has a VAR parameter of type BigText. The pdf file is saved in Windows and then I use the dll files to copy the file into the VAR parameter. Afterwards the VAR parameter has the length of more than 200000, so it should be right.
When I call the procedure from a C# program or from the Google Chrome extension Wizdler, I get this error:
Microsoft Dynamics NAV Business Web Services attempted to issue a client callback to download a file: Invoice.pdf (CodeUnit 50000 myCodeUnitName). Client callbacks are not supported on Microsoft Dynamics NAV Business Web Services.
When I ran my code in NAV development environment, it asked the first time, if it should use the dlls. I selected "always". Now that popup does not come anymore, so I don't know what "client callback" there is.
Here is my code:
TempBlob.RESET();
TempBlob.Blob.CREATEOUTSTREAM(OutS);
REPORT.SAVEAS(206, TempText, REPORTFORMAT::Pdf, OutS);
TempBlob.INSERT();
TempBlob.CALCFIELDS(Blob);
TempBlob.Blob.CREATEINSTREAM(InS);
NewFileName := 'Invoice.pdf';
DOWNLOADFROMSTREAM(InS,'','<TEMP>', '', NewFileName);
CREATE(Document, FALSE, TRUE);
Element := Document.createNode('element', 'ImageFile', 'whatIsThis');
Element.dataType := 'bin.base64';
CREATE(Stream, FALSE, TRUE);
Stream.Type := 1;
Stream.Open;
Stream.LoadFromFile(NewFileName);
Element.nodeTypedValue := Stream.Read;
Stream.Close;
Invoice.ADDTEXT(Element.text);
CLEAR(Stream);
CLEAR(Element);
CLEAR(Document);
//message('%1', Invoice.LENGTH);