Implementing the Advanced PDF Search component in your application
You can add PDF search capability to Pega Customer Service™ and Pega Sales Automation™ applications by implementing the Advanced PDF Search component. The PDF search functionality is an independent component that you can implement in your application to enable searching for any text, special characters, or numbers within a PDF file. For example, in a Customer Service application, during a billing inquiry call a customer service representative can search a customer's previous bills for a word or a date that is related to the customer's inquiry. From the search results, the customer service representative can select and display a bill, and use the navigation controls to advance through multiple search results in a bill.
Before implementing the search component, ensure that:
- Source documents are accessible
- PDF files are not password-protected
You can use the default layout (see Example) or customize the layout to create the look that you want. The search result PDF includes the following features:
- Auto-scrolling to the first occurrence of the search text
- Highlighted search text
- Navigation controls to move to the next and previous occurrences of the search text
Using the default layout
To implement the default search component layout, directly embed the AdvancedPdfSearch rule in the section where you want the search text box to appear.
- In the left navigation pane, click Records > User interface > section.
- Open the section in which you want to embed the AdvancedPDFSearch section.
- Create a new Dynamic Layout section.
- Click Structural > Embedded section.
- Drag the embedded section onto the new Dynamic Layout section.
- In the Section Include dialog box, enter AdvancedPDFSearch in the Section field as shown in the following example:
- Click Submit. The section is embedded in the dynamic layout, as shown in the following example:
- Save, and then check in your changes.
Customizing the layout
You can customize the search component layout to change the location of the PDF navigation controls or the Search text box. To customize the layout, create a new Dynamic Layout section and then embed the following rules in the appropriate sections to create the look that you want.
- In the left navigation pane, click Records > User interface > section.
- Open the section in which you want to include the AdvancedPDFSearch control.
- Click Structural > Dynamic layout.
- In the dynamic layout, embed the following rules as required to create the look that you want:
Rule name | Purpose |
---|---|
SearchPDF | Includes script files for searching text across multiple documents. |
DocumentSearchOccurrences | Contains the search component that takes search text as input and displays the search results. |
PDFControls | Contains the additional document controls such as navigation buttons. |
PDFViewer | Displays the PDF document that the user selects from the search results. |
Populating the D_PDFDocument datapage
Populate the D_PDFDocument datapage with the document details from the system or database that contains the data that you want to search. To do this, you must override the data source of the D_PDFDocument datapage. You can fetch the document details by using a REST call or by fetching the records from the database.
Perform the following steps to override the data source for the D_PDFDocument datapage:
- In the left navigation pane, select Data model > data transform.
- Open the SourcePDF data transform. This data transform is called from the activity that shows the properties that you need to set.
- In the Activity name field, enter SourcePDF.
- Open the SourcePDF activity.
- Set the following properties by using the document details, as shown in the following example:
- Save your changes.
Configuring the search results display
By default, when you perform a search, the search component displays the first three search results in the drop-down list. Any additional search results are displayed, a maximum of nine items at a time, when you click Show More, as shown in the following example:
You can change the number of documents displayed in the initial search results and the number of documents displayed when you click the Show More link by configuring the following dynamic system settings:
- MinimumRecords – Use this setting to set the number of documents displayed in the initial search results.
- AdditionalRecords – Use this setting to set the number of additional documents displayed by clicking the Show more link.
Example: Advanced PDF search component default layout
The following example shows the result of a PDF search displayed in the user interface. The PDF document uses the default component layout.