Example





In This Topic
GdPicture14.WPF Namespace / GdViewer Class / PdfGetKeywords Method

PdfGetKeywords Method (GdViewer)

In This Topic
Returns the keywords of the currently displayed PDF document, if any is set in the document information dictionary. If the document currently displayed in the GdViewer control is not the PDF file, the method will fail.
Syntax
'Declaration

 

Public Function PdfGetKeywords() As String
public string PdfGetKeywords()
public function PdfGetKeywords(): String; 
public function PdfGetKeywords() : String;
public: string* PdfGetKeywords(); 
public:

String^ PdfGetKeywords(); 

Return Value

The value of the document's Keywords property as a string. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only meaningful for PDF documents, otherwise it returns an empty string. It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.
Example
How to find out the keywords associated with the loaded PDF document.
'We assume that the GdViewer1 control has been properly integrated.

If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then

    Dim filename As String = GdViewer1.GetLastPath()

    Dim message As String = "The current file is: " + filename

    If GdViewer1.GetDocumentType() = DocumentType.DocumentTypePDF Then

        message += vbCrLf + "PDF Version: " + GdViewer1.PdfGetVersion() +

                   vbCrLf + "Keywords: " + GdViewer1.PdfGetKeywords()

        'Retrieving the PDF metadata.

        Dim metadata As String = GdViewer1.PdfGetMetadata()

        If GdViewer1.GetStat() = GdPictureStatus.OK Then

            Dim metadataFile As String = filename.Replace(".pdf", "_metadata.xmp")

            System.IO.File.WriteAllText(metadataFile, metadata)

            message += vbCrLf + "Metadata has been successfully saved. File: " + metadataFile

        Else

            message += vbCrLf + "Metadata has not been retrieved. Status: " + GdViewer1.GetStat().ToString()

        End If

    Else

        message += vbCrLf + "This file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString()

    End If

            

    MessageBox.Show(message, "GdViewer.PdfGetKeywords")

Else

    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetKeywords")

End If
//We assume that the GdViewer1 control has been properly integrated.

if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)

{

    string filename = GdViewer1.GetLastPath();

    string message = "The current file is: " + filename;

    if (GdViewer1.GetDocumentType() == DocumentType.DocumentTypePDF)

    {

        message += "\nPDF Version: " + GdViewer1.PdfGetVersion() +

                   "\nKeywords: " + GdViewer1.PdfGetKeywords();

        //Retrieving the PDF metadata.

        string metadata = GdViewer1.PdfGetMetadata();

        if (GdViewer1.GetStat() == GdPictureStatus.OK)

        {

            string metadataFile = filename.Replace(".pdf", "_metadata.xmp");

            System.IO.File.WriteAllText(metadataFile, metadata);

            message += "\nMetadata has been successfully saved. File: " + metadataFile;

        }

        else

            message += "\nMetadata has not been retrieved. Status: " + GdViewer1.GetStat().ToString();

    }

    else

    {

        message += "\nThis file is not a PDF document, its format is: " + GdViewer1.GetDocumentType().ToString();

    }

    MessageBox.Show(message, "GdViewer.PdfGetKeywords");

}

else

    MessageBox.Show("The file can't be loaded. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PdfGetKeywords");
See Also