microsoft / ALAppExtensions

Repository for collaboration on Microsoft AL application add-on and localization extensions for Microsoft Dynamics 365 Business Central.
MIT License
778 stars 613 forks source link

Procedure "ToBase64" from "Base64 Convert" codeunit cut the base64 string in some PDF files #17309

Closed aparras closed 2 years ago

aparras commented 2 years ago

1. Describe the bug I'm having a strange behavior when converting some PDF files to base64 by code. I have used the codeunit "Base64 Convert" with the function "ToBase64". I have also used the dotnet "Convert" with the function "ToBase64String" but the result is the same. The result is that a line is inserted into the Base64 string that says something like the line is too long and removes a part of the string. This only happens with some PDF files. Specifically a file that causes problems is a scanned PDF file but on a website that encodes PDF files to base64 the result is correct.

Also if we create a dll in c# the result is correct but using that dll from Business Central the result is incorrect.

2. To Reproduce Steps to reproduce the behavior:

  1. Add like document attachment a scanned PDF file or a too long PDF file to a purchase invoice.
  2. Try to convert to base64 string the document attachment using the codeunit "Base 64 Convert" and introduce the result into text variable without length..

3. Expected behavior The complete base64 as it appears on websites to convert PDF files to base64.

4. Actual behavior The result is a base64 shortened and with a line indicating that a part has been removed. Wrong Base64.txt

5. Versions:

marvingitau commented 3 months ago

Hello was this solved and how?