Techniques are disclosed for determining the authenticity of a digital-origin document based, at least in part, on the code of the document. By determining authenticity based on the code of the document, authentication may take into account several features that are not detectable on the rendered image of a digital-origin document. The document class of a target document is initially determined. Anomalies are then detected in the code using various detectors, including but not limited to metadata-based detectors and content-based detectors. The output of the detectors may be combined to generate a document anomaly score that indicates likelihood that the document is not authentic.