Free Support Forum - aspose.com

Missing Bookmarks

I am using Aspose.Cells and converting the Excel to PDF. I am applying bookmarks to the PDF with workbookDesigner.Workbook.SaveOptions.PdfBookmark

After applying the bookmarks to PDF, I converted the workbookDesigner to MemoryStream and returned from a method. When I tried to convert this MemoryStream back to WorkbookDesigner object, it deletes the applied bookmarks.

Can you please suggest, Why this is happening and how to prevent the applied bookmarks while converting back to WorkbookDesigner from MemoryStream?

Regards,
Ankush

Hi Ankush,

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

Thank you for considering Aspose.

Please try the attached latest version of Aspose.Cells. If you still face any problem, please share your sample code and template file (if any) to reproduce the issue. We will check it soon.

Thank You & Best Regards,

Hi Aslam,

I tried the attached DDL but still facing the same problem.

Remember, I am applying bookmarks to the PDF with using
workbookDesigner.Workbook.SaveOptions.PdfBookmark

After applying the bookmarks to PDF, I converted the workbookDesigner to MemoryStream and returned from a method. When I tried to convert this MemoryStream back to WorkbookDesigner object, it deletes the applied bookmarks.

Sample Code below

public MemorySteam GetPDF()
{
WorkbookDesigner workbookDesigner = new WorkbookDesigner();
workbookDesigner.Open(memStream); //Loads an excel file which already loaded in MemorySteam

//Now applied the bookmarks into it.
PdfBookmarkEntry pdfBookMarks = new PdfBookmarkEntry();
PdfBookmarkEntry bookmarkChild = null;
foreach (Worksheet worksheet in workbookDesigner.Workbook.Worksheets)
{
bookmarkChild = new PdfBookmarkEntry();
bookmarkChild.Text = worksheet.Name;
bookmarkChild.Destination = Cell["A3"];
pdfBookMarks.SubEntry.Add(bookmarkChild);
}

//Add bookmarks
workbookDesigner.Workbook.SaveOptions.PdfBookmark = pdfBookMarks;

//Bookmarks exists till this point in WorkBookDesigner object
MemoryStream stream = workbookDesigner.Workbook.SaveToStream();
}

MemorySteam str = GetPDF();
WorkbookDesigner workbookDesigner = new WorkbookDesigner();
workbookDesigner.Open(str);

//Bookmarks doesnot exist in the WorkBook Designer object anymore
if (workbookDesigner.Workbook.SaveOptions.PdfBookmark != null)
{
//-------------------
//-------------------
}


Regards,
Ankush

Hi Ankush,

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

Well, SaveOptions is not a setting of Excel file formats and Workbook.SaveToStream() saves workbook to an Excel format, so it will not save the SaveOptions settings. You need to reset SaveOptions setting after opening the workbook.

Thank You & Best Regards,