Search Results for

    Show / Hide Table of Contents

    Class Cleaner

    The Cleaner class can be used to scan or sanitize (remove any potentially harmful content) PDF document.

    Inheritance
    System.Object
    Cleaner
    Namespace: IronPdf
    Assembly: IronPdf.dll
    Syntax
    public static class Cleaner : Object

    Methods

    SanitizeWithBitmap(PdfDocument)

    Sanitize PDF by convert PDF To an Bitmap image and convert it back to PDF. Returns a new PdfDocument object with additional zero margins, preserving the original layout.

    Declaration
    public static PdfDocument SanitizeWithBitmap(PdfDocument pdfDocument)
    Parameters
    Type Name Description
    PdfDocument pdfDocument

    PDF document to sanitize.

    Returns
    Type Description
    PdfDocument

    SanitizeWithBitmap(PdfDocument, ChromePdfRenderOptions)

    Sanitize PDF by converting it to a Bitmap image and then back to a PDF, using custom render options.

    ⚠️ This method will override the VirtualPaperLayoutManager (PaperFit) and paper size settings on the provided renderOption object to ensure the sanitized output matches the original document's dimensions. Other settings, such as margins, will be respected.

    • Slower than SanitizeWithSvg(PdfDocument, ChromePdfRenderOptions)
    • Visually looks the same
    • Result is a non-searchable PDF
    Declaration
    public static PdfDocument SanitizeWithBitmap(PdfDocument pdfDocument, ChromePdfRenderOptions renderOption)
    Parameters
    Type Name Description
    PdfDocument pdfDocument

    PDF document to sanitize.

    ChromePdfRenderOptions renderOption

    Custom render options for the output PDF (margins respected, paper size/fit overridden).

    Returns
    Type Description
    PdfDocument

    SanitizeWithBitmap(String)

    Sanitize PDF by convert PDF To an Bitmap image and convert it back to PDF. Returns a new PdfDocument object.

    Declaration
    public static PdfDocument SanitizeWithBitmap(string pdfFilePath)
    Parameters
    Type Name Description
    System.String pdfFilePath

    Path to the PDF file to sanitize.

    Returns
    Type Description
    PdfDocument

    SanitizeWithBitmap(String, ChromePdfRenderOptions)

    Sanitize PDF by converting it to a Bitmap image and then back to a PDF, using custom render options. Returns a new PdfDocument object.

    Declaration
    public static PdfDocument SanitizeWithBitmap(string pdfFilePath, ChromePdfRenderOptions renderOption)
    Parameters
    Type Name Description
    System.String pdfFilePath

    Path to the PDF file to sanitize.

    ChromePdfRenderOptions renderOption

    Custom render options for the output PDF (margins respected, paper size/fit overridden).

    Returns
    Type Description
    PdfDocument

    SanitizeWithSvg(PdfDocument)

    Sanitize PDF by convert PDF To an SVG image and convert it back to PDF. Returns a new PdfDocument object.

    • Quicker than SanitizeWithBitmap(PdfDocument)
    • Result is a searchable PDF
    • Layout might be inconsistent.
    Declaration
    public static PdfDocument SanitizeWithSvg(PdfDocument pdfDocument)
    Parameters
    Type Name Description
    PdfDocument pdfDocument

    PDF document to sanitize.

    Returns
    Type Description
    PdfDocument

    SanitizeWithSvg(PdfDocument, ChromePdfRenderOptions)

    Sanitize PDF by converting it to an SVG image and then back to a PDF, using custom render options.

    ⚠️ This method will override the VirtualPaperLayoutManager (PaperFit) and paper size settings on the provided renderOption object to ensure the sanitized output matches the original document's dimensions. Other settings, such as margins, will be respected.

    • Quicker than SanitizeWithBitmap(PdfDocument, ChromePdfRenderOptions)
    • Result is a searchable PDF
    • Layout might be inconsistent.
    Declaration
    public static PdfDocument SanitizeWithSvg(PdfDocument pdfDocument, ChromePdfRenderOptions renderOption)
    Parameters
    Type Name Description
    PdfDocument pdfDocument

    PDF document to sanitize.

    ChromePdfRenderOptions renderOption

    Custom render options for the output PDF (margins respected, paper size/fit overridden).

    Returns
    Type Description
    PdfDocument

    SanitizeWithSvg(String)

    Sanitize PDF by convert PDF To an SVG image and convert it back to PDF. Returns a new PdfDocument object.

    • Quicker than SanitizeWithBitmap(PdfDocument)
    • Result is a searchable PDF
    • Layout might be inconsistent.
    Declaration
    public static PdfDocument SanitizeWithSvg(string pdfFilePath)
    Parameters
    Type Name Description
    System.String pdfFilePath

    Path to the PDF file to sanitize.

    Returns
    Type Description
    PdfDocument

    SanitizeWithSvg(String, ChromePdfRenderOptions)

    Sanitize PDF by converting it to an SVG image and then back to a PDF, using custom render options. Returns a new PdfDocument object.

    • Quicker than SanitizeWithBitmap(String, ChromePdfRenderOptions)
    • Result is a searchable PDF
    • Layout might be inconsistent.
    Declaration
    public static PdfDocument SanitizeWithSvg(string pdfFilePath, ChromePdfRenderOptions renderOption)
    Parameters
    Type Name Description
    System.String pdfFilePath

    Path to the PDF file to sanitize.

    ChromePdfRenderOptions renderOption

    Custom render options for the output PDF (margins respected, paper size/fit overridden).

    Returns
    Type Description
    PdfDocument

    ScanPdf(PdfDocument, String[])

    Scan for any risk that might exists in a PDF.

    Declaration
    public static CleanerScanResult ScanPdf(PdfDocument pdfDocument, string[] yaraFiles = null)
    Parameters
    Type Name Description
    PdfDocument pdfDocument

    a PdfDocument object

    System.String[] yaraFiles

    Optional external yara rule files, this will override the default yara rules

    Returns
    Type Description
    CleanerScanResult

    scan result as an CleanerScanResult object

    ScanPdf(Byte[], String[])

    Scan for any risk that might exists in a PDF.

    Declaration
    public static CleanerScanResult ScanPdf(byte[] pdfBytes, string[] yaraFiles = null)
    Parameters
    Type Name Description
    System.Byte[] pdfBytes

    a PDF bytes

    System.String[] yaraFiles

    Optional external yara rule files, this will override the default yara rules

    Returns
    Type Description
    CleanerScanResult

    scan result as an CleanerScanResult object

    ScanPdf(String, String[])

    Scan for any risk that might exists in a PDF.

    Declaration
    public static CleanerScanResult ScanPdf(string pdfFilePath, string[] yaraFiles = null)
    Parameters
    Type Name Description
    System.String pdfFilePath

    A PDF File path

    System.String[] yaraFiles

    Optional external yara rule files, this will override the default yara rules

    Returns
    Type Description
    CleanerScanResult

    scan result as an CleanerScanResult object

    ☀
    ☾
    Downloads
    • Download with Nuget
    • Start for Free
    In This Article
    Back to top
    Install with Nuget
    Want to deploy IronPDF to a live project for FREE?
    What’s included?
    30 days of fully-functional product
    Test and share in a live environment
    No watermarks in production
    Get your free 30-day Trial Key instantly.
    No credit card or account creation required
    Your Trial License Key has been emailed to you.
    Download IronPDF free to apply
    your Trial Licenses Key
    Install with NuGet View Licenses
    Licenses from $499. Have a question? Get in touch.