menu

Document Processing

PdfCompressionLevel Class - C# PDF Library API Reference | Syncfusion

    Show / Hide Table of Contents

    PdfCompressionLevel Class

    Defines data compression level.

    Inheritance
    System.Object
    PdfCompressionLevel
    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public sealed class PdfCompressionLevel : Enum
    Remarks

    Default value is Normal.

    Examples
    //Create a new PDF document.
    PdfDocument doc = new PdfDocument();
    //Create a new page.
    PdfPage page = doc.Pages.Add();
    //Set document compression level
    doc.Compression = PdfCompressionLevel.BestSpeed;
    //Obtain PdfGraphics object.
    PdfGraphics g = page.Graphics;
    //Create font with Bold font style.
    PdfFont font = new PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Bold);
    //Create pen with green color.
    PdfPen pen = new PdfPen(System.Drawing.Color.Green);
    //Create brush with black color.
    PdfBrush brush = new PdfSolidBrush(System.Drawing.Color.Black);
    RectangleF rect = new RectangleF(100, 100, 200, 100);
    //Draw text in the new page.
    g.DrawString("Simple Rectangle", font, PdfBrushes.DarkBlue, new PointF(310, 255));
    //Draw rectangle in the new page.
    g.DrawRectangle(pen, brush, rect);
    //Save the document.
    doc.Save("CompressionLevel.pdf");
    //Close the document.
    doc.Close(true);
    'Create a new PDF document.
    Dim doc As PdfDocument = New PdfDocument()
    'Creates a new page.
    Dim page As PdfPage = doc.Pages.Add()
    'Set document compression level.
    doc.Compression = PdfCompressionLevel.BestSpeed
    'Obtain PdfGraphics object.
    Dim g As PdfGraphics = page.Graphics
    'Create font with Bold font style.
    Dim font As PdfFont = New PdfStandardFont(PdfFontFamily.Helvetica, 14, PdfFontStyle.Bold)
    'Create pen with green color.
    Dim pen As PdfPen = New PdfPen(System.Drawing.Color.Green)
    'Create brush with black color.
    Dim brush As PdfBrush = New PdfSolidBrush(System.Drawing.Color.Black)
    Dim rect As RectangleF = New RectangleF(100, 100, 200, 100)
    'Draw text in the new page.
    g.DrawString("Simple Rectangle", font, PdfBrushes.DarkBlue, New PointF(310, 255))
    'Draw rectangle in the new page.
    g.DrawRectangle(pen, brush, rect)
    'Save document to disk.
    doc.Save("CompressionLevel.pdf")
    'Close the document.
    doc.Close(True)

    Fields

    AboveNormal

    Pack better but require a little more time.

    Declaration
    public const PdfCompressionLevel AboveNormal
    Field Value
    Type
    PdfCompressionLevel

    BelowNormal

    Something middle between normal and BestSpeed compressions.

    Declaration
    public const PdfCompressionLevel BelowNormal
    Field Value
    Type
    PdfCompressionLevel

    Best

    Use best compression, slow enough.

    Declaration
    public const PdfCompressionLevel Best
    Field Value
    Type
    PdfCompressionLevel

    BestSpeed

    Use high speed compression, reduce of data size is low.

    Declaration
    public const PdfCompressionLevel BestSpeed
    Field Value
    Type
    PdfCompressionLevel

    None

    Pack without compression.

    Declaration
    public const PdfCompressionLevel None
    Field Value
    Type
    PdfCompressionLevel

    Normal

    Use normal compression, middle between speed and size.

    Declaration
    public const PdfCompressionLevel Normal
    Field Value
    Type
    PdfCompressionLevel

    See Also

    PdfDocument
    PdfPage
    PdfFont
    PdfBrush
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved