Printing Blob Field

fazlehasan
Member Posts: 70
I have pasted this text from Word Document to a NAV Blob Field: ~!@#$%^&*() ‘something’ “something more” end
And printed this blob fields through a NAV report as pdf, it looks like this:

It could not decode the Left Single Quotation, Right Single Quotation, Left Double Quotation, Right Double Quotation when printing.
This is my code.
CALCFIELDS("Additional Comments");
"Additional Comments".CREATEINSTREAM(iStream,TEXTENCODING::UTF8);
Encoding:=Encoding.UTF8;
StreamReader := StreamReader.StreamReader(iStream,Encoding,TRUE);
Here,
StreamReader is a DotNet variable of subtype System.IO.StreamReader.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
and Encoding is a DotNet variable of subtype System.Text.Encoding.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Your suggestion will be very much appreciated to resolve the issue.
And printed this blob fields through a NAV report as pdf, it looks like this:

It could not decode the Left Single Quotation, Right Single Quotation, Left Double Quotation, Right Double Quotation when printing.
This is my code.
CALCFIELDS("Additional Comments");
"Additional Comments".CREATEINSTREAM(iStream,TEXTENCODING::UTF8);
Encoding:=Encoding.UTF8;
StreamReader := StreamReader.StreamReader(iStream,Encoding,TRUE);
Here,
StreamReader is a DotNet variable of subtype System.IO.StreamReader.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
and Encoding is a DotNet variable of subtype System.Text.Encoding.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Your suggestion will be very much appreciated to resolve the issue.
0
Answers
-
Hi,
Not sure why you are using dotnets to read from a blob, NAV can handle this.
Can you try something like://no length takes all the text. vTextline should be text with no length or in old nav versions you may need to use bigtext.addtext etc. repeat vInStr.READTEXT(vtextLine); until vInstr.EOS;
Also, I recall if you are about to read BLOBs from SQL query etc, you need to set BLOB properties compressed=false. Even if you do that, some characters are not well recognised etc.1 -
Perhaps this one:
CALCFIELDS(Description); Description.CREATEINSTREAM(InStr); BinaryReader := BinaryReader.BinaryReader(InStr,Encoding.UTF8); IF NOT ISNULL(BinaryReader) THEN BEGIN //read value from BLOB field IF BinaryReader.BaseStream.Length > 0 THEN MyText := BinaryReader.ReadString; BinaryReader.Close; END;
https://andreilungu.com/read-write-text-from-to-blob-field-nav/1 -
ah, now I realise you want to upload a blob file (word document), not the text itself.
Then yes, you can do something like this, I used for reading an imagevChars: Byte; repeat pInStream.Read(vChars, 1); vOutStr.Write(vChars, 1); until pInStream.EOS;
1 -
I go this error when I tried to utilize one of the suggestions using Binary Reader, probable it could not decode the Left/Right Single/Double quotation marks (U+2018, U+2019,U+201C,U+201D) and got the error:
Thanks txeriff and PurpleHaze for your help. You are awesome.0 -
Finally this code worked: thanks for your help.
"Additional Comments".CREATEINSTREAM(iStream1);
binRdr:=binRdr.BinaryReader(iStream1,Encoding.UTF8);
IF NOT ISNULL(binRdr) THEN BEGIN //read value from BLOB field
length:=binRdr.BaseStream.Length;
IF length > 0 THEN BEGIN
WHILE i<length DO BEGIN
var_char:=binRdr.ReadByte();
TokenText+=FORMAT(var_char);
i+=1;
END;
END;
MESSAGE('text %1',TokenText);
binRdr.Close;
END;1
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