@samirjaiswal
Issue Summary
You are seeing that table‑cell fill colors are lost when converting an RTF file (created with Word 2019/365 Build 2505 and later) to DOCX or PDF using Aspose.Words v21.9. The same RTF works correctly when it is created with an earlier build (2504) and when the same file is processed with newer Aspose.Words versions.
What We Know
Component |
Version |
Behaviour |
Aspose.Words |
21.9 (released 2024‑09) |
Cell shading is dropped for RTF files saved from Word 2019/365 Build ≥ 2505 |
Word (RTF authoring) |
2505‑2507 (Build 18827‑19029) |
RTF includes a <shading> tag that newer Word versions emit. |
Aspose.Words |
22.10 + (released 2024‑12) and later |
The issue was fixed – cell shading is preserved when loading the same RTF. |
The problem originates from the RTF parser in v21.9, which did not recognise the newer <shading>
attribute that Microsoft added starting with Build 2505. When the parser ignores this attribute, the shading information is lost, and consequently the PDF/DOCX output contains a plain‑white cell.
Immediate Recommendation
1. Upgrade to the Latest Aspose.Words Version
The fix is included in Aspose.Words v23.3 (release notes: Aspose.Words 23.3 Release Notes). Upgrading resolves the shading loss for all the Word builds you listed (2505‑2507).
# NuGet upgrade command (for .NET projects)
dotnet add package Aspose.Words --version 23.3.0
2. Verify After Upgrade
Re‑run your three steps:
- Open the RTF created with Build 2505 (or later).
- Convert to PDF/DOCX using the upgraded library.
- Confirm that the table‑cell background colour is retained.
You should see identical output to the file created with Build 2504.
Work‑around for v21.9 (if upgrading is not possible right now)
If you must stay on v21.9 for a short period, you can apply the following temporary workaround:
// Load the RTF with a custom LoadOptions that forces parsing of unknown tags
var loadOptions = new Aspose.Words.LoadOptions
{
// Preserve all formatting – this forces the parser to keep unknown RTF tags
LoadFormat = Aspose.Words.LoadFormat.Rtf,
// Enable preserving of markup that the old parser would otherwise ignore
PreserveOriginalFormatting = true
};
Document doc = new Document(@"Test.rtf", loadOptions);
// OPTIONAL: If the shading still does not appear, you can manually re‑apply it:
// (run this only for the affected tables/cells)
foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
foreach (Row row in table.Rows)
{
foreach (Cell cell in row.Cells)
{
if (cell.CellFormat.Shading.ForegroundPatternColor.IsEmpty)
{
// Example: set a light gray fill as a fallback
cell.CellFormat.Shading.BackgroundPatternColor = Color.LightGray;
}
}
}
}
// Save to PDF/DOCX
doc.Save(@"Test_fixed.pdf", SaveFormat.Pdf);
Caveats of the work‑around
- It relies on
PreserveOriginalFormatting
, which may increase memory usage for very large documents.
- The manual re‑apply block forces a default colour; you will need to know the intended colour if you want an exact match.
This approach is not a permanent fix—upgrading is the recommended solution.
Next Steps
- Upgrade to Aspose.Words v23.3 (or any newer version).
2 If you cannot upgrade immediately, apply the temporary work‑around above.
- Test with the exact RTF files you attached (or send a fresh copy) to confirm the issue is resolved.
If after upgrading you still encounter any discrepancies, please:
- Attach the original RTF, the output PDF/DOCX, and the code snippet you use for conversion.
- Open a support ticket via the Aspose Support Center so we can assign a dedicated engineer to investigate further.
Helpful Links
We appreciate your detailed reproduction steps. Upgrading should fully resolve the shading loss, and we are here to help if anything else arises.
Kind regards,
[Your Name] – Aspose.Words Support Engineer