javaspringwicketwicket-8

How to display PDF on the HTML page


I have migrated my application from wicket 1.x to wicket 8.x and now facing an error to display PDF on iframe. It is showing as blank on the iframe.

I am trying to display PDF in the iframe tag in the HTML on page load but it is showing as blank.

Share the detailed code below path: https://github.com/smartuadk/Shared_Repo_StackOverflow/tree/main/PDF_Preview


Solution

  • Please add below http security header tag in Spring security module xml file to allow Spring security to display the HTML iframe in spring application:

    <security:http use-expressions="false">
        <security:headers>
            <security:frame-options disabled="true"></security:frame-options>
        </security:headers>
    </security:http>
    

    This solution worked for me and now my application is able to display the iFrame without any error and able to load PDF file in iFrame as well.