Embed pdf document in CHT

Hello community

I have added a pdf document in an app form accessed by click ont he button with a web link , is it possible to add still access the document from with in CHT when a chw clicks on the button and avoid being navigated to a another website ?

Short answer is no, I do not think there is any specific functionality in the CHT that would let you view the PDF from within the webapp.

Here is one “outside-the-box” idea, (but I doubt it is better than your current solution of just linking to it). Technically you could just embed the PDF right in a label on your app form using an iframe:

<iframe src="https://research.google.com/pubs/archive/44678.pdf" width="400px" height="300px"  />

The big problem with this (you know, besides everything about it) is that it will not work out of the box with the CHT’s content security policy (for good reasons). I am not a CSP expert, so maybe these issues could be avoided by hosting the PDF file somewhere on the CHT server or something, but the only way I could get the above code to render properly is by updating the CHT CSP to include frameSrc: ['https://research.google.com/', 'https://static.googleusercontent.com/'],.

Maybe someone else has better ideas…?

1 Like