Aspose.word for SharePoint

Hi,

I am using the Aspose.Words for SharePoint to convert the Word to PDF. When I convert is there any option to specify the Word Bookmark to PDF NamedDest? I want the bookmark to be used directly in the webpage Url like www.aspose.com/mypdf#nameddest=TOC

Please help.

Regards
Senthamil.

Hi Senthamil,

Thanks for your inquiry. Sure, you can achieve this by using the PdfOptions.BookmarksOutlineLevel property. Please read the following API page:

Aspose.Words for SharePoint|Documentation.

Best Regards,

Hi,

Thanks for the info. Currently I am trying to use that API in my conversion code. But I am not sure how to use it. Can you please share me any sample code to set this option before converting it to PDF?

Regards

Senthamil.

Hi Senthamil,


Thanks for your inquiry. Sure, you can specify options when converting documents to a PDF file as follows:

SPWeb web = SPContext.Current.Web;

SPFile srcFile = web.GetFile(Shared Documents/sample.docx);

PdfOptions pdfOptions = new PdfOptions();

// Make headings up to level 3 appear in the pdf outline:

pdfOptions.HeadingsOutlineLevels = 3;

// Expand the top outline level in pdf document:

pdfOptions.ExpandedOutlineLevels = 1;

// Overwrite existing files if needed

ConversionOptions options = new ConversionOptions();

options.OverwriteExistingFiles = true;

// Convert to PDF:

Converter.ConvertFileToPdf(srcFile, srcFile.ParentFolder, options, pdfOptions);


Please let me know if I can be of any further assistance.

Best regards,

Hi Awais hafeez,

Thanks for sharing the code. I have used this code and after word is converted to pdf the bookmarks and bookmark panel is coming and we can navigate to bookmark by clicking it in panel.

But i am not able to navigate to particular bookmark in web browser directly by passing the #nameddest as parameter in the pdf link. . I tried using below two option

http://servername/Share Document/Manual_Test/testbm1.pdf?#nameddest=test8 or

http://servername/Share%20Document/Manual_Test/testbm1.pdf#nameddest=test8

Below is code i have used:

PdfOptions pdfOptions = new PdfOptions();
pdfOptions.HeadingsOutlineLevels = 3;
pdfOptions.ExpandedOutlineLevels = 1;
pdfOptions.BookmarksOutlineLevel = 2;
ConversionOptions co = new ConversionOptions();
co.OverwriteExistingFiles = true;
ConvertedItem result = Converter.ConvertFileToPdf(sPFile, sPFile.ParentFolder,co,pdfOptions);

Please let us know if we need to do any thing else to use the nameddest parameter and navigate to bookmark directly using web browser.

Please find attached doc file which is converted to pdf.

Thanks & Regards,

Senthamil Selvan

Hi Senthamil,

Thanks for your inquiry.

Please note that Aspose.Words' page layout engine tries to mimic the way the Microsoft Word’s page layout engine works. To you, this means that if you convert a Microsoft Word document into PDF, XPS or print it using Aspose.Words, the output will appear almost exactly as if it was done by Microsoft Word. To confirm this, I have attached a PDF document, i.e. generated by using Microsoft Word 2007 on my side, here for your reference.

Also, please note that a Bookmark in PDF document is not a named destination. I think, the following link will help you in creating a named destination in PDF:
http://www.rcramer.com/tech/html/pdf.html

Best regards,

Hi Awais,

Thanks Awais for the quick reply.

Then, Is there any way we can created the nameddest while converting word to pdf using aspose?.

Thanks & Regards,

Senthamil Selvan

Hi Senthamil,

Thanks for your inquiry. I feel your query is more related to Aspose.PDF, I will move your request in Aspose.PDF forum. My colleagues from Aspose.PDF component team will answer you shortly.

Best regards,