Aspose.Pdf

Making Changes after a Conversion from Word to PDF

A very common use for Aspose.Pdf is the conversion of Word Documents to PDF. However, from time to time one may have a need to make further changes to a document after such a conversion. For example, suppose you would like to import the headings from a Word document and then convert them to bookmarks in the resulting PDF. How would you achieve that? Just simply do as follows

 

[C#]

 

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();


//Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF
//XML Schema.
pdf.BindXML(xmlDoc,null);


//Before saving, to add bookmarks from headings.
pdf.IsBookmarked = true;


foreach(Aspose.Pdf.Section sec in pdf.Sections)
{
  foreach(Aspose.Pdf.Paragraph para in sec.Paragraphs)
 {
   if(para is Heading)
   {
     Heading h = para as Heading;
     h.IsInList = true;
   }
 }
}


pdf.Save(outputFile);

 

[VB.Net]

 

Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()


'Object xmlDoc contains all contents from original word document in XML format defined in Aspose.PDF
'XML Schema.
pdf.BindXML(xmlDoc,Nothing)


'Before saving, to add bookmarks from headings.
pdf.IsBookmarked = True
Dim sec As Aspose.Pdf.Section


For Each sec In pdf.Sections
 Dim para As Aspose.Pdf.Paragraph
 For Each para In sec.Paragraphs
  If TypeOf para Is Heading Then
   Dim h As Heading = para as Heading
   h.IsInList = True
  End If
 Next
Next


pdf.Save(outputFile)

 

With that is mind you can easily see that when doing a conversion from any supported format to PDF, Aspose.Pdf provides you an easy yet powerful API for further modification.