Making a PDF file available for offline viewing
At design time, you can make a PDF file available for offline viewing by associating the PDF file (which has already been uploaded to the Pega 7 Platform instance) with a button, link, or icon in the Pega Mobile Client app. To view the PDF file at run time, the offline user taps the button, link, or icon in the app.
- Upload the PDF file to a Rule-File-Binary rule
- Invoke the view() JavaScript function in the application
- List the PDF file in the pyCustomAppCache file
Upload the PDF file to a Rule-File-Binary rule
Make sure that the name of the PDF file to be uploaded is saved in lowercase.
- If you are not already logged in to the Pega 7 Platform, log in.
- From the header, click Technical > Binary File. >
- Enter the name of the PDF file (without the .pdf extension) in the Label field.
- Enter the app name in the App Name (Directory) field.
- Enter
pdf
in the File Type field.
Creating a binary file - Click .
- Click
vwgti.pdf
and select the PDF file from your local directory that you want to make available in the Pega Mobile Client app, for example: - Click .
Invoke the view() JavaScript function in the application
After you save the PDF file to a Rule-File-Binary rule, you can associate it with a button, link, or an icon in your application's user interface. When a user clicks the button, link, or icon at run time, the pega.ui.pdf.view()
JavaScript function is invoked, with two parameters specifying the application name and the PDF file name, so that the PDF file opens. You must create a Run Script action for the button, link, or icon.
- Open the section of the user interface with the button, link, or icon and click View Properties for the control.
- From the Actions tab, click .
- Click Add an action, and then click All actions and choose the
Run script
action from the list. - In the Function Name field, enter the name of the JavaScript function that enables the display of a PDF file:
"pega.ui.pdf.view
". Make sure that you include the name within quotation marks. - In the Parameters section, add the first parameter.
- Enter
applicationName
in the Name field. - Enter the name of the application within quotation marks in the Value field, for example: "
webwb"
- Add a second parameter.
- Enter
pdfName
in the Name field. Enter the name of the PDF file (without the .pdf extension) within quotation marks in the Value field, for example:
"vwgti"
Adding a local action to view a PDF file- Click , and then click
List the PDF file in the pyCustomAppCache file
To complete this process, make sure that the PDF file is listed in the mobile application's pyCustomAppCache file. For the example displayed above, add the following entry: webwb/vwgti.pdf
- In the search bar in the header, enter
pyCustomAppCache
- From the results that are returned, click pyCustomAppCache to open this HTML rule.
- Enter
webwb/vwgti.pdf
in the HTML Source data field.
Editing the pyCustomAppCache file - Click .