Class CleanerScanResult
Contains the results of a PDF security scan, indicating detected threats and malware signatures. Returned by ScanPdf(PdfDocument, String[]) and related scanning methods.
Example - Check scan results:
var pdf = PdfDocument.FromFile("untrusted.pdf");
var result = Cleaner.ScanPdf(pdf);
if (result.IsDetected)
{
Console.WriteLine($"THREATS FOUND: {result.Risks.Count}");
foreach (var risk in result.Risks)
Console.WriteLine($" - {risk}");
// Do not process this PDF
}
else
{
Console.WriteLine("PDF is clean");
// Safe to process
}
Inheritance
Namespace: IronPdf
Assembly: IronPdf.dll
Syntax
public class CleanerScanResult : Object
Inspecting an untrusted PDF for malware becomes straightforward when Cleaner.ScanPdf hands back a CleanerScanResult: check IsDetected, enumerate Risks, and decide whether to proceed or discard the document.
IsDetected is a boolean that flips to true the moment any threat signature is found, making it the fastest gate in a validation pipeline. Risks is a List<string> that names every detected signature, giving enough detail to log the findings, alert a user, or route the file to quarantine. ToString serialises the result into a single human-readable string, convenient for structured logging or console diagnostics without manually iterating Risks. All three members are read-only by design: the object captures a point-in-time snapshot of the scan and cannot be mutated after ScanPdf returns it.
A typical usage pattern checks IsDetected first and only iterates Risks when a threat is present, keeping the happy path concise:
using IronPdf;
var pdf = PdfDocument.FromFile("untrusted.pdf");
CleanerScanResult result = Cleaner.ScanPdf(pdf);
if (result.IsDetected)
foreach (var risk in result.Risks)
Console.WriteLine($"Threat detected: {risk}");
else
Console.WriteLine(result.ToString()); // "PDF is clean"Because CleanerScanResult is a plain data record returned by the scanner rather than something you construct directly, it fits naturally into a larger document-processing pipeline: scan on ingest, branch on IsDetected, and pass only clean PdfDocument instances to downstream rendering or signing steps. See the PDF security how-to and the IronPDF examples for broader context on building safe document workflows.
Properties
IsDetected
Gets whether any security threats or malware signatures were detected in the PDF.
Returns true if Risks contains any items.
Example:
if (result.IsDetected)
throw new SecurityException("Malicious PDF detected");
Declaration
public bool IsDetected { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
|
Risks
Gets the list of detected security risks and malware signature names. Empty list if no threats were found.
Example:
foreach (var threat in result.Risks)
_logger.LogWarning($"PDF threat: {threat}");
Declaration
public List<string> Risks { get; }
Property Value
| Type | Description |
|---|---|
| System.Collections.Generic.List<System.String> | List of threat identifiers/names. Empty if clean. |
Methods
ToString()
A text summary of CleanerScanResult
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A text summary of CleanerScanResult |