AVAILABLE NOW: Spring 2025 Release

How to search keywords in PDF metadata with Apryse SDK

By Apryse | 2025 Jun 23

Sanity Image
Read time

3 min

Cloud services such as Google Drive continue to grow in popularity each year as a safe, secure and convenient way to store and back up your documents, images, music and other files. For users with a large amount of data in the cloud, searching and finding your files again can become problematic. Most search features are limited in their scope, and only take advantage of the file name or, for file formats such as PDF, the text within the file itself. Therefore some level of customization or enhancement may be necessary to take full advantage of your Google Drive cloud storage. You can use the Apryse PDF SDK to read and edit the file metadata, and then update the file's IndexableTextData property in Google Drive to enable custom keyword searching.

The code sample below uses Apryse SDK to look at the keywords metadata within PDF files. This has useful applications such as enhancing search tools in cloud storage platforms such as Google Drive.

C# code:

using pdftron; 

using pdftron.PDF; 

using pdftron.SDF; 

 

namespace ConsoleApp1 

{ 

    internal class Program 

    { 

        static void Main(string[] args) 

        { 

            PDFNet.Initialize(PDFTronLicense.License); 

 

            // Open the PDF document 

            using (PDFDoc doc = new PDFDoc("path_to_input.pdf")) 

            { 

                doc.InitSecurityHandler(); 

 

                // Get the document's Info dictionary 

                PDFDocInfo info = doc.GetDocInfo(); 

 

                // Update the Keywords metadata 

                info.SetKeywords("new, keywords, here"); 

 

                // Save the updated document 

                doc.Save("output_keywords.pdf", SDFDoc.SaveOptions.e_linearized); 

            } 

 

            // Terminate the library 

            PDFNet.Terminate(); 

        } 

        } 

    } 

What’s Next?

For more information about Apryse, contact us or check out our documentation. 

Sanity Image

Apryse

Share this post

email
linkedIn
twitter