KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Run PDFs in 4D Web Area
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: August 23, 2021

The embeded 4D Web Area is able to run and display PDFs.
Typically, PDFs are stored as documents on disk. They can be loaded to the Web Area by passing the path to the PDF into the WA OPEN URL command.

WA OPEN URL(*; "Web Area"; $pathToPDF_t)

PDFs stored in memory as a blob can also be opened in the Web Area. To do so, the PDF must be encoded in Base64. Then the Base64 data can be appended to

   "data:application/pdf;base64,"

as a URL to pass into the WA OPEN URL command.
BASE64 ENCODE($PDF_Blob; $PDF_Base64_t)
WA OPEN URL(*; "Web Area"; "data:application/pdf;base64,"+$PDF_Base64_t)

The example above, will load the PDF in the Web Area named "Web Area". This will allow PDFs saved into a table as a blob to be loaded without needing to download the PDF onto the machine first.