Compression
IPDFDocument4 :: General document management :: Common

See Also Example
Collapse All

This property gets or sets the value indicating whether PDF page streams are compressed or not.

Syntax

CompressionType Compression { get; set; }
Value
One of the CompressionType values

Remarks

A compressed file is always smaller; however, it contains binary data rather than ASCII data. In addition, "run-length" compression (uncompressed file) is compatible with older PDF reader programs.

You can also reduce output file size by setting the FontEmbedStyle property to esNotEmbed.

Example

How to Compress the Document

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.Compression := coFlate;

{ the size of the PDF file generated would be: }
{  about 7 Kb if Compression = ctFlate (1)     }
{  about 13 Kb if Compression = ctNone (0)     }

font := PDF.AddFont('Verdana', false, false, false, false, fcDefault);
PDF.UseFont(font, 8);
line := 'This is a long text line. This is a long text line.';
for i := 1 to 100 do
    PDF.ShowTextAt(10, i*10, line);
PDF.SaveToFile("test.pdf", true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->Compression = coFlate;

// the size of the PDF file generated would be:
//  about 7 Kb if Compression = ctFlate (1)
//  about 13 Kb if Compression = ctNone (0)

long font = PDF->AddFont("Verdana", false, false, false, false, FontCharset.fcDefault);
PDF->UseFont(font, 8);
char* line = "This is a long text line. This is a long text line.";
for (int i = 0; i < 100; i++)
    PDF->ShowTextAt(10, i*10, line);
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
PDF.Compression = CompressionType.coFlate;

// the size of the PDF file generated would be:
//  about 7 Kb if Compression = ctFlate (1)
//  about 13 Kb if Compression = ctNone (0)

long font = PDF.AddFont("Verdana", false, false, false, false, FontCharset.fcDefault);
PDF.UseFont(font, 8);
string line = "This is a long text line. This is a long text line.";
for (int i = 0; i < 100; i++)
    PDF.ShowTextAt(10, i*10, line);
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.Compression = 1 'coFlate

' the size of the PDF file generated would be:
'  about 7 Kb if Compression = ctFlate (1)
'  about 13 Kb if Compression = ctNone (0)

font = PDF.AddFont("Verdana", False, False, False, False, 1) 'fcDefault
PDF.UseFont font, 8
line = "This is a long text line. This is a long text line."
For i = 1 To 100
    PDF.ShowTextAt 10, i*10, line
Next
PDF.SaveToFile "test.pdf", true

See Also

Reference