I basically have office documents(Word,Excel,PowerPoint) in byte[] format in Database. My goal is to convert these Documents to PDF with Headers(Title,Company Details) and Footers(Date,Page Numbers,Text) on each page.
I am already using seperate Aspose API(Word,Excel etc) based on the document we want to convert.
Requirement :
When Applying Header and Footer Do I need write separate code for All the Aspose Product ?
Some documents have Embedded Files which needs to be extracted and saved. How can I acheive this ?
We have looked into your requirements. For PowerPoint format, you may use Aspose.Slides to achieve the goal. You can set Header properties (title, Company Details) using Aspose.Slides.DocumentProperties class. HeaderFooterManager can be used for Footer (Date,Page Numbers,Text).
Once you are done with setting these elements in presentation then you will export to PDF format. In this way the resultant PDF will have footer text and properties will be listed in PDF properties. Please visit the following links for details.
My Query was do we need to separately write code for each product ??
for e.g this for Word Aspose.
Word.Document doc = new Word.Document(filestream);
this.ApplyDocumentDetails(doc, inDoc); // this code applies Header and footer to Word Document.using document builder option
doc.Save(filename, Word.SaveFormat.Pdf);
ref to apply header and footer
Or Do I apply header and footer once I convert to PDF ??
Yes, you need to write separate code snippets for each product. Each product have its own APIs to achieve the task. For example you can save the byte array of Excel document to streams and then open the file via Aspose.Cells API, manipulate headers, footers or add properties and save to PDF. Please visit the following links for details.
I am trying to apply the header and footer for Word Document section. using Applying Header and Footer for Word. header and footer is rendering with a table border. I need to remove border.
I have uploaded the Code Snippet and Sample Converted File. Sample.zip (31.0 KB)
Thanks It worked with the declaring Table object and then using the object.ClearBorders method.
As I was trying to use directly.
builder.StartTable().ClearBorders()
I also wanted to display a two seperate line of text Align to Right on header part.when I write second builder.write method It appends to the first line. something like this :
You can simply use DocumentBuilder.Writeln(string) method to meet this requirement. It inserts a string and a paragraph break into the document. Hope, this helps.
Well, you may easily put line breaks using escape sequence new line char ("\n"), see the line of code for your reference: pageSetup.SetHeader(2, "Report 1\nOn &N Page");
The header text can only be set in NoteSlideView inside slide. For other slide views there is no header and for that reason it is not directly available in HeaderFooterManger. Please try the following code example:
C#
public static void ManageHeader()
{
String path = @"C:\Aspose Data\";
Presentation presentation = new Presentation(path + "handout_header_footer.pptx");
IMasterHandoutSlide masterHandoutSlide = presentation.MasterHandoutSlideManager.MasterHandoutSlide;
if (masterHandoutSlide != null)
updateHeaderFooterText(masterHandoutSlide);
IMasterNotesSlide masterNotesSlide = presentation.MasterNotesSlideManager.MasterNotesSlide;
if (null != masterNotesSlide)
updateHeaderFooterText(masterNotesSlide);
foreach (ISlide slide in presentation.Slides)
{
INotesSlide notesSlide = slide.NotesSlideManager.NotesSlide;
if (null != notesSlide)
updateHeaderFooterText(notesSlide);
}
presentation.Save(path + "handout_test.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
}
public static void updateHeaderFooterText(IBaseSlide master)
{
foreach (IShape shape in master.Shapes)
{
if (shape.Placeholder != null)
{
if (shape.Placeholder.Type == PlaceholderType.Header)
((IAutoShape)shape).TextFrame.Text = "HI there new header";
if (shape.Placeholder.Type == PlaceholderType.Footer)
((IAutoShape)shape).TextFrame.Text = "HI there new footer";
}
}
}
If this does not help, then kindly send us your source presentation file along with expected output document. We will investigate and share our findings with you.