Free Support Forum - aspose.com

Add Header while converting to PDF File

We want to convert Word,Excel,PPT, CAD Files to PDF.
We tried to use below code as provided in the documentation for converting to pdf.

We want to add header to the output pdf file.

  1. How to add header to the file being converted to pdf ?
  2. How to handle if the Input File already has a header?

Document:

Document doc=new Document(inputFileName);
doc.save(outputFileName);

Excel

Workbook workbook = new Workbook(inputFileName);
workbook.save(outputFileName);

PPT

Presentation presentation = new Presentation(inputFileName);
presentation.save(outputFileName, SaveFormat.Pdf);

CAD Files

Image image = Image.load(inputFileName);
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageSize(new SizeF(1200, 1200));
PdfOptions pdfOptions = new PdfOptions();
pdfOptions.setVectorRasterizationOptions(rasterizationOptions);
image.save(outputFileName, pdfOptions);

@rajum,

Thanks for the details.

Well, I think you should add header/footer to your input file formats (e.g DOC/DOCX, XLS/XLSX, PPT, etc.) via Aspose APIs, so when you convert to PDF, the headers would be retained. For example, see the document on how to add header to the Word document. Similarly using Aspose.Cells API, you may add headers/footers to the worksheet. Moreover, see the thread on how to add headers/footers to Powerpoint presentation using Aspose.Slides APIs:

Hope, this helps a bit.