Not able to print formatted comments using Aspose.Cells when generating pdf from excel

I have applied background color to excel cell comments. When I’m trying to generate PDF using Aspose Cells, the background color is not being displayed in PDF.

Can you pleae provide if there is any alternative way to apply exact formatting from excel to PDF

@susmithaputhana
By creating sample files for testing, we can discover that when the output file is sent to the PDF. The text color of the comment is missing, but the background color is correct. Please refer to the attachment (41.4 KB).

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CELLSNET-54213

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

In the example that is shared in the attachment, background color is displayed as it is a Notes.
If we add a comment and apply background color and generate PDF. That is not being displayed in PDF.

@susmithaputhana,

Could you please zip and attach your input Excel file (containing a comment with a background color applied)? This will help us to evaluate your issue accurately and consequently figure it out soon.

result.7z (7.5 KB)

Attaching the input excel file

@susmithaputhana,

Thanks for the sample file.

I checked your file and there is a setting applied for comment to be shown at the end of the sheet, check Page Setup|Sheet tab (Comments: at end of sheet). So, when you render to PDF, the comments will be rendered at the end of page (in simple text format). To accomplish your task, see the following lines of code (in bold) that you may try for your needs, it will render comment as it is displayed in the worksheet:
e.g.
Sample code:

Workbook workbook = new Workbook(“g:\test2\Result.xlsx”);
Worksheet sheet = workbook.Worksheets[0];
sheet.Comments[0].IsVisible = true;
sheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;
PdfSaveOptions options = new PdfSaveOptions();
//print one PDF per sheet
// options.OnePagePerSheet = true;
workbook.Save(“g:\test2\out1.pdf”, options);

I have attached the output PDF file for your reference. The comment box with background color is printed in the output PDF same as what MS Excel shows when viewing the Excel file into it.
out1.pdf (16.5 KB)

When I try to set the recommended option to print comments. I’m not able to see the entire comments in case of threaded comments.
Attached the screenshot for your reference
image.png (37.2 KB)

@susmithaputhana,

Thank you for providing the screenshot. Could you please zip the Excel file and attach it, along with the output PDF? We will review your issue promptly.

excel.zip (22.5 KB)

@susmithaputhana,
By using the following sample code for testing, we can obtain the correct results. The incomplete display of the comment content in ‘Sheet4’ is due to insufficient comment size, resulting in incomplete display of the text inside. If you export using MS-Excel, you will also get the same result. Please refer to the attachment (80.7 KB).

The sample code as follows:

Workbook workbook = new Workbook(filePath + "bid-28f612926fc748a681f793198d6cc14e-redactedfile.xlsx");
foreach (Worksheet sheet in workbook.Worksheets)
{
    sheet.PageSetup.PrintComments = PrintCommentsType.PrintInPlace;
    foreach (Comment comment in sheet.Comments)
    {
        comment.IsVisible = true;
    }
}

PdfSaveOptions options = new PdfSaveOptions();
//print one PDF per sheet
options.OnePagePerSheet = true;
workbook.Save(filePath + "out.pdf", options);

The issue still exists when we have threaded comments. Not able to see the entire the comments when using PrintCommentsType.PrintInPlace

@susmithaputhana
Would you like to provide the PDF file you generated? If you can provide screenshots and indicate the errors, it will be very helpful for us to locate the issue.

This is the PDF that you generated and shared. out.pdf (77.7 KB)

Can you please verify the Page 4
image.png (42.6 KB)

@susmithaputhana

As I mentioned earlier, the comment cannot be fully displayed because its length and width are not enough. Please use our modified file for testing, and after increasing the length and width, the comment can fully display all information. Please refer to the attachment (94.6 KB).

@susmithaputhana
Sorry for confusion by @John.He.
The comment of Page 4 is threaded comment. MS Excel only print it when printing comments at the end of sheet :sheet.PageSetup.PrintComments is PrintCommentsType.PrintSheetEnd
When printing comments in the place, MS Excel will ignore the threaded comments. You can print sheet4 in MS Excel with comment printing settings.
We will work as MS Excel to ignore the threaded comments when sheet.PageSetup.PrintComments is PrintCommentsType.PrintInPlace.
We have logged an issue Nanjing Redmine

@susmithaputhana,

This is to inform you that the issue has been resolved. The fix will be included in our upcoming release version (Aspose.Cells v23.10) scheduled for release in first half of October 2023. We will let you know when the next release is published.

The issues you have found earlier (filed as CELLSNET-54236) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi

@susmithaputhana
This is to inform you that the issue(CELLSNET-54213) has been resolved. The fix will be included in our upcoming release version (Aspose.Cells v24.1) scheduled for release in first half of January 2024. We will let you know when the next release is published.
Here is the resulting file I generated using the latest function:
CELLSNET-54213.pdf (36.8 KB)

The issues you have found earlier (filed as CELLSNET-54213) have been fixed in this update. This message was posted using Bugs notification tool by johnson.shi