PdfDocument Object : IsStrictlyDeviceGray Method |
Visual Basic |
---|
Public Function IsStrictlyDeviceGray( _ ByVal PageNumber As Long _ ) As Boolean |
Errors that could occur:
pdf.PdfError = 13691, pdf.PdfErrorMessage = The page is missing visible graphics; this happens when no visible graphic elements are found on the page, false is returned as there is no assurance that strictly DeviceGray is used on the page.
pdf.PdfError = 13658, pdf.PdfErrorMessage = Page number out of range; this happens if the input long pageNumber is invalid, i.e., -10.
err.Number vbObjectError = 13650, err.Description = This object is not associated with an instance of the PDFXpress control"; this happens if the PdfDocument IsStrictlyDeviceGray() is being called on does not first call SetParentControl().
'This code snippet will demonstrate how to test if a specific page number of
'a document strictly uses the DeviceGray color space. If any other color space
'is used the result will be false. NOTE: this function doesn't examine color
'value, only the color space used
Private Sub IsDeviceGray()
On Error GoTo errorHandler
Dim pdf As New PdfXpress
pdf.Initialize()
Dim doc As New PdfDocument
doc.SetParentControl(pdf)
doc.OpenDocument("C:\\input.pdf", "password")
Dim isPage0StrictlyDeviceGray As Boolean
isPage0StrictlyDeviceGray = doc.IsStrictlyDeviceGray(0)
MsgBox("Does page 1 use strictly the DeviceGray color space? " _
& CStr(isPage0StrictlyDeviceGray))
pdf = Nothing
Exit Sub
errorHandler:
MsgBox(Err.Description)
End Sub