GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / SetJpegQuality Method
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
Example





In This Topic
SetJpegQuality Method (GdPicturePDF)
In This Topic
Changes the level of quality used to compress JPEG image within the currently loaded PDF document.

Please note that firstly you need to create or load the PDF document to allow this setting to work properly. Secondly, you need to set the compression level before adding the required image to the current document.

Syntax
'Declaration
 
Public Sub SetJpegQuality( _
   ByVal Quality As Integer _
) 
public void SetJpegQuality( 
   int Quality
)
public procedure SetJpegQuality( 
    Quality: Integer
); 
public function SetJpegQuality( 
   Quality : int
);
public: void SetJpegQuality( 
   int Quality
) 
public:
void SetJpegQuality( 
   int Quality
) 

Parameters

Quality
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. The default value is 75.
Remarks
It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any. Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.

JPEG compression is only suitablefor 8bpp grayscale and non indexed color images. Please use the GdPicturePDF.SetCompressionForColorImage method to specify the JPEG compression scheme for other color images.

Example
How to set the compression level correctly.
Dim gdpicturePDF As New GdPicturePDF()
'Firstly, create or load the PDF document.
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    'Set the required parameter.
    gdpicturePDF.SetJpegQuality(80)
    'Process your document here, for example, add an image.
Else
    MessageBox.Show("The file can't be loaded.", "Example: SetJpegQuality")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
//Firstly, create or load the PDF document.
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    //Set the required parameter.
    gdpicturePDF.SetJpegQuality(80);
    //Process your document here, for example, add an image.
}
else
    MessageBox.Show("The file can't be loaded.", "Example: SetJpegQuality");
gdpicturePDF.Dispose();
See Also