Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8664537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:15:52+00:00 2026-06-12T17:15:52+00:00

I want to display pdf file in webpage using iframe with spring framework. Instead

  • 0

I want to display pdf file in webpage using iframe with spring framework. Instead of download options i have to show pdf file in my webpage. Pls anyone can help me.

Thanks in advance..

My java code:

Employee employee = employeeManager.getObjectOrNull(
            Employee .class, id);
    File file = new File(dir,
            employee .getFileName());
    org.apache.commons.io.FileUtils.writeByteArrayToFile(file,
            employee .getfile());

    if (employee != null) {
        ControllerUtils.openFile(dir,
                response, employee.getFileName());
        String contentType = Utils.getContentType(employee 
                .getFileName());
        response.setContentType(contentType);
        response.setHeader("Cache-Control", "private, max-age=5");
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T17:15:53+00:00Added an answer on June 12, 2026 at 5:15 pm

    I’ve got the solution. I used embed tag. My HTML code:

    <embed width="900px" height="500px" name="plugin" src="/content/downloadPdf" type="application/pdf">
    

    My java code

            response.setContentType("application/pdf");
            response.setHeader("Cache-Control", "private, max-age=5");
    
            response.setHeader("Pragma", "");
            if (file.length>0) {
                response.setContentLength(file.length);
            }
            ServletOutputStream ouputStream = response.getOutputStream();
            InputStream is = new ByteArrayInputStream(file);
            try {
                int b;
                while ((b = is.read()) != -1) {
                    ouputStream.write(b);
                }
            } finally {
                ouputStream.flush();
                ouputStream.close();
                is.close();
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange issue in phonegap framework. I want to display PDF file
I want to display Pdf file inside iframe control.I have added my code like
I want to display pdf file in webview. I try using this code it
Very simple...I just want to display a local pdf file that I have saved
I have a PDF file stored in server and I want to display it
I want to display PDF file in iPad using CATiled Layer All is well
We want to display a pdf-file on a webpage. From what i can think
I have successfully done code to display pdf file in browser instead of open
I want to parse the tabular information from a .pdf file,and want to display
I want to read a pdf file and display it in the UI in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.