We are currently evaluating Aspose.PDF for converting HTML documents into PDF format. We would like to understand the CSS properties that are fully supported during the conversion process.
Having this information will help us create PDF without any inconsistencies.
@vikrantm
Summary
Aspose.PDF can convert HTML to PDF, but the exact set of CSS properties it supports is documented by Aspose and not detailed in the provided evidence. To know which CSS rules will be rendered correctly, refer to the official “Supported CSS properties” section for the specific Aspose.PDF SDK you are using.
Why it happens
During conversion Aspose.PDF parses the HTML and applies only those CSS properties that its rendering engine implements. Any property that is not implemented is ignored, which can cause visual differences between the source HTML and the generated PDF.
What to do next
- Locate the official list
- Open the Aspose.PDF documentation for your platform (e.g., .NET, Java, Python).
- Navigate to the HTML to PDF conversion topic.
- Look for a table or paragraph titled Supported CSS properties (or similar). This list enumerates every CSS property the converter recognises.
- Validate with a small test
// Example for .NET
using Aspose.Pdf;
using Aspose.Pdf.HtmlLoadOptions;
var html = @"<html><head><style>
body {font-family:Arial; font-size:12pt; color:#333; margin:20px;}
h1 {color:#0066CC; margin-bottom:10px;}
.box {border:1px solid #000; padding:5px; background:#F0F0F0;}
</style></head><body>
<h1>Test</h1><div class='box'>Sample content</div>
</body></html>";
var pdfDoc = new Document();
var loadOptions = new HtmlLoadOptions(); // uses the built‑in CSS engine
pdfDoc.Pages.Add();
pdfDoc.Pages[1].Paragraphs.Add(new Aspose.Pdf.HtmlFragment(html, loadOptions));
pdfDoc.Save("output.pdf");
- Modify the CSS rules you plan to use, generate the PDF, and compare the result with a browser rendering. If a rule does not appear, it is likely not supported.
- Search the Aspose knowledge base or forums
- Look for topics such as “Supported CSS properties for HTML to PDF”. Community posts often reference the same list or share practical tips.
- Work‑around unsupported features
- Simplify the layout to use only the supported CSS properties.
- Alternatively, apply the desired visual effect directly in the PDF after conversion using Aspose.PDF’s drawing APIs.
- Keep the library up‑to‑date
- Newer releases may add support for additional CSS features. Review the release notes of the version you are using for any CSS‑related enhancements.
Note: The current evidence does not contain a detailed list of supported CSS properties, so the above steps guide you to the official source where the definitive information resides.
I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.