This is a migrated thread and some comments may be shown as answers.

Exporting Excel to PDF with letterhead

3 Answers 831 Views
SpreadProcessing
This is a migrated thread and some comments may be shown as answers.
Niraja
Top achievements
Rank 1
Niraja asked on 24 Jul 2020, 08:21 AM

Hi,

I'm trying to export excel to PDF with letter head on each page of the PDF. how can I achieve it? 

 

Thanks,

Niraja.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 24 Jul 2020, 11:59 AM

Hello Niraja,

This is supported and the following article shows how you can add a header to the workbook: Headers and Footers | Telerik Document Processing.

Let me know if you have any other questions.

Regards,
Dimitar
Progress Telerik

0
Niraja
Top achievements
Rank 1
answered on 18 Aug 2020, 08:03 AM

Hi Dimitar,

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.

Regards,
Dimitar
Progress Telerik

Tags
SpreadProcessing
Asked by
Niraja
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Niraja
Top achievements
Rank 1
Share this question
or