API Reference
HtmlToPdfOptions
Controls direct HTML layout and PDF generation. Layout, resource, page, and safety settings are inherited from HtmlRenderOptions.
Inheritance
- HtmlRenderOptions
- HtmlToPdfOptions
Usage
Explore 24 API references to this type
This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.
Returned or exposed by 3
Accepted by parameters 21
- Extension method HtmlConversionDocument.SaveAsPdf
- Extension method HtmlConversionDocument.SaveAsPdfAsync
- Extension method HtmlConversionDocument.SaveAsPdfResult
- Extension method HtmlConversionDocument.SaveAsPdfResultAsync
- Extension method HtmlConversionDocument.ToPdfBytes
- Extension method HtmlConversionDocument.ToPdfBytesAsync
- Extension method HtmlConversionDocument.ToPdfDocument
- Extension method HtmlConversionDocument.ToPdfDocumentAsync
- Extension method HtmlConversionDocument.ToPdfDocumentResult
- Extension method HtmlConversionDocument.ToPdfDocumentResultAsync
- Method HtmlPdfConverterExtensions.SaveAsPdf
- Method HtmlPdfConverterExtensions.SaveAsPdfAsync
- Method HtmlPdfConverterExtensions.SaveAsPdfResult
- Method HtmlPdfConverterExtensions.SaveAsPdfResultAsync
- Method HtmlPdfConverterExtensions.ToPdfBytes
- Method HtmlPdfConverterExtensions.ToPdfBytesAsync
- Method HtmlPdfConverterExtensions.ToPdfDocument
- Method HtmlPdfConverterExtensions.ToPdfDocumentAsync
- Method HtmlPdfConverterExtensions.ToPdfDocumentResult
- Method HtmlPdfConverterExtensions.ToPdfDocumentResultAsync
- Method HtmlPdfResourcePolicySummary.From
Examples
var options = new HtmlToPdfOptions {
PageSize = OfficePageSizes.A4,
Margins = HtmlRenderMargins.All(32),
DefaultFontFamily = "Arial"
};
byte[] pdf = HtmlConversionDocument.Parse(html).ToPdfBytes(options);Constructors
public HtmlToPdfOptions() #Creates direct paged HTML-to-PDF options using the standard defaults.
public HtmlToPdfOptions(HtmlRenderOptions renderOptions) #Creates PDF-capable options from shared HTML rendering settings without changing their layout mode. PDF conversion enforces paged layout on its own conversion snapshot.
Parameters
- renderOptions OfficeIMO.Html.HtmlRenderOptions
- Shared settings used by PNG, SVG, and PDF rendering.
Methods
public override HtmlRenderOptions Clone() #HtmlRenderOptionsCreates an independent options snapshot.
public HtmlToPdfOptions ClonePdf() #HtmlToPdfOptionsCreates an independent options snapshot for one PDF conversion.
public HtmlPdfResourcePolicySummary GetResourcePolicySummary() #HtmlPdfResourcePolicySummaryReturns a snapshot of the active HTML resource policy.
Inherited Methods
public OfficeImageExportResult EnsureAccepted(OfficeImageExportResult result) #OfficeImageExportResultParameters
- result OfficeImageExportResult
public virtual Boolean Equals(Object? obj) #BooleanParameters
- obj Object?
public Double GetEffectiveScale(Double logicalWidth, Double logicalHeight) #DoubleParameters
- logicalWidth Double
- logicalHeight Double
public HtmlRenderOptions UseBrowserUserAgentStyles() #HtmlRenderOptionspublic HtmlRenderOptions UseTextHyphenationLexicon(OfficeTextHyphenationLexicon? lexicon) #HtmlRenderOptionsParameters
- lexicon OfficeTextHyphenationLexicon?
Properties
public PdfTextFallbackFeatures TextFallbacks { get; set; } #OfficeIMO-managed font fallback groups used by generated PDF text.
public PdfTextShapingMode TextShapingMode { get; set; } #Dependency-free shaping mode used by generated PDF text.
public PdfEmbeddedFontFamily? FontFamily { get; set; } #Optional caller-supplied embedded font family used by generated PDF text.
public Boolean InteractiveFormControls { get; set; } #Converts supported standard HTML inputs, text areas, and selects into interactive AcroForm fields. Disable this to retain the shared renderer's static control paint in the PDF.
public DateTimeOffset? MathMlSourceModificationDate { get; set; } #Optional caller-supplied modification date for generated Formula MathML associated files.
public Boolean AutoFitWidePrintContent { get; set; } #Fits visible layout overflow, including fixed-width descendants and tables, into a uniform CSS print page. Clipped descendants and paint-only shadows do not widen the layout. Fitting retains the physical CSS media context and uses bounded reflow. Named and page-specific rules require an explicit fitting width. Set to false to retain unscaled print layout. An explicit HtmlToPdfOptions.PrintLayoutWidthCssPixels takes precedence.
public Double? PrintLayoutWidthCssPixels { get; set; } #Optional wider CSS layout width for print-to-page fitting. The PDF keeps HtmlRenderOptions.PageSize as its physical size while the paged layout is uniformly reduced to fit its width. CSS media queries and responsive resource selection continue to use HtmlRenderOptions.ViewportWidth. When HtmlRenderOptions.HonorCssPageRules is true, the resolved authored page size and margins remain the physical PDF geometry while the content is reduced to fit its printable width. The requested width must exceed that printable width.
public Int32 MaxOutlinedTextCharactersPerRun { get; set; } #Maximum UTF-16 characters expanded into vector font outlines for one rendered text run. Raise this only for trusted documents with unusually long unbroken text.
public Int32 MaxOutlinedTextPathCommands { get; set; } #Maximum path commands generated by text outlines across one PDF conversion.
public PdfOptions PdfOptions { get; set; } #PDF writer settings used for the generated document, including file version, forward-only serialization, tagging, compliance groundwork, and output intents.
public IOfficeTextShapingProvider? TextShapingProvider { get; set; } #Optional host-provided shaping seam used with caller-supplied or resolved embedded fonts.
public PdfResourcePolicy ResourcePolicy { get; set; } #Host-resource policy. Defaults to balanced conversion: system fonts and bounded in-source resources are allowed, while local and remote reads are denied.
Inherited Properties
public HtmlRenderFidelityPolicy FidelityPolicy { get; set; } #public Boolean? ProjectSerializedShadowRoots { get; set; } #public Double? ViewportHeight { get; set; } #public OfficePageSize PageSize { get; set; } #public Boolean HonorCssPageRules { get; set; } #public HtmlRenderMargins Margins { get; set; } #public String DefaultFontFamily { get; set; } #public Boolean AllowSystemFontFallback { get; set; } #public Double DefaultFontSize { get; set; } #public Double DefaultLineHeight { get; set; } #public HtmlRenderUserAgentStyleMode UserAgentStyles { get; set; } #public OfficeTextHyphenationCallback? TextHyphenationCallback { get; set; } #public HtmlRenderMediaFeatures MediaFeatures { get; set; } #public IList<String> AdditionalStylesheets { get; } #public HtmlUrlPolicy UrlPolicy { get; set; } #public HtmlUrlPolicy? ResourceUrlPolicy { get; set; } #public HtmlRenderResourceResolver? ResourceResolver { get; set; } #public TimeSpan ResourceTimeout { get; set; } #public Int32 MaxConcurrentResourceLoads { get; set; } #public Int64 MaxResourceBytes { get; set; } #public Int64 MaxTotalResourceBytes { get; set; } #public Int32 MaxResourceCount { get; set; } #public Int32 MaxResourceRequests { get; set; } #public Int32 MaxStylesheetImportDepth { get; set; } #public Int32 MaxSurfaceWidth { get; set; } #public Int32 MaxSurfaceHeight { get; set; } #public Int32 MaxProjectedVisuals { get; set; } #public Int32 MaxInputCharacters { get; set; } #public Int32 MaxBackgroundImageTiles { get; set; } #public Int32 MaxBackgroundImageLayers { get; set; } #public Int32 MaxBoxShadowLayers { get; set; } #public Int32 MaxTextShadowLayers { get; set; } #public Int32 MaxLeaderCharacters { get; set; } #public Int32 MaxSvgForeignObjectDepth { get; set; } #public Int32 MaxSvgForeignObjectHtmlNodes { get; set; } #public Int32 MaxGradientStops { get; set; } #public Int32 ConicGradientQualitySegments { get; set; } #public Int32 MaxTableColumns { get; set; } #public Int32 MaxCollapsedTableBorderSegments { get; set; } #public Int32 MaxLayoutOperations { get; set; } #public Int32 MaxRunningStringCharacters { get; set; } #public HtmlCssMediaContext MediaContext { get; } #public Double Scale { get; set; } #public Int32? MaximumOutputWidth { get; set; } #public Int32? MaximumOutputHeight { get; set; } #public OfficeColor BackgroundColor { get; set; } #public OfficeRasterEncodingOptions RasterEncoding { get; set; } #public Boolean SvgTextAsPaths { get; set; } #public Int64 MaximumRasterPixels { get; set; } #public OfficeRasterOverflowBehavior RasterOverflowBehavior { get; set; } #public IOfficeRasterImageCodec? ImageCodec { get; set; } #public Double? TargetDpi { get; set; } #public OfficeFontFaceCollection Fonts { get; set; } #public String? TextShapingLanguage { get; set; } #public OfficeImageExportPolicy Policy { get; set; } #public IProgress<OfficeImageExportProgress>? Progress { get; set; } #public Int32 MaximumOutputCount { get; set; } #public Int64 MaximumTotalRasterPixels { get; set; } #public Int64 MaximumTotalEncodedBytes { get; set; } #public TimeSpan RenderTimeout { get; set; } #public Int32 MaximumDegreeOfParallelism { get; set; } #public virtual Double LogicalUnitsPerInch { get; } #