Monday, August 17, 2026

Display PDF Documents in a Visualforce Page from OmniScript; Secured Guest User

 

Apex: 


Overall flow:

ContentVersion File


AutoGenDocPreviewController


Base64 PDF String


Visualforce Page


JavaScript atob()


Binary PDF


Blob


Temporary URL


iframe


PDF displayed in browser



Why This Approach Is Useful for Guest Users

Instead of exposing the file directly through:

/servlet/servlet.FileDownload?file=...

the Apex controller retrieves the file and sends it as Base64. The browser reconstructs the PDF locally.

This is often used when:

  • Guest users cannot access ContentVersion directly.
  • Secure Guest User Access is enabled.
  • Files are owned by an integration user.
  • You need custom security checks before showing the document.