PDF Search Workaround for Systems with No Keyboard

Summary: There is no officially supported method for utilizing search functionality in PDFs in mappView when the user does not have a keyboard to press Ctrl +F with. This PDF viewer solution uses a custom HTML page hosted by the mapp View web server and displayed inside a standard Web Browser widget. The viewer is based on Mozilla PDF.js and supports searchable PDFs, page scrolling, lazy page rendering for large documents, word highlighting, and next/previous match navigation. Setup requires placing pdfviewer.html, the PDF document, and the pdfjs library files on the mapp View web server, then configuring the required MIME types (.pdf, .mjs, .js) so the browser can correctly load the files. The Web Browser widget is then pointed to the hosted pdfviewer.html URL, allowing PDFs to be viewed directly inside mapp View with significantly more functionality than the standard PDF widget.

Step 1: Configure Web Server
The PLC needs to host a web server which will serve up the html page we need. Here are screenshots from my test project.
In simulation:

On hardware:


Note that the ‘Web root directory’ points to the root of the user partition.

Step 2 User Partition Files:

It necessary to have pdfviewer.html, pdfjs which contains pdf.mjs and pdj.worker.mjs, and the document that is to be displayed.
Here’s a screenshot of my user partition on hardware.

Step 3 mappView Widget:
Add a web viewer widget and fill out the host with your PLCs IP, path should be the .html file, and port should match your web server setting.
In simulation use IP 127.0.0.1.

Step 4: Edit pdf name
Inside the pdfviewer.html on line 181 is the definition of the pdf to be displayed. Currently this is a static value that needs to be changed manually.

Done!
The web viewer now displays the pdf with a toolbar for searching and indexing.
The web viewer does not have access to the actual text geometry, instead this script relies on approximating positions based on average character length so the highlighting may be slightly off in some cases, but in my testing it seems good enough to not cause any confusion.
A basic english OSK is defined in the .html file. Users comfortable with editing the file can create their own custom keyboards if desired.

PdfViewerFiles.zip (692.7 KB)

4 Likes

interesting, thanks for sharing :wink: