Open a ticket
Chat with us
Click or drag to resize

How to open document automatically

Please note that application of the options described in this section depend on the initial set up explained here.

In this example it will load document at web site's location test-pdf/pdfprint-manual.pdf and show its second page.

Notes:

  • if document is password protected it will show password prompt before loading the document

  • if external site allows CORS, it is also possible to set external URL

C#
using PdfViewer = Terminalworks.PdfViewer.AspNetCore;

var options = new PdfViewer.Options {
  DocumentUrl = "test-pdf/pdfprint-manual.pdf",
  InitialPageNumber = 2
};

This example will load password protected document if the password is correct from the secured document url.
SecuredDocumentUrl, also as password, is sent only for non-Static rendering.
Differences between DocumentUrl and SecuredDocumentUrl:

  • DocumentUrl is visible in browser inspect element and SecuredDocumentUrl isn't

  • DocumentUrl can be used for every blazor rendering type and SecuredDocumentUrl can't be used for a Static rendering

Example for RazorPages/MVC:

C#
@using PdfViewer = Terminalworks.PdfViewer.AspNetCore
<component
  type="typeof(PdfViewer.Pages.Shared.TWPdfViewer)"
  render-mode="Server"
  param-SecuredDocumentUrl='@("test-pdf/password-protected.pdf")',
  param-Password = '@("testPassword")'
/>
Copyright © 2024 Terminalworks. All Rights Reserved