Show a PDF from a TMS WEB Core app

This is a frequently asked question from TMS WEB Core users how a PDF file, typically a generated report, can be shown from a TMS WEB Core app. The good news is that it is simple as browser technology has us covered. There are basically two options:

  1. Show the PDF file in a new browser window (tab)
  2. Show the PDF embedded in the application window

So, let's just do this and provide a project that shows this. To show the PDF file in a new browser window, all we need to do is call Application.Navigate(URL, ntBlank), where URL is the link to the PDF file.

To show the PDF file embedded in the application window, we can drop a TWebBrowserControl on the form and set its URL to the link to the PDF file.

So, in a nutshell, the code behind becomes as simple as:

procedure TForm2.WebButton1Click(Sender: TObject);
  URL = '';
  if WebRadioButton1.Checked then
    WebBrowserControl1.URL := URL
    Application.Navigate(URL, TNavigationTarget.ntBlank);

For your convenience, you can download the test project here

Needless to say that this exact code works in TMS WEB Core for Delphi, TMS WEB Core for Lazarus and TMS WEB Core for Visual Studio Code. It can be applied in a classic web client application, a PWA and also an Electron based cross-platform desktop application.

Not using TMS WEB Core yet? Get your free & fully functional trial version download from our website and benefit from the Holiday Season holidays to explore and get excited.

Leave Your Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.