PeachPDF

PeachPDF.PdfGenerateConfig

PdfGenerateConfig.SnapBoxDecorationsToCssPixels Property

When set to true, the rectangle each box’s decorations are painted on is snapped to whole CSS pixels (1px = 0.75pt), the way a browser does before it paints a box: every edge is rounded to the nearest pixel on its own, so a 1px border covers exactly one device pixel of a viewer showing the page at 100% zoom instead of two half-covered ones (which reads as a wider, paler line), and the background, outline and shadows meet it on the same edges.

Layout is unaffected; only what is painted moves, by at most half a CSS pixel (0.375pt), so text can sit that far off its box. The overflow clip of a box and the collapsed borders of a table are snapped with it.

Not snapped: replaced elements (<img>, inline <svg>, <iframe>, <math>), a <button> or <textarea> in its default appearance, multi-column rules, @page margin boxes and page borders, text decorations, list markers and anything under a transform. An edge where a box is cut across a page or line break stays where it is.

In PDFium the page size decides the result, not this option: it rounds the page up to a whole number of pixels and fills plain rectangles without anti-aliasing, so on A4 it draws a 1px rule as two rows with the option on or off. A page whose size is a whole number of CSS pixels (such as 794px 1123px) is crisp there either way. The option helps viewers that anti-alias fills.

Defaults to false: the exact fractional geometry is what a PDF can express, and what other CSS print engines write.

public bool SnapBoxDecorationsToCssPixels { get; set; }

Property Value

System.Boolean