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

Free Support Forum - aspose.com

Document outline and bookmark difficulty

Hi aspose<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

I’m working with document outline and bookmarks when converting a word file in to a pdf file. When I convert my Word file, I set the PdfSaveOptions’ HeadingsOutlineLevels to 1.

var document = new Aspose.Words.Document(OriginalFilePath);

var options = new PdfSaveOptions

{

HeadingsOutlineLevels = 1,

Compliance = PdfCompliance.PdfA1b

};

document.Save(DestinationFile, options);

After Im done saving the file, I add a new page into the file and adds bookmarking.

//Add attachements

var bookmarks = new List<Bookmark>();

var delimiterpage = CreateEnclosureNotSupportedFiletype(destinationDirectoryInfo, enclosure, agendaItem, agendaData, fi);

//open delimiter document

var pdfdelimiter = new Aspose.Pdf.Document(delimiterpage);

//add delimiter document to main document

pdfDocument1.Pages.Add(pdfdelimiter.Pages);

//create bookmark to the delimiter page

var bookmarkTitle = string.Format("{0}.{1} Bilag {2}", PrependZero(agendaItem.Sort), PrependZero(enclosure.Sort), enclosure.Name);

bookmarks.Add(new Bookmark { PageNumber = pdfDocument1.Pages.Count, Title = bookmarkTitle });

I save the convert pdf with the new page add and open the PdfBookmarkEditor, change the title of the bookmark, resort the bookmarks, create the bookmarks in bookmark editor and save the final file.

//Save agenda with enclosures

pdfDocument1.Save(finalSaveFileName);

//Create bookmarks

var bookmarkEditor = new Aspose.Pdf.Facades.PdfBookmarkEditor(pdfDocument1);

bookmarkEditor.BindPdf(pdfDocument1);

foreach (Bookmark item in bookmarkEditor.ExtractBookmarks()) {

var nr = PrependZero(number);

item.Title = item.Title.Replace(number.ToString(CultureInfo.InvariantCulture), nr);

if (item.Title.StartsWith("00"))

{

item.Title = item.Title.Substring(1, item.Title.Length - 1);

}

bookmarks.Add(item);

}

bookmarks.Sort(new BookmarkComparer());

foreach (var item in bookmarks)

{

bookmarkEditor.CreateBookmarks(item);

}

//Save agenda with bookmarks

bookmarkEditor.Save(finalSaveFileName);

I open the file in Adobe Reader and all this is working as expected. I can click on both the H1 (HeadingsOutline) and my custom created bookmarks and I jumps to the expected page. But then I open the final PDF file in Adobe Reader and go to “Files” and “Save as”, save the file with a new file name, try to click on the custom bookmark and it work, I jumps to the page, but then I click on a H1 (HeadingsOutline) bookmark nothing happens. I can click on a custom bookmark again and it work. Try to link on H1 bookmark and nothing happens and so on.

Is this a known error, if yes, is this fixed in a new release? In addition, is the any way to test my code with a newer version?

My current running Aspose.Pdf v6.8.0.0?

Hi Anders,

Thanks for contacting support and sorry for the delayed response. I have tried replicating the problem using one of my sample PDF files and I am afraid I am unable to reproduce it over my end. Can you please share some sample application with resource files so that we can again test the scenario at our end. We are sorry for this inconvenience.