menu

WinForms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Enum PdfCompressionLevel - WindowsForms API Reference | Syncfusion

    Show / Hide Table of Contents

    Enum PdfCompressionLevel

    Defines data compression level.

    Namespace: Syncfusion.Pdf
    Assembly: Syncfusion.Pdf.Base.dll
    Syntax
    public enum PdfCompressionLevel
    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

    Name Description
    AboveNormal

    Pack better but require a little more time.

    BelowNormal

    Something middle between normal and BestSpeed compressions.

    Best

    Use best compression, slow enough.

    BestSpeed

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

    None

    Pack without compression.

    Normal

    Use normal compression, middle between speed and size.

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