There are no headers in default presentation view that you are using on your end in PowerPoint. The headers in PowerPoint are only available in NotesView of presentation. Even, if you set the header text using HeaderFooter manager class, it will not appear. I suggest you to please try using following sample code to observe headers in notes view.
private static void generatePDFFromPPT(String filename, String extension)
{
filename="C:\\Aspose Data\\TestText";
Presentation presentation = new Presentation(filename+".pptx");
//Add empty slide in the end
presentation.getSlides().addEmptySlide(presentation.getLayoutSlides().getByType((byte)SlideLayoutType.Blank));
presentation.getHeaderFooterManager().setAllHeadersVisibility(true);
presentation.getHeaderFooterManager().setAllFootersVisibility(true);
presentation.getHeaderFooterManager().setAllHeadersText("HEADER TEXT");
presentation.getHeaderFooterManager().setAllFootersText("FOOTER TEXT");
PdfOptions opts=new PdfOptions();
opts.getNotesCommentsLayouting().setNotesPosition(NotesPositions.BottomFull);
presentation.save(filename + ".pdf", SaveFormat.Pdf,opts);
}
The code sample that has been shared in my last post is applicable to both PPT and PPTX file. I have also added provision to add empty slide (empty page) at the end of generated PDF as well.
Can you please explain your requirement about JPEG and PNG formats too? What type of output you are looking for that. I am right, you want to export a JPEG or PNG image to PDF. If that is so, you can add image to blank presentation object with full slide size and export the presentation to PDF. You can please refer to this documentation link for inserting a JPEG or PNG image in slide and then export that to PDF to serve the purpose.
For your requirements, related to DOC and DOCX, we will share feedback with you shortly.
To convert a document (DOC, DOCX, RTF, ODT etc) to PDF, simply invoke the Document.Save method and specify a file name with the “.PDF” extension. The following Java code converts a whole document from DOC to PDF using default options:
Document doc = new Document("Template.doc");
doc.save(output.pdf);
Also, you can simply insert a Page Break to simulate addition of an extra empty page at the end of document.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.writeln("I am on first page");
// inserting a page break will add an empty page at the end
builder.moveToDocumentEnd();
builder.insertBreak(BreakType.PAGE_BREAK);
doc.save("E:\\Temp\\awjava-20.6.docx");
doc.save("E:\\Temp\\awjava-20.6.pdf");