Documentation

Checking conversion fidelity

Conforming to PDF/A is not the same as looking like the input. CheckFidelity renders both sides and reports a per-page comparison so content loss is visible.

Conforming to PDF/A is not the same as looking like the input — a page blanked during conversion still verifies clean. Options.CheckFidelity renders the input and the output and reports a per-page comparison so you can catch that.

fidelity.go
// Conforming to PDF/A is not the same as *looking* like the input -- a page
// blanked during conversion still verifies clean.
cr, err := gopdfrab.ConvertContext(ctx, path, gopdfrab.PDFA1B,
	gopdfrab.Options{CheckFidelity: true})
defer cr.Close()

for _, pf := range cr.Fidelity {
	if pf.Blanked() {
		log.Printf("page %d lost its content during conversion", pf.Page)
	}
}

// Content the rasterizer could not draw is reported, never silently omitted
for _, d := range cr.RasterDrops {
	log.Printf("page %d: dropped %v", d.Page, d.Features)
}

cr.RasterizedPages // pages rebuilt as a flat image

Both sides are drawn by the same rasterizer, so its limitations cancel and the comparison isolates what the conversion changed. Blanked() flags unambiguous content loss without tripping on benign changes like font substitution.

When conversion has to rasterize a page as a last resort, anything the rasterizer cannot draw — shadings, inline images, Type 3 fonts — is reported per page in RasterDrops rather than silently omitted, so that loss is loud even though the pixel comparison (which drops it symmetrically) cannot see it.

Fidelity checking costs a render of both documents, so it is off by default. Turn it on for archival pipelines, where a silently blanked page is far more expensive than the extra CPU, and for spot-checking a new class of input before you trust it in bulk.