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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:33:18+00:00 2026-05-14T18:33:18+00:00

I write a simple program to print a image in JSF…. I have one

  • 0

I write a simple program to print a image in JSF….

I have one image (sampleImage.png).. Already i connected my pc to printer….

Manually i open the image and select print option , then i got image from printer….

Now i want print image using javascript….

File name : imagePrint.jsp

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Printer</title>          
        <script type="text/javascript">
             function printImage()
            {                                       
               // Here i want write a script for print image                              
            }
        </script>

    <body>
        <h:form id="fileViewerForm">
            <rich:panel>
                <f:facet name="header">
                    <h:outputText value="Printer"/>
                </f:facet>

                <h:commandButton value="PrintImage" onclick="printImage();"/>

                   <rich:panel id="imageViewerPanel">                               
                       <h:graphicImage id="imageViewer" value="sampleImage.png" url="sampleImage.png"/>             
                  </rich:panel>                                       
            </rich:panel>
        </h:form>
    </body>
</html>

help me about this..

The following script for print the textarea into the printer…..
So i need to print the image

            function printText()
            {
                alert("Text Area print to printer start....");
                var textElem = document.getElementById("fileViewerForm:textAreaGrid1").innerHTML;
                alert("Text Area Content : " + textElem);

                if(textElem.toLowerCase().indexOf("<textarea", 0) != -1)
                {
                    textElem = document.getElementById("fileViewerForm:fileContent1").value;
                    var regExp = /\n/gi;
                    textElem = textElem.replace(regExp,'<br>');
                }
                popup = window.open('','popup','toolbar=no,menubar=no,width=200,height=150');
                popup.document.open();
                popup.document.write("<html><head></head><body onload='print()'>");
                popup.document.write(textElem);
                popup.document.write("</body></html>");
                popup.document.close();
            }             
  • 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-14T18:33:19+00:00Added an answer on May 14, 2026 at 6:33 pm

    You will receive image id using both
    h:form and h:graphicImage tag id’s

    The Java script is :

     function printImage()         
     {            
       var iamgeId = document.getElementById('fileViewerForm:imageViewer');
    
       var imagObject = new Image();
       imagObject = iamgeId;
       var originalImage = '<img id="imageViewer" src="'+imagObject.src+'" 
                            height="'+imagObject.height+'"
                             width="'+imagObject.width+'" />';
    
       popup =  window.open('','popup','toolbar=no,menubar=no,width=200,height=150');
       popup.document.open();
       popup.document.write("<html><head></head><body onload='print()'>");
       popup.document.write(originalImage);
       popup.document.write("</body></html>");
       popup.document.close();           
    }
    

    JSF code is :

      <h:commandButton value="Print" onclick="printImage();"/><br>
           <rich:panel id="imageViewerPanel">                
    
                <h:graphicImage id="imageViewer" url="sampleImage.png"
                                value="sampleImage.png" width="200"
                                                         height="200" />
           </rich:panel>
      </h:panelGrid>
    

    It works on FireFox 3.0.18.

    By,
    Eswara Moorthy, NEC.

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

Sidebar

Ask A Question

Stats

  • Questions 458k
  • Answers 458k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer For :) – (:\)(?!\))) Then For :)) – (:\)\)) May 15, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer It is possible to convert a string from any encoding… May 15, 2026 at 11:00 pm
  • Editorial Team
    Editorial Team added an answer If you need to check who was first to finish… May 15, 2026 at 11:00 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.