function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandeep Kumar SinghSandeep Kumar Singh 

I wan to search keywords in pdf stored in Content Apex Class

How can i read keywords or pdf content in Apex Class, i have stored pdf in salesforce Content. 
 
SwethaSwetha (Salesforce Developers) 
HI Sandeep,
I recommend reviewing the below links https://salesforce.stackexchange.com/questions/51921/search-text-in-a-pdf-file-attachments

https://salesforce.stackexchange.com/questions/146909/can-we-programatically-search-in-files-for-particular-keywords

https://github.com/pranayjswl007/ApexFileSearcher

If it helps please mark this answer as best so that others facing the same issue will find this information useful. Thank you
AnudeepAnudeep (Salesforce Developers) 
Hi Sandeep, 

As far as I know, it is not possible to do a reliable search in a PDF attachment.

See this post to learn more

Let me know if it helps
Sandeep Kumar SinghSandeep Kumar Singh
@Shweta I tried all the link which you provided, not Working ApexFileSearcher is not worikhg for PDF.
@Anudeep I tried this this is not working too getting error System.StringException: BLOB is not a valid UTF-8 string
Thanks for help
 
AnudeepAnudeep (Salesforce Developers) 
Sandeep - The error 'System.StringException: BLOB is not a valid UTF-8 string' is expected as written in the post

A PDF consists of binary data, it is therefore not possible to do a reliable search in a PDF attachment.

Encoding the Blob to Base64 won't help either, since the result contains in no way the original content.

Your best bet would be, attaching plain text and searching its content.

Let me know if this helps, if it does, please close the query by marking it as solved. It may help others in the community. Thank You!