Hello Friends,
As we know, Report.SaveAsPDF or Report.SaveAsExcel not supported in Business Central Cloud (SaaS) version.
We have an alternate code for solution. We can save Report in Stream objects than after convert to file using Blob Export function.
Here is the sample code to download work order report in PDF file with Customize file Name.
Hope this help someone to get solution of download pdf file in business central
Thank you for Reading...
Keep Sharing...Keep Growing....
As we know, Report.SaveAsPDF or Report.SaveAsExcel not supported in Business Central Cloud (SaaS) version.
We have an alternate code for solution. We can save Report in Stream objects than after convert to file using Blob Export function.
Here is the sample code to download work order report in PDF file with Customize file Name.
pageextension 50212 SalesOrderEx extends "Sales
Order"
{
layout
{
// Add
changes to page layout here
}
actions
{
// Add
changes to page actions here
addlast("&Print")
{
action("Download
Report")
{
ApplicationArea = All;
Image = ExportFile;
trigger OnAction()
var
TempBlob_lRec: Record TempBlob temporary;
Out: OutStream;
RecRef: RecordRef;
FileManagement_lCdu: Codeunit "File Management";
SalesHeader_lRec: Record "Sales Header";
begin
TempBlob_lRec.Blob.CreateOutStream(Out, TEXTENCODING::UTF8);
SalesHeader_lRec.Reset;
SalesHeader_lRec.SetRange("Document Type", Rec."Document Type");
SalesHeader_lRec.SetRange("No.", Rec."No.");
SalesHeader_lRec.FindFirst();
RecRef.GetTable(SalesHeader_lRec);
REPORT.SAVEAS(752, '', REPORTFORMAT::Pdf, Out, RecRef);
FileManagement_lCdu.BLOBExport(TempBlob_lRec, STRSUBSTNO('SalesOrder_%1.Pdf', "No."), TRUE);
end;
}
}
}
Hope this help someone to get solution of download pdf file in business central
Thank you for Reading...
Keep Sharing...Keep Growing....
This comment has been removed by the author.
ReplyDeleteThank you for very usefull information.. Eric Samek Brasa
ReplyDeleteHi,
ReplyDeleteThe TempBlob Record is no more in D 365BC wave2, So how we use Codeunit "Temp blob" please suggest on this to download PDF
This comment has been removed by the author.
ReplyDeleteThanks for this, i'm having issue with converting the blob to byte. Converting to byte is my main goal, because i want to use it on HttpClient.
ReplyDeleteThe file is always corrupt
When i tried to save it into file and open up the pdf, i couldn't even open it up. Please what i'm i doing wrong
ReportID := GetDocumentReportID(DocumentVariant);
DataTypeManagement.GetRecordRef(DocumentVariant,DocumentRef);
TempBlob.Blob.CREATEOUTSTREAM(VarOutStream);
REPORT.SAVEAS(ReportID,'',REPORTFORMAT::Pdf,VarOutStream,DocumentRef);
TempBlob.Blob.CREATEINSTREAM(VarInStream);
MemStream := MemStream.MemoryStream();
COPYSTREAM(MemStream,VarInStream);
bytes := MemStream.ToArray();
File.TEXTMODE(TRUE);
File.WRITEMODE(TRUE);
File.OPEN('C:\temp\test.pdf');
File.WRITE(Convert.ToBase64String(bytes));
File.CLOSE;
Terrific article! This is the type of information that should be shared across the web.
ReplyDeleteba 2nd semester result vikram university
Hi Nilesh, thank you for your article, it is very useful!
ReplyDeleteWe have to do the same but downloading more than one report (in our case we have invoices).
We are doing the same as you in a proccesing only report, we write your code in the OnAfterGetRecord trigger in "Sales Invoice Header" dataitem. In the request page we set an interval of Document No. (f.e: 7033..7035) and when we do the process we only received the last document in the interval (7035).
Could you help us?, Do you know what we could do to receive a pdf of each document?
Thank you for your time.
Alba Rey
Hi Alba,
DeleteWe are having the same problem. Did you come up with a solution?
Thanks for your help!
Saved as a favorite, I really like your ba final exam date blog!
ReplyDeletewant to download report from API ,direct pdf can you please suggest
ReplyDeletebilecik
ReplyDeletevan
elazığ
tokat
uşak
EB0
van
ReplyDeletezonguldak
yalova
urfa
gümüşhane
SHKO
izmir evden eve nakliyat
ReplyDeletemalatya evden eve nakliyat
hatay evden eve nakliyat
kocaeli evden eve nakliyat
mersin evden eve nakliyat
W3W30
54132
ReplyDeleteBitranium Coin Hangi Borsada
Tekirdağ Şehirler Arası Nakliyat
Trabzon Lojistik
Gümüşhane Evden Eve Nakliyat
Ağrı Parça Eşya Taşıma
Elazığ Parça Eşya Taşıma
Adana Lojistik
Loop Network Coin Hangi Borsada
Bitlis Lojistik
066E6
ReplyDeletetekirdağ canlı sohbet bedava
random görüntülü sohbet
sesli görüntülü sohbet
siirt rastgele sohbet
tokat yabancı sohbet
urfa mobil sohbet
adıyaman canlı sohbet odası
maraş parasız görüntülü sohbet uygulamaları
sesli sohbet sitesi
B6A08
ReplyDeleteSamsun Bedava Sohbet Chat Odaları
Osmaniye Sohbet Uygulamaları
Muş Canlı Sohbet Siteleri Ücretsiz
mobil sohbet odaları
Ardahan Sesli Sohbet Sesli Chat
Sivas Goruntulu Sohbet
mobil sohbet sitesi
Istanbul Görüntülü Sohbet Sitesi
ordu rastgele sohbet siteleri