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 :
Business Central forum
Under review by Community Managers

Under review

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

only one page out of 3 when uploading PDF to document attachments

Posted on by

Hi all!

I'm trying to upload binary data (PDF Files) to document attachments.

The value seems to be correct but the pdf in business central is is just one page out of 3 or more. 

What am I doing wrong ? 

Thank you so much for your help.

Code:

//Get Base64 string
                httpResponse.Content.ReadAs(Success);
//Convert base64
                FinalString := Base64Convert.FromBase64(Success);
 // fill fileContent and fileName
                BlobTable.Type := BlobTable.Type::PDF;
//Write to blob field "content"
                BlobTable.Content.CreateOutStream(FinalOStream);
                BlobTable.SetBinaryContent(FinalString);
//Create instream
                TempBlob.CreateInStream(FinalInstream);
//Assigne file name
                FileName := 'Test.pdf';
//download pdf file
                DownloadFromStream(FinalInstream, '', '', '', FileName)
//upload to document attachment sales invoice
                attachment.SaveAttachmentFromStream(FinalInstream, Recordr, Filename);

Data (Final String) example:

%PDF-1.7 %���� 5 0 obj <</Filter/FlateDecode/Length 2646>>stream X �[]o�6}/�����[���G�Xl��i�$���v��>�mٞ�G�h�m�?~/)R���4 �Θ������KRz��K�4�Js$���p��Ċ)���/(�$ǚi��� rd,&F!���[}�@/�Hck-Z�!⿶��+��h���qxDcm4Zܢ?}z�����F�_��/�b���� � �*5 smN����i�~#(�I����|V�:�}&�x�������~X�{ݍ������)�*�������� �<�z� D�֞JMO��PL���?�Z���~�+��b��:�=�ʠ�=���Njo�V��T~�Ztp�1��b���V�0�0 =��� �9xD=�?]�ѫ�)�������%�?4��*Zt.7�,���h�̈�Ir�핐�����x�o�i�3ƪI�7�Y��RLOR/�4��z�7�"����y:b�� $c�( ���8�4>l���DV����Z�����u��J�?Q�����ج��l�3�9�~C�6�U� q=C�%�2�^�<<g�?zC�%�дRhN�I!vN�R��߂B�e�,�H� K�T�*� �U��ʗ�r���XJ��i�.�h4�Ł8IMM�Ts^JĻ��ͪ��1���h��߈ �!��ֶ7B�H��٩����Ӑd���_����Z��Q����;$��F@�)3 #E�+z���U�Ss��pi�t��.[��wO˩�5����sv{w����i��m��_`CRpG!a�p�� n�1�%���v��oE�.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Business Central

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans