GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / ConvertToGrayscale Method / ConvertToGrayscale(Boolean,Boolean,Boolean,Boolean,Boolean,Boolean) Method
Set this parameter to true if you want to convert all text on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all path - based graphic objects on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all images on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all annotations on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to convert all form fields on page to grayscale, otherwise set it to false.
Set this parameter to true if you want to execute removal of unused resources of the end of the process.
Example





In This Topic
ConvertToGrayscale(Boolean,Boolean,Boolean,Boolean,Boolean,Boolean) Method
In This Topic

Converts specified content of currently selected page of the loaded PDF document to grayscale.

Syntax
'Declaration
 
Public Overloads Function ConvertToGrayscale( _
   ByVal Text As Boolean, _
   ByVal Graphics As Boolean, _
   ByVal Images As Boolean, _
   ByVal Annotations As Boolean, _
   ByVal FormFields As Boolean, _
   ByVal RemoveUnusedResources As Boolean _
) As GdPictureStatus
public GdPictureStatus ConvertToGrayscale( 
   bool Text,
   bool Graphics,
   bool Images,
   bool Annotations,
   bool FormFields,
   bool RemoveUnusedResources
)
public function ConvertToGrayscale( 
    Text: Boolean;
    Graphics: Boolean;
    Images: Boolean;
    Annotations: Boolean;
    FormFields: Boolean;
    RemoveUnusedResources: Boolean
): GdPictureStatus; 
public function ConvertToGrayscale( 
   Text : boolean,
   Graphics : boolean,
   Images : boolean,
   Annotations : boolean,
   FormFields : boolean,
   RemoveUnusedResources : boolean
) : GdPictureStatus;
public: GdPictureStatus ConvertToGrayscale( 
   bool Text,
   bool Graphics,
   bool Images,
   bool Annotations,
   bool FormFields,
   bool RemoveUnusedResources
) 
public:
GdPictureStatus ConvertToGrayscale( 
   bool Text,
   bool Graphics,
   bool Images,
   bool Annotations,
   bool FormFields,
   bool RemoveUnusedResources
) 

Parameters

Text
Set this parameter to true if you want to convert all text on page to grayscale, otherwise set it to false.
Graphics
Set this parameter to true if you want to convert all path - based graphic objects on page to grayscale, otherwise set it to false.
Images
Set this parameter to true if you want to convert all images on page to grayscale, otherwise set it to false.
Annotations
Set this parameter to true if you want to convert all annotations on page to grayscale, otherwise set it to false.
FormFields
Set this parameter to true if you want to convert all form fields on page to grayscale, otherwise set it to false.
RemoveUnusedResources
Set this parameter to true if you want to execute removal of unused resources of the end of the process.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks

We recommend to use this overload when multiple pages of the document need to be converted or if the document will be processed in any other way before saving. This is because removal of unused resources, which is a document wide process, can be executed after last page was processed and not after every page which improves the overall performance.

Example
How to convert images on the selected pages to grayscale and remove unused resources after last page is processed.
Using gdpicturePDF As New GdPicturePDF
    gdpicturePDF.LoadFromFile("input.pdf")
    gdpicturePDF.SelectPage(1)
    gdpicturePDF.ConvertToGrayscale(False, False, True, False, False, False)
    gdpicturePDF.SelectPage(2)
    gdpicturePDF.ConvertToGrayscale(False, False, True, False, False, True)
    gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("input.pdf");
    gdpicturePDF.SelectPage('1);
    gdpicturePDF.ConvertToGrayscale(false, false, true, false, false, false);
    gdpicturePDF.SelectPage(2);
    gdpicturePDF.ConvertToGrayscale(false, false, true, false, false, true);
    gdpicturePDF.SaveToFile("output.pdf");
}
See Also