This articles explains to use the frame border-image for PDF exported documentation using Bold Report Report Writer component with Syncfusion PDF libraries.
You can refer the Report Writer documentation for getting the PDF document from Report.
You have to use Syncfusion.Pdf for use the frame border-image for PDF exported documentation. You can refer the following code snippet for how to use the frame border-image for PDF exported documentation.
[HttpPost]
public IActionResult RDLPDF()
{
// Export the RDL To PDF.
FileStream mainReportStream = new FileStream(_hostingEnvironment.WebRootPath + @"\Reports\SampleReport.rdl", FileMode.Open, FileAccess.Read);
BoldReports.Writer.ReportWriter writer = new BoldReports.Writer.ReportWriter();
writer.LoadReport(mainReportStream);
MemoryStream memoryStream = new MemoryStream();
writer.Save(memoryStream, BoldReports.Writer.WriterFormat.PDF);
// Download the generated export document to the client side.
memoryStream.Position = 0;
FileStreamResult fileStreamResult = new FileStreamResult(memoryStream, "application/pdf");
var fileStream1 = fileStreamResult.FileStream;
// Combine the Exported PDF and templatecombine
PdfDocument finalDoc = new PdfDocument();
FileStream fileStream2 = new FileStream(_hostingEnvironment.WebRootPath + @"\PDF\Template.pdf", FileMode.Open, FileAccess.Read);
// Creates a PDF stream for merging
Stream[] streams = { fileStream1, fileStream2 };
// Merges the PDF Document.
PdfDocumentBase.Merge(finalDoc, streams);
//Save the document into the stream
MemoryStream combinestream = new MemoryStream();
finalDoc.Save(combinestream);
combinestream.Position = 0;
FileStreamResult fileStreamResult1 = new FileStreamResult(combinestream, "application/pdf");
var pagenumber = fileStreamResult1.FileStream;
// Add a Page number for combined PDF
PdfLoadedDocument loadedDoc = new PdfLoadedDocument(pagenumber);
// Create a new PDF document
PdfDocument doc = new PdfDocument();
doc.PageSettings.Margins.All = 0;
//Add a page to the document
PdfPage page = doc.Pages.Add();
//Create PDF graphics for the page
PdfGraphics graphics = page.Graphics;
FileStream fileStream3 = new FileStream(_hostingEnvironment.WebRootPath + @"\f25e9269edfa67ef53e840eea0a98c30.jpg", FileMode.Open, FileAccess.Read);
//Load the image from the disk
PdfBitmap image = new PdfBitmap(fileStream3);
//Draw the image
graphics.DrawImage(image, 0, 0, page.GetClientSize().Width, page.GetClientSize().Height);
//Save the document
MemoryStream ms = new MemoryStream();
doc.Save(ms);
//Close the document
doc.Close(true);
//Load the border design PDF document
PdfLoadedDocument loadedDocument1 = new PdfLoadedDocument(ms);
//Create a new document
PdfDocument document = new PdfDocument();
document.PageSettings.Margins.All = 0;
//Add the border design in each page of an existing PDF document
for (int i = 0; i < loadedDoc.Pages.Count; i++)
{
//Add a PDF page
PdfPage pdfPage = document.Pages.Add();
//Create a template from the first document
PdfPageBase loadedPage = loadedDocument1.Pages[0];
PdfTemplate template = loadedPage.CreateTemplate();
//Draw the loaded template into a new document
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());
//Create a template from the second document
loadedPage = loadedDoc.Pages[i];
template = loadedPage.CreateTemplate();
//Draw the loaded template into a new document
pdfPage.Graphics.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());
}
MemoryStream pagenumberstream = new MemoryStream();
document.Save(pagenumberstream);
//Close the PDF documents
document.Close(true);
loadedDocument1.Close(true);
loadedDoc.Close(true);
string contentType = "application/pdf";
//Define the file name
string fileName = "Combinewithpagenumber.pdf";
//Creates a FileContentResult object by using the file contents, content type, and file name
pagenumberstream.Position = 0;
return File(pagenumberstream, contentType, fileName);
}