PDF document preview

Certified Associate Developer

I have a use case that needs to display a PDF or doc type document in a “FIT”/preview format. I thought the documentImage would work however it only works up to “LARGE” and not “FIT”. Is this a problem for anyone else and has anyone found a way to display a PDF?

ENV:18.1

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Hi Samuel,

    We had exactly the same issue that you are facing currently and we came up with a workaround for this which works perfectly as we wanted it to. May be this can help you as well.

    Pre-requisite:

    Latest version of Appian is required (it is 18.1 when this reply was posted)

    The browser used is "Google Chrome" with the below extension installed

    Extension name: PDF JS PDF Viewer (v 2.0.466 or higher)

    Source: Chrome Web Store 

    License: Free

     

    Here's how you do it:

    1. Create a webAPI component that takes the appian documentID as a parameter and returns a response in the below format:

    (In version18.1 you can use the 'Document Download' template to automatically generate this code)

    Headers

    Content-Type: application/pdf

    Content-Disposition: inline; filename="<fileName>.pdf"

    Body

    The document itself (todocument(<documentID>))

    (Exception handling is not specified here. But must be in place.)

    2. Now your webAPI will have a URL that would look something like this: <siteURL>/suite/webapi/document/12345         (12345 will be your appian documentID)

    If the pre-requisite mentioned above is in place then you will already see the PDF displayed in your browser on entering the above URL with an existing documentID. This will be your first test to see if this approach would suit your needs.

    3. In your SAIL interface you can now use the a!webContentField and pass this URL for the source parameter. Use the height to get the desired preview size.

Reply
  • 0
    Certified Lead Developer

    Hi Samuel,

    We had exactly the same issue that you are facing currently and we came up with a workaround for this which works perfectly as we wanted it to. May be this can help you as well.

    Pre-requisite:

    Latest version of Appian is required (it is 18.1 when this reply was posted)

    The browser used is "Google Chrome" with the below extension installed

    Extension name: PDF JS PDF Viewer (v 2.0.466 or higher)

    Source: Chrome Web Store 

    License: Free

     

    Here's how you do it:

    1. Create a webAPI component that takes the appian documentID as a parameter and returns a response in the below format:

    (In version18.1 you can use the 'Document Download' template to automatically generate this code)

    Headers

    Content-Type: application/pdf

    Content-Disposition: inline; filename="<fileName>.pdf"

    Body

    The document itself (todocument(<documentID>))

    (Exception handling is not specified here. But must be in place.)

    2. Now your webAPI will have a URL that would look something like this: <siteURL>/suite/webapi/document/12345         (12345 will be your appian documentID)

    If the pre-requisite mentioned above is in place then you will already see the PDF displayed in your browser on entering the above URL with an existing documentID. This will be your first test to see if this approach would suit your needs.

    3. In your SAIL interface you can now use the a!webContentField and pass this URL for the source parameter. Use the height to get the desired preview size.

Children