PDF Assets

My client has a library of hundreds of PDF report sections of varying length. After completing a survey, some criteria are evaluated that determine which PDF sections to include in a final report deliverable. While completing the survey, it is helpful for surveyors to read these sections. The section contents are subject to change, but the changes are consistently made in a repository that we have integrated with Journey Apps via REST API.

I don’t see a way to store a PDF asset in Journey Apps so I think our options are to convert to an asset friendly format like PNG or extract just the text from each PDF and store in the database. Could write a polling cloud-code task to keep the data up-to-date in the case that it changes in the repository.

Wondering if maybe someone has any novel recommendations for handling this?

Hi Fletcher

You can store a PDF in the DB using the attachment field type, like this.

    <model name="item" label="Item">
        <field name="pdf" label="Pdf" type="attachment" media="application/pdf"/>

Please note that attachments that are stored in the DB are not automatically synched to devices, but instead are retrieved from the server on-demand and then stored locally for a period of time. What this means is that if you need your end users to have access to the PDFs offline then this solution will not work.

Please note, storing it in a PNG would be no different - unless you are thinking of actually making it part of the codebase and not the data. In other words uploading the PNGs to the Assets directory of your application and including it directly in the codebase (this is not recommended for files that are going to change frequently, as every change would require you to update the codebase and re-deploy. Also not recommended if the library is indeed 100s of files as this unnecessarily will increase the size of the codebase)

Since the content changes frequently it does pose an interesting problem as you probably do want to make sure that the users have access to the latest versions, and the only sure way to do that is to have it be online only with a “link” to the latest version.

My gut feeling is that either storing the raw extracted text (offline friendly) or storing a link to the actual PDF file (online only - either a link to the existing library or as an attachment in the JourneyApps DB) will be your best bet.

If the formatting of the text is important you could consider storing it as HTML and then rendering it dynamically via an embedded HTML project.

I hope this helps