When utilizing PDF.JS, the PDF content objects are rendered in layers within the browser's frame. Options like <object>
, <embed>
, or <iFrame>
can be used interchangeably to serve as alternatives to a traditional PDF viewer.
By default, the display consists of a background image on the screen with invisible text overlaid in HTML, along with a canvas for annotations that is transparent for drawing notes.
As a result, all text appears "invisible" as it mirrors the transparent HTML fonts from the original PDF source.
In situations where the fonts are white on a white background, PDF.JS has the capability to convert them to transparent on a transparent background. This ensures that the text remains searchable alongside other transparent text elements.
This concept is similar to how Optical Character Recognition (OCR) functions, where the text is not highlighted for selection but rather the numbers that OCR inserts discreetly as non-visible characters. Consequently, text selection can sometimes appear rough or misaligned.