Open PDF Files in WebClient

Open PDF Files in WebClient

This tutorial describes how to open a PDF file from WebClient by using a custom template. This template uses the panel title as the URL to open the file. To implement this template, follow these steps:
  1. In Eclipse, create a custom template file called “FileViewer-page.wcli” in your CustomTemplates project.
  2. Copy one the following code snippets in your “FileViewer-page.wcli” file (the code you use will determine how the PDF file will open).

    Code 1: Will open the file in a different window

    /(!JSOnLoad)
    window.open(/(!Panel:!Title), "_blank", "height=600,width=800");
    /(!JSOnLoad)
    

    Code 2: Will open the File inside the function panel that uses the template

    /(!MainArea)
    	<embed src="/(!Panel:!Title)" width="100%" height="100%" />
    	
    /(!MainArea)
    

    NOTE: You can see the results of using these code snippets in step 6.

  3. In CA PLEX create the following functions:
    FileViewer


    PDF_Viewer


  4. Open the Action Diagram for the “PDF_Viewer” function and add the following code in the “Pre Point Set Panel caption text”:

    Cast  Environment<*Message text>, Input
    
    



    This will set the received URL as panel title for the function in order to open the file using the custom template we have created.

  5. To open the PDF file, call the “PDF_Viewer” function. That this function requires the URL from the file as a parameter.





  6. Generate your functions and test them in Eclipse.

    Test using the “Code 1” from step 2

    Test using the “Code 1” from step 2


    • Related Articles

    • CM WebClient 1.8.8 Release Notes

      Download current GA Release : Download CM WebClient 1.8.8 WebClient Mobile Updates To see the latest updates of WebClient Mobile, please visit: WebClient Mobile repository. What's New? Support Java 11 Complete functionality of DojoTimePicker.ctrl to ...
    • Generate the Full URL for Uploaded Files on a Server

      Most commonly when you save a file in your server you will be using a context name to define the physical location in which the files are stored and also you may be using the same context name for the file paths in your database records, see the ...
    • Using OBASE with WebClient

      For OBASE, a good start is to import the attached file (WebClientOBASESupport) into the model (Tools->Import->XML Import).  Attached files description: WebClientOBASEOnly: It's for when the Plex model only uses OBASE. WebClientOBASESupport: It's when ...
    • Upgrading CM WebClient v1.6.x to CM WebClient v1.8.x

      Download com.adcaustin.webclient.WebClientPlugin-1.8.jar. Note: The new WebClient plugin version "1.8.7" requires Eclipse from 2020-03 (4.15.0) onwards. Close your eclipse application. Delete the old version of your WebClient Plugin Builder from ...
    • Customizing in CM WebClient

      Attach point A template for a given screen can be generated from more than one template by using attach points. The templates are arranged in order from root to leaf. An attach point is a location defined in a template that other templates further ...