XRendering SaveCompression Property. The preferred compression method. ABCpdf .NET PDF Library.

ABCpdf .net

 
   

 

Type Default Value Read Only Description
[C#] Compression

[Visual Basic]
Compression
  None No The preferred compression method.

 

   

Notes
 

This property determines the preferred compression method.

Not all file formats support all compression methods. Not all compression methods support all color spaces. This is why this property indicates a preferred method.

The Compression enumeration accepts the following values:

  • None [Uncompressed]
  • G3 [G3 Black and White Fax Compression]
  • G4 [G4 Black and White Fax Compression]
  • LZW [LZW Compression]
  • Jpeg [Tiff Jpeg Compression]
  • AdobeFlate [Adobe Flate Compression]
  • Flate [Flate Compression]
  • PackBits [Macintosh PackBits]

In general this property is most useful when producing output in formats like TIFF which support a range of color spaces and compression methods.

 

   

Example
 

The following example shows how to render a PDF into a multipage G4 compressed Fax TIFF using different vertical and horizontal resolutions.

[C#]
Doc theDoc = new Doc();
theDoc.Read(Server.MapPath("../Rez/spaceshuttle.pdf"));
// set up the rendering parameters
theDoc.Rendering.ColorSpace = XRendering.ColorSpaceType.Gray;
theDoc.Rendering.BitsPerChannel = 1;
theDoc.Rendering.DotsPerInchX = 200;
theDoc.Rendering.DotsPerInchY = 400;
// loop through the pages
int n = theDoc.PageCount;
for (int i = 1; i <= n; i++) {
  theDoc.PageNumber = i;
  theDoc.Rect.String = theDoc.CropBox.String;
  theDoc.Rendering.SaveAppend = (i != 1);
  theDoc.Rendering.SaveCompression = XRendering.Compression.G4;
  theDoc.Rendering.Save(Server.MapPath("fax.tif"));
}
theDoc.Clear();

[Visual Basic]
Dim theDoc As Doc = New Doc()
theDoc.Read(Server.MapPath("../Rez/spaceshuttle.pdf"))
' set up the rendering parameters
theDoc.Rendering.ColorSpace = XRendering.ColorSpaceType.Gray
theDoc.Rendering.BitsPerChannel = 1
theDoc.Rendering.DotsPerInchX = 200
theDoc.Rendering.DotsPerInchY = 400
' loop through the pages
Dim n As Integer = theDoc.PageCount
For i As Integer = 1 To n
  theDoc.PageNumber = i
  theDoc.Rect.String = theDoc.CropBox.String
  theDoc.Rendering.SaveAppend = (i <> 1)
  theDoc.Rendering.SaveCompression = XRendering.Compression.G4
  theDoc.Rendering.Save(Server.MapPath("fax.tif"))
Next
theDoc.Clear()