Local PDF
Open a PDF from this computer
The selected file stays in the browser and is passed directly to the viewer as Base64 data.
Ready to tryUse the controls above to interact with this demo.
What this demonstrates
Load a local PDF
Select a PDF from the local computer. FileReader converts it to Base64 and the viewer loads it with the locally hosted PDF.js renderer without a separate upload request.
API used
TXDocumentViewer.loadDocument
Key members
FileReader converts the selected file to Base64 in the browser; the viewer receives that data directly.
const reader = new FileReader();
reader.onload = () => TXDocumentViewer.loadDocument(
reader.result.split(",")[1],
file.name
);
reader.readAsDataURL(file);
How it works
The Razor helper prepares the browser viewer and its document. Demo-specific JavaScript uses the public TXDocumentViewer API and remains encapsulated with this demo.
NuGet packages
Displays supported document and PDF formats in the browser.
dotnet add package TXTextControl.Web.DocumentViewer --version 34.2.0
Source files
See the implementation
The view, browser behavior, assets, and controller are encapsulated in Demos/DocumentViewer/Pdf/UploadingPdfs.