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 6037691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:06:41+00:00 2026-05-23T06:06:41+00:00

Whene I open a PDF on the browser I want to print it in

  • 0

Whene I open a PDF on the browser I want to print it in a div not all the page.
How can I do that? Here is my JSP source code:

<%@ page language="java" import="com.search.ts.*
                                ,java.io.*
                                ,java.net.*
                                ,javax.xml.namespace.QName
                                ,javax.jws.*
                                ,javax.xml.ws.* "
                                                   contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Ebook reader</title>

<%@ page language="java" import="com.search.ts.CallSEI_CallSPort_Client,java.util.*,com.search.ts.Links,com.search.ts.LinksResponse"  %>

<link rel="stylesheet" type="text/css" href="style.css" />

</head>
<body>

            <div id="right_section">
              <div class="right_box">

<% 

        String filename= request.getParameter("err");
        //String filename =(String) request.getAttribute("linkbook");
        File file = new File("F:/fichiers/", filename+".pdf");

        response.setContentType(getServletContext().getMimeType(file.getName()));
        response.setContentLength((int) file.length());
        response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");

        BufferedInputStream input = null;
        BufferedOutputStream output = null;

        try {
            input = new BufferedInputStream(new FileInputStream(file));
            output = new BufferedOutputStream(response.getOutputStream());

            byte[] buffer = new byte[8192];
            int length;
            while ((length = input.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
        } finally {
            if (output != null) try { output.close(); } catch (IOException ignore) {}
            if (input != null) try { input.close(); } catch (IOException ignore) {}
        }


        %>


          </div>
 </div>


</body>
</html>
  • 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-05-23T06:06:41+00:00Added an answer on May 23, 2026 at 6:06 am

    i was in the seem prbm you have to send from the 1st pdf page a link with the name of the pdf (myfile.pdf), like that:

    <a href="pdfread.jsp?err=<%=filename %>"><%=bookName %> </a> 
    

    to the page pdfread.jsp and in this page put that

    <%
        String filename= request.getParameter("err");
    %>
    <embed src="${pageContext.request.contextPath}/pdfreader/<%=filename %>#toolbar=0&navpanes=0&scrollbar=0" width="500" height="375">
      </embed>
    

    and this code you must put it in a servlet with a do get

        String filename= request.getParameter("err");
        //String filename =(String) request.getAttribute("linkbook");
        File file = new File("F:/fichiers/", filename+".pdf");
    
        response.setContentType(getServletContext().getMimeType(file.getName()));
        response.setContentLength((int) file.length());
        response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");
    
        BufferedInputStream input = null;
        BufferedOutputStream output = null;
    
        try {
            input = new BufferedInputStream(new FileInputStream(file));
            output = new BufferedOutputStream(response.getOutputStream());
    
            byte[] buffer = new byte[8192];
            int length;
            while ((length = input.read(buffer)) > 0) {
                output.write(buffer, 0, length);
            }
        } finally {
            if (output != null) try { output.close(); } catch (IOException ignore) {}
            if (input != null) try { input.close(); } catch (IOException ignore) {}
        }
    

    see this link to do it

    How to use doGet in jsp with Servlet

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to open a PDF file in a new browser window when user
I need to render a simple link in a page that open a pdf
Is it possible that when you have a webpage, when you open the PDF,
want to open pdf file when a user clicks on hyperlink shown in gridview
I want open pdf file directly without asking open,save options(prompt window).In this temppath is
I want to force the browser to download a pdf file. I am using
I want to open R with input encoding UTF-8 for plots, and I can't
I have a URL that goes to a pdf file. In my coldfusion page,
I have open pdf file through my application.when click on device back button it
I need to open a some types of files like .jpg, word, .pdf when

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.