Skip to main content

Hi all,

I’ve set up a CMS Workspace in Salesforce and I’m trying to build a custom component to search for documents.

I’m able to search documents by title, but is it possible to search for text inside a PDF document as well? I know some external tools provide this capability out of the box.

I’ve tried using the Salesforce APIs (e.g. the content-search-api), but they don’t seem to search the actual content of the documents as expected.

Has anyone had a similar requirement and found an OOTB Salesforce solution for searching inside PDF content?

1 件の回答
  1. 8月12日 5:12

    Hi Andrea — you've hit a real boundary. Short version: Salesforce CMS does not full-text-index the text inside a PDF's binary. The CMS content search / content-search-api indexes the content item's fields (title, metadata, body/content nodes), not the bytes inside an attached PDF — which is exactly why your title search works but a content search comes back empty. There's no OOTB CMS setting to flip for "search inside PDF content." 

     

    Where Salesforce does search inside PDFs OOTB: Salesforce Files (ContentVersion). Global / SOSL search extracts and indexes the text content of uploaded files, including PDFs (within size limits), so a SOSL query over ContentVersion matches on text inside the PDF. So the native "search inside a PDF" capability exists — it just lives on Files, not on CMS content. 

     

    Practical options for your custom component: 

    1. Store or expose the PDFs as Salesforce Files (ContentVersion) and have your component run SOSL against ContentVersion — you get inside-the-PDF matching for free (subject to the documented file-content index limits). Least-effort native route. 

    2. Extract the text at ingest and make it searchable: run the PDF through a text-extraction/OCR step (an Apex PDF library, or a Flow/Apex HTTP callout to an extraction or OCR service) when the document is added, and store the extracted text in a searchable field — on the CMS content or a related custom object your component queries. This is the usual pattern when the file must stay in CMS but you still need full-text search. 

    3. If you're on an Industries cloud, look at Smart Content Search — it is designed to search within document content, but it's license/cloud-specific, so confirm it applies to your org. 

     

    Net: no OOTB CMS "search inside PDF," but Files + SOSL gives you native in-PDF search, and text-extraction-on-ingest is the standard workaround when the content needs to stay in CMS. 

     

    Ref: How search indexes and finds text (including within files):

    https://help.salesforce.com/s/articleView?id=sf.search_index.htm&type=5

0/9000