web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

pdf download from blob storage - not valid pdf file

(0) ShareShare
ReportReport
Posted on by 58

Hello

I just to tried to make the Saas File Management exercice from a BC book

Uploading a pdf file works fine

Downloading produces a file that is not valid - cannot be opened bye a pdf reader

I have the impression that the base64 variable does not change (in the debugging watch) when executing the base64Convert.FromBase64 function : 

...
httpResponse
.Content.ReadAs(base64);
base64 := DelChr(base64, '=''"');
base64Convert.FromBase64(base64);
tempblob.CreateOutStream(outstr);
...
When charging the file in an editor I see something beinning like this : 
JVBERi0xLjcNCiWhs8XXDQoxIDAgb2JqDQo8P ...

When modifying AL (the conversion part) and the related c# code to return the file content directly (no base 64) I get something more ressembling to a pdf file : 
%PDF-1.7 ...
but even this one is not valid

Does anybody have any idea what I'm doing wrong ?
I have the same question (0)
  • JAngle Profile Picture
    150 on at

    I’ve encountered a similar challenge. I’ve added this question on Twitter and used [tag:bcalhelp] as it is well tracked. Hopefully an answer follows on

  • Suggested answer
    ajkauffmann Profile Picture
    117 on at

    Don't remove the = at the end of the string. Base64 works with groups of 4 characters. The = is added as a padding at the end to ensure that the last group is also 4 characters.

    What is also going wrong is the call to Base64Convert. The purpose of the call is to return the original value.

    First of all you must catch the return value, like:

    MyText := Base64Convert.FromBase64(Base64Text)

    But in this case the result will not be text, it will be binary. So you should use the OutStream.

    In full, the code should be as follows:

    HttpResponse.Content.ReadAs(base64);
    TempBlob.CreateOutStream(outstr);
    Base64Convert.FromBase64(base64, outstr);

  • Verified answer
    gtr2 Profile Picture
    58 on at

    Thanks - works fine now :)

  • Verified answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Thank you Arend-Jan, I will ask the team to publish this on our CSS Twitter account to get more traction.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,091 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,032 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 946 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans