Free Support Forum -

How to un hide and show comments while converting excel to pdf


Using aspose i am converting excel to pdf. But the comments added in all the sheets in the workbook as printing after converting to pdf. And if there is any hidden comment that also i need to unhide before printing. Please help me out in fixing this.


Thanks for your query.

You may please try following sample code and provide your feedback.

// Create a workbook from source Excel file
Workbook workbook = new Workbook(sourceDir + "samplePrintCommentWhileSavingToPdf.xlsx");

// Access first worksheet
Worksheet worksheet = workbook.Worksheets[0];

//Set all comments to visible
foreach(var comment in worksheet.Comments)
    comment.IsVisible = true;
    * For print no comments use "PrintCommentsType.PrintNoComments"
    * and for print the comments as displayed on sheet use "PrintCommentsType.PrintInPlace"
    * For Print the comments at the end of sheet we use "PrintCommentsType.PrintSheetEnd"
worksheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;

// Save workbook in pdf format
workbook.Save(outputDir + "outputPrintCommentWhileSavingToPdf.pdf"); (9.5 KB)