Raster image to PDF¶
Converts a single raster image stream to a single-page PDF, stretching the image to fill the full page client area.
| Field | Value |
|---|---|
| Operation ID | OP-SFC-007 |
| Trigger | Called by Execute a single conversion (converter template) via ImageConverter.ConvertItem, dispatched from Convert a source document to PDF for gif/jpg/jpeg/png |
| Inputs | Source Stream, ConvertRequest |
| Outputs | PDF byte[] |
| Primary components | ImageConverter.ConvertItem |
| Entry point | PdfApi.SyncFusionCore\Convert\ImageConverter.cs |
Steps¶
- Choose conformance (
Pdf_A1B/None) and create thePdfDocument(BR-SFC-011). - Add exactly one page and read its client size (BR-SFC-016).
- Load the stream as a
PdfBitmapand draw it into a rectangle equal to the full page size — aspect ratio is not preserved (BR-SFC-017). - Save to a
MemoryStream, close the document, and return the bytes.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start(["ConvertItem called<br>with stream, request"]) --> Conf["Choose conformance,<br>create PdfDocument"]
Conf --> AddPage["Add one page,<br>read client size"]
AddPage --> LoadBmp[Load stream as PdfBitmap]
LoadBmp --> Draw["Draw image into full<br>page rectangle"]
Draw --> Save["Save to MemoryStream,<br>close document"]
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. - The source image's aspect ratio is not preserved; the image is stretched to the page's full client rectangle.
Related documentation¶
Sources¶
PdfApi.SyncFusionCore\Convert\ImageConverter.cs