HTML to PDF¶
Converts an HTML document stream to PDF bytes using the Syncfusion HtmlToPdfConverter configured with the Internet Explorer rendering engine.
| Field | Value |
|---|---|
| Operation ID | OP-SFC-010 |
| Trigger | Called by Execute a single conversion (converter template) via HtmlConverter.ConvertItem, dispatched from Convert a source document to PDF for html |
| Inputs | Source Stream, ConvertRequest |
| Outputs | PDF byte[] |
| Primary components | HtmlConverter.ConvertItem |
| Entry point | PdfApi.SyncFusionCore\Convert\HtmlConverter.cs |
Steps¶
- Read the entire stream as a string using a default-encoding
StreamReader. - Create a
Syncfusion.HtmlConverter.HtmlToPdfConverterwithIEConverterSettings(Internet Explorer rendering engine) (BR-SFC-022). - Set
settings.IsPDFA1B = (request.Format == PdfFormat.PdfA)(BR-SFC-011). - This branch reads
request.Format, notrequest.Options.IsPdfaas the other converters do — the two are equivalent becauseConvertRequest.FormatproxiesOptions.OutputFormat. - Call
converter.Convert(html, "")with an empty base URL, save to aMemoryStream, and return the bytes (BR-SFC-023).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["ConvertItem called<br>with stream, request"]) --> Read[Read stream as string]
Read --> Create["Create HtmlToPdfConverter<br>with IEConverterSettings"]
Create --> SetPdfa["Set IsPDFA1B from<br>request.Format"]
SetPdfa --> Convert["converter.Convert html,<br>empty base URL"]
Convert --> Save[Save to MemoryStream]
Save --> Return([Return PDF bytes])
Failure and edge-case behavior¶
- Any Syncfusion conversion failure surfaces as an exception, which is caught by
Execute a single conversion (converter template) and turned into a failed
PdfResultrather than propagated here. - Relative resource references in the source HTML (images, stylesheets) do not resolve because the base URL is empty.
- Untrusted HTML is rendered in-process by a legacy browser engine with no sanitization or resource-access restriction configured.*
Related documentation¶
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Sources¶
PdfApi.SyncFusionCore\Convert\HtmlConverter.cs