Hi Folks,
We are trying to convert PDF stream to Base64String, in order to share the encoded Base64 string with other 3PL system.
Note: We don't have file as input, we are getting this PDF Stream from class (ERFileDestinationAttachment) while system execute ER (BDM) report.
It wasn't working when this feature is enabled /Utilize application resources to perform CBD documents conversion from Word to PDF format/ under feature management.
Requirement scope: Convert PDF stream to Base64String
Logic 1:
System.Byte[] bytes;
System.IO.BinaryReader binaryReader;
System.IO.Stream baseStream;
System.IO.StreamReader streamReader;
System.Object streamObject;
System.Object bytesObject;
int streamLength;
int bytesLength;
baseStream = _pdfStream;
streamObject = baseStream.get_Length();
streamLength = streamObject;
binaryReader = new System.IO.BinaryReader(baseStream);
bytes = binaryReader.ReadBytes(streamLength); // Here system return as bytes[0]
baseStream.Close();
bytesObject = bytes.get_Length();
bytesLength = bytesObject;
base64data = System.Convert::ToBase64String(bytes, 0, bytesLength);
Logic 2:
using (System.IO.Stream fileStream = _pdfStream)
{
using (System.IO.MemoryStream memoryStream = new System.IO.MemoryStream())
{
fileStream.CopyTo(memoryStream);
base64data = ERConversionUtils::StreamToBase64(memoryStream);
}
}
For conversion from PDF Stream to BASE64String
If Feature is enabled,
Both logic 1 & 2 - Not working
if Feature is disabled,
Both logic 1 & 2 - Working
Note: We had to enable this feature, since we are trying to print/save document which has more than 300+ lines. As per suggestion from MS.
Kindly advise with some input on this.
Thanks in advance.
Thanks,
Sangeeth