We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Generating bookmars using SEQ fields

Hi Team,


Can you please help with some sample code which helps in generating the bookmarks using SEQ fields of MS Word?
PFA - Sample word document and image with expected output.

Please let me know if you need more details.

Thanks,
Satyendra

Hi Satyendra,


Thanks for your inquiry. Unfortunately, your question isn’t clear enough therefore we request you to please elaborate your inquiry further. This will help us to understand your scenario, and we will be in a better position to address your concerns accordingly. Currently, you can format paragraphs with StyleIdentifier.Heading1 through StyleIdentifier.Heading9 styles and place Bookmarks in correct locations and then use different settings in PdfSaveOptions.OutlineOptions to achieve the desired results.

Best regards,

Hi Hafeez,


Basically, I want some code that will help me create PDF bookmarks using SEQ fields in the word document.

Is this possible using Aspose.Words?

If you look at the document (and press Alt + F9), then you will notice that the document has SEQ fields inserted for each text. I want to create bookmarks for such SEQ field text and the output I expect is like that of attached image in my previous message.

Thanks,
Satyendra

Hi Satyendra,


Thanks for your inquiry. We are working over your query and will get back to you soon.

Best regards,

Hi Satyendra,


Thanks for being patient. One way to achieve this is you can wrap SEQ fields inside Bookmarks and display them in outline in PDF. Please try executing the following code:

Document doc = new Document(MyDir + @“SEQ_Example_RUS.docx”);

DocumentBuilder builder = new DocumentBuilder(doc);

int i = 0;

foreach (Field field in doc.Range.Fields)

{

if (field.Type == FieldType.FieldSequence)

{

builder.MoveToField(field, true);

BookmarkStart bmStart = builder.StartBookmark("bookmark " + i);

builder.EndBookmark("bookmark " + i);

field.Start.ParentNode.InsertBefore(bmStart, field.Start);

i++;

}

}

PdfSaveOptions options = new PdfSaveOptions();

options.OutlineOptions.DefaultBookmarksOutlineLevel = 9;

doc.Save(MyDir + @“out.pdf”, options);


I hope, this helps.

Best regards,