The excel doesn't have any header or footer. But I want the pdf to have the company logo on each page of the PDF.
Thnaks,
Niraja.
0
Dimitar
Telerik team
answered on 18 Aug 2020, 01:15 PM
Hi Niraja,
You can add the logo after the document is exported to pdf. Here is an example:
var fixedPdfProvider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
var xlsxPdfProvider = new Telerik.Windows.Documents.Spreadsheet.FormatProviders.Pdf.PdfFormatProvider();
workbook.ActiveWorksheet.WorksheetPageSetup.Margins = new PageMargins(50, 100, 50, 20);
var fixedDocument = xlsxPdfProvider.ExportToFixedDocument(workbook);
MemoryStream image = new MemoryStream(File.ReadAllBytes(@"..\..\logo.png"));
foreach (var page in fixedDocument.Pages)
{
var editor = new FixedContentEditor(page);
editor.Position.Translate(300, 10);
editor.DrawImage(image);
}
var bytes = fixedPdfProvider.Export(fixedDocument);
File.WriteAllBytes(@"..\..\result.pdf", bytes);
Should you have any other questions do not hesitate to ask.