How to print in java(page or whole frame with photos)

Hell sir,
My self kiran patel.I am going to devlop a visitor information system project for Ongc(stand-alon application)
I want to know about below topics.
(1) How to print simple page using printer in java.i dont know any code.
(2) Printing page should contain the whole page which include information and photo of visitor.
(3) how to catch the photo in data base or my frame of visitor info. which we have taken throw web-came.
(4) can we store any image in database?
Please help me as possible as soon.......
kiran patel(MSc it)

Background study -
http://java.sun.com/docs/books/tutorial/2d/printing/index.html
http://java.sun.com/docs/books/tutorial/jdbc/index.html

Similar Messages

  • Tutorial on how to print  multiple output pages

    Hi,
    I am rather sad that this forum does not provide a simple principle on how to printout multiple pages to newbie.
    Below is a short contribution from me on how to print across multiple pages, other reader are also encourage to modify the code to provide more robust tutorial .
    * How to use java to print across pages that are more than one
    * Short contribution to java forum by Eric gan (Malaysia)
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.print.*;
    import java.awt.Graphics2D;
    import java.awt.print.*;
    import java.awt.print.Book;
    import java.awt.print.Pageable;
    import java.awt.Graphics2D;
    import java.awt.Graphics;
    public class Example implements Printable {
    //--- Private instances declarations
    private int row_cnt=30; // set the total number of row per page
    private int cum_row_cnt=30; // set the counter to record total number of row per page to determine
    // whether maximum pages should be increase depending on the programme requirement
    private int max_pg=0; // set the maximum number of page
    public Example () {
    //--- Create a printerJob object
    PrinterJob printJob = PrinterJob.getPrinterJob ();
         printJob.setPrintable(Example.this);
    if (printJob.printDialog()) {
    try {
    printJob.print();
    } catch (Exception PrintException) {
    PrintException.printStackTrace();
    public void paint (Graphics g) {
    Graphics2D g2d;
    g2d = (Graphics2D) g;     
    int x=10;
    int y=10;
    for (int outline=0;outline<=160;outline+=20){
              if (y>cum_row_cnt){
              cum_row_cnt+=row_cnt;//counter should grow by value equal to row_cnt
         max_pg++;
         g2d.drawString("outline value ---> " +outline , x, y);
         y+=10; // to set the row printing interval      
    } // end of paint procedure
         public int print(Graphics g,
    PageFormat pf, int pi)
              throws PrinterException {
    // normal routine to check when should java stop the print looping
    if (pi >max_pg) {
    return Printable.NO_SUCH_PAGE;
    Graphics2D g2 = (Graphics2D) g;
         int fontHeight=g2.getFontMetrics().getHeight();
         int fontDesent=g2.getFontMetrics().getDescent();
         double pageHeight = pf.getImageableHeight()-fontHeight;
         double pageWidth = pf.getImageableWidth();
         // setting for the translate and graphics clipping to enable printing on output pages
    // row_cnt can be equal to pageHeight
    // in this examples assumming pageHeight=20 rows           
         g2.translate(pf.getImageableX(), pf.getImageableY());
    g2.translate(0f,-pi*row_cnt);
    g2.setClip(0, (int)(row_cnt* pi),
    (int) Math.ceil(pageWidth),
    (int) Math.ceil(row_cnt));
    paint(g2);
    return Printable.PAGE_EXISTS;
    public static void main (String [] args) {
    Example example = new Example ();
    System.exit (0);
    Thank

    Hello
    I know that Pages is using its own algorithm to resize pages when it put several of them on a single sheet.
    This is why I use this tip.
    I draw a rectangle whose size is supposed to be the final one.
    I give it a white background and a black border whose thickness is set to one point.
    For the tests I just insert three page breaks so that the document is a four pages one.
    I print it as is.
    Doing that, I may measure the printed rectangle.
    Of course, at first attempt it doesn't match the required size.
    It's easy to compute the required adjustments.
    When the correct factor is reached, it is easy to build the complete document so that it prints the correct size.
    Doing that I never got odd results but maybe it's because I am a lucky guy.
    Of course, disagreeing with one advice doesn't mean that I don't respect it.
    I respect your opinion, _on other matters too_
    Yvan KOENIG (from FRANCE mardi 6 mai 2008 17:24:09)

  • How do I print a configuration page from a Mac with Snowleopard?

    How do  I print a configuration page from a Mac with Snowleopard?  Printer is workinhg fine, but I just put in a new cartridge and I'd like to know how many pages I'm printing.
    Dave

    Hi there Dave, aka @dewanio , welcome back
    I saw that you are looking to print off a configuration page.
    The printer itself will print a test page however, the model depends on how it will print. Let me know which printer you have and I will get back to you!
    Thanks!
    R a i n b o w 7000I work on behalf of HP
    Click the “Kudos Thumbs Up" at the bottom of this post to say
    “Thanks” for helping!
    Click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution!

  • How to print envelopes in pages, How to print envelopes in pages

    How to print envelopes in pages, How to print envelopes in pages

    I presume you are using the Pages application, is that correct?
    So start off by launching Pages and choose one of the regular envelope styles. Traditional works well for me.
    Next go to the File menu and select Page setup. From the menu that says Paper Size select Manage Custom Sizes. In the resulting dialog, there should be a button on the left labeled "+". Click it. In the Paper Size area, select Width 5 in and Height 7 in. Name the size (where it says "untitled" something descriptive like "5 x 7 envelope". Click the OK button. The Paper Size menu here should now say the description you gave it. Click OK again. Your work area should now be a 5 x 7 envelope.
    Best of luck.
    PS If you are using Word or some other program, the process is probably the same or very similar.

  • How to print 2 sided pages brochure

    how to print 2 sided pages brochure

    Hello kaskasnikola,
    I understand that you need to print 2 pages per page.
    1 Open the printer driver, and click the Finishing tab.
    2 Select the number of pages per sheet from the Pages
    per sheet drop-down list.
    3 Select the correct options for Print page borders,
    Page order, and Orientation.
    4 Click OK.
    If you are having any problems please post on our printer forums.
    Here is a link to the forum.

  • How to open a jsf page on a link with a record . Link is in email

    Respected Friends ,
    I am facing a need for sending a email link to users for opening a form for processing a record . I have created a servlet for forwarding the user to the desired page on which we need to render a perticualr record. The servlet forwards the user to the required page but when the page is rendered it gives
    java.lang.NullPointerException     at iffco.wf.view.servlets.UserLinkRedirectServelt.getApplicationModule(UserLinkRedirectServelt.java:143)     at iffco.wf.view.servlets.UserLinkRedirectServelt.doPost(UserLinkRedirectServelt.java:125)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:712)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:369)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:865)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:447)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:215)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)     at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)     at com.evermind[Oracle Containers for J2EE 10g (10.1.3.1.1) ].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)     at java.lang.Thread.run(Thread.java:595)
    Please help me ,
    I want to know how i can load a page from a link with a perticular record .
    I am using jdeveloper 10.1.3 . Also when i acess the current application module from the servlet it gives me the null pointer exception.
    Thanks in advance

    HI FRANK THANKS FOR THE QUICK REPLY I AM PASTING THE CODE OF MY SERVLET..
    frank can you please provide me how to pass parametres along with jspx link and how to acess them in the managed bean .this will also solve my problem.
    package iffco.wf.view.servlets;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import iffco.wf.view.backing.LoginPageBean;
    import iffco.wf.view.utils.ADFJSFUtils;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.ViewObject;
    import oracle.jbo.client.Configuration;
    import iffco.wf.model.wf_servicesImpl;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import oracle.adf.controller.v2.context.LifecycleContext;
    import oracle.adf.controller.v2.lifecycle.PageController;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCDataControl;
    public class UserLinkRedirectServelt extends HttpServlet {
        private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        /**Process the HTTP doGet request.
        public void doGet(HttpServletRequest request,
                          HttpServletResponse response) throws ServletException,
                                                               IOException {
            String var0 = "";
            String var1 = "";
            String var2 = "";
            response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head><title>UserLinkRedirectServelt</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a GET. This is the reply.</p>");
            out.println("</body></html>");
            out.close();
            System.out.println("Inside doget method of servlet");
            LoginPageBean LoginBeanInstance = new LoginPageBean();
            System.out.println("Login bean initiated--->" + LoginBeanInstance );
            String nextJSP = "/faces/LoginPage.jspx";
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
            dispatcher.forward(request,response);
        /**Process the HTTP doPost request.
        public void doPost(HttpServletRequest request,
                           HttpServletResponse response) throws ServletException,
                                                                IOException {
            String var0 = "";
            String var1 = "";
            String var2 = "";
            response.setContentType(CONTENT_TYPE);
            PrintWriter out = response.getWriter();
            out.println("<html>");
            out.println("<head><title>UserLinkRedirectServelt</title></head>");
            out.println("<body>");
            out.println("<p>The servlet has received a POST. This is the reply.</p>");
            out.println("</body></html>");
            out.close();
            System.out.println("Inside post method of servlet");
            LoginPageBean LoginBeanInstance = new LoginPageBean();
            System.out.println("Login bean initiated--->" + LoginBeanInstance );
            String        amDef = "iffco.wf.model.wf_services";
            String        config = "wf_servicesLocal";
            wf_servicesImpl service = (wf_servicesImpl)Configuration.createRootApplicationModule(amDef,config);
            System.out.println("service created --> "+ service);
            ViewObject vo=service.getLoginVO();
            System.out.println(vo);
            vo.setNamedWhereClauseParam("p_personal_no","109128");
            vo.setNamedWhereClauseParam("p_password","abc");
            vo.executeQuery();
            System.out.println("View Object has -->"+vo.getEstimatedRowCount()+" Rows");
            ADFJSFUtils newHelperClass = new ADFJSFUtils();
            System.out.println("New Helper Class Initated -->"+newHelperClass);
            ApplicationModule currentAM = newHelperClass.getDataControlApplicationModule("wf_servicesDataControl");
            System.out.println("Current AM is -->"+currentAM);
            ViewObject vo = currentAM.findViewObject("LoginVO");
            System.out.println(vo);
            vo.setNamedWhereClauseParam("p_personal_No","109128");
            vo.setNamedWhereClauseParam("p_password","abc");
            vo.executeQuery();
            System.out.println("View Object has -->"+vo.getEstimatedRowCount()+" Rows");
            System.out.println("Before method");
            wf_servicesImpl wfser=getApplicationModule();
            System.out.println("after method value got-->"+wfser);
            String nextJSP = "/faces/LoginPage.jspx";
            RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(nextJSP);
            dispatcher.forward(request,response);
        public wf_servicesImpl getApplicationModule() { 
                 FacesContext context = FacesContext.getCurrentInstance(); 
                 System.out.println("context --"+context);
                 ValueBinding vb = context.getApplication().createValueBinding("#{data}"); 
                 BindingContext bc = (BindingContext) vb.getValue(context); 
                 DCDataControl dc  = bc.findDataControl("wf_servicesDataControl"); 
                 return (wf_servicesImpl) dc.getDataProvider(); 
        private void redirect(
            ResponsePage aDestinationPage, HttpServletResponse aResponse
          ) throws IOException {
            String urlWithSessionID = aResponse.encodeRedirectURL(aDestinationPage.toString());
            aResponse.sendRedirect( urlWithSessionID );
          private void forward(
            ResponsePage aResponsePage, HttpServletRequest aRequest, HttpServletResponse aResponse
          ) throws ServletException, IOException {
            RequestDispatcher dispatcher = aRequest.getRequestDispatcher(aResponsePage.toString());
            dispatcher.forward(aRequest, aResponse);
    }

  • How do I select and email a whole lot of photos on my iPad from my iPad emails? It seems I have to go into Email and then insert one photo at a time? Isn't there a way to select all in the photos and then email the batch.?

    How do I select and email a whole lot of photos on my iPad from my iPad emails? It seems I have to go into Email and then insert one photo at a time? Isn't there a way to select all in the photos and then email the batch.?

    Actually, you can email up to 5 at a time from the Photos app. Select any more and the email share option will not appear.
    If you explain why you need to email large numbers of photos, we might be able to offer an alternative.

  • How to display a double page of a magazine with ibooks

    how to display a double page of a magazine with ibooks ?
    Thanks

    oiram osurac wrote:
    how to display a double page of a magazine with ibooks ?
    What is the title of the magazine you are talking about?

  • How can I view 2 pages on Ipad 3 with retina?

    How can I view 2 pages on Ipad 3 with retina?

    For viewing PDF I use PDF Pen. It's awesome though some consider the app pricey. PDF expert is another one.
    Sometimes it depends on the book you are viewing. If its a PDF it will not show 2 pages that I am aware of.

  • Java printing problem how to print in multiple pages

    hi all
    i'm trying to print the output of my application
    no problems with the 1st page but i'd like to tell to my app to print in a brand new page if the content exceed the printable length of the first page. i have 2 classes: printer and Document. the last one implements Printable
    Printer code
    PrinterJob printJob = PrinterJob.getPrinterJob ();
          //--- Create a new book to add pages to
          Book book = new Book ();
          //--- Add the cover page using the default page format for this print job
          //book.append (new IntroPage (), printJob.defaultPage ());
          //--- Add the document page using a landscape page format
          PageFormat documentPageFormat = new PageFormat ();
          documentPageFormat.setOrientation (PageFormat.LANDSCAPE);
          //Document doc=new Document();
          //book.append (doc, documentPageFormat);  
          //book.append (new Getter(), documentPageFormat);  
          book.append (new Document(), documentPageFormat);  
          //--- Tell the printJob to use the book as the pageable object
          printJob.setPageable (book);
          System.out.println("AAAAAAAA" +book.getNumberOfPages());
          //--- Show the print dialog box. If the user click the
          //--- print button we then proceed to print else we cancel
          //--- the process.
          if (printJob.printDialog()) {
             try {
                printJob.print(); 
             } catch (Exception PrintException) {
                PrintException.printStackTrace();
          }Document code:
    public class Document implements Printable
        private final static int POINTS_PER_INCH = 72;
        Calendar now;
        DateFormat df;
        Date date;
        double width;
        Point2D.Double pen;
        Graphics2D g2d;
        LineBreakMeasurer lineBreaker;
        AttributedString paragraphText;
        TextLayout layout;
        double maxPen=0.0;
        static int x1,x2,x3,x4,x5,x6,x7,x8,x9,x10;
        static double intestY, textX, textY;
        public Document()
        public int print (Graphics g, PageFormat pageFormat, int page)
            pen = new Point2D.Double();
            //setto calendario e DateFormat per orario
            df=new SimpleDateFormat("HH:mm:ss:SSS");
            //now=GregorianCalendar.getInstance();       
            //date=now.getTime();
             //--- Create the Graphics2D object
             g2d = (Graphics2D) g;
             //--- Translate the origin to 0,0 for the top left corner
             g2d.translate(pageFormat.getImageableX (), pageFormat.getImageableY ());        
             g2d.setColor(new Color(204,204,204));
             Font titleFont = new Font ("arial", Font.PLAIN, 10);
             Font textFont = new Font ("arial", Font.PLAIN, 8);
             g2d.setFont (titleFont);
             //--- Compute the horizontal center of the page
             FontMetrics fontMetrics = g2d.getFontMetrics ();
             String text = "ABSOL s.r.l. - LISTA APPUNTAMENTI DI Marcello Baiguera";
             textX=(pageFormat.getImageableWidth() - fontMetrics.stringWidth(text))/2;
             textY =7.2;
             //g2d.drawString (text, (int) textX, (int) textY);
             g2d.setFont (textFont);
             fontMetrics = g2d.getFontMetrics ();        
             //linea orizzontale sotto il titolo
             textY=textY + fontMetrics.getDescent();
             //g2d.drawLine(0, (int)textY, (int)pageFormat.getImageableWidth(), (int)textY);
             //prima linea verticale - margine sx
             //g2d.drawLine(x1, (int)textY, x1, (int)pageFormat.getImageableHeight());
             //seconda linea vert 
             x2=x1+fontMetrics.stringWidth("ven. 31/12/2003 ");
             //g2d.drawLine(x2, (int)textY, x2, (int)pageFormat.getImageableHeight());
             //terza linea vert         
             x3=x2+fontMetrics.stringWidth("88:88 ");
             //g2d.drawLine(x3, (int)textY, x3, (int)pageFormat.getImageableHeight()); 
             //quarta linea vert         
             x4=x3+fontMetrics.stringWidth("Marcello Impegnato text text text text");
             //g2d.drawLine(x4, (int)textY, x4, (int)pageFormat.getImageableHeight());
             //quinta linea vert         
             x5=x4+fontMetrics.stringWidth("Sig D'alessio Gigione ");
             //g2d.drawLine(x5, (int)textY, x5, (int)pageFormat.getImageableHeight());   
             //sesta linea vert         
             x6=x5+fontMetrics.stringWidth("Via del PonteVico, 222222 ");
             //g2d.drawLine(x6, (int)textY, x6, (int)pageFormat.getImageableHeight());
             //settima linea vert         
             x7=x6+fontMetrics.stringWidth("del Bagnolo Del Mella (bs) ");
             //g2d.drawLine(x7, (int)textY, x7, (int)pageFormat.getImageableHeight());
             //ottava linea vert         
             x8=x7+fontMetrics.stringWidth("333/78547888 ");
             //g2d.drawLine(x8, (int)textY, x8, (int)pageFormat.getImageableHeight());       
             //nona linea vert         
             x9=x8+fontMetrics.stringWidth("Rinnovo Scadenza Il ");
             //g2d.drawLine(x9, (int)textY, x9, (int)pageFormat.getImageableHeight());
             //decima linea vert         
             x10=x9+fontMetrics.stringWidth("Sandropolitan")+2;
             //g2d.drawLine(x10, (int)textY, x10, (int)pageFormat.getImageableHeight());
             intestY=textY+12;
             text = "DATA";
             textX= x1+((x2-x1)-fontMetrics.stringWidth(text))/2;                 
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "ORA";
             textX= x2+((x3-x2)-fontMetrics.stringWidth(text))/2;                 
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "CLIENTE";
             textX= x3+((x4-x3)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "REFERENTE";
             textX= x4+((x5-x4)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "INDIRIZZO";
             textX= x5+((x6-x5)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "CITTA'";
             textX= x6+((x7-x6)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY);        
             text = "TELEFONO";
             textX= x7+((x8-x7)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "MOTIVAZIONE";
             textX= x8+((x9-x8)-fontMetrics.stringWidth(text))/2;       
             //g2d.drawString (text, (int) textX, (int) intestY); 
             text = "APP. CON";
             textX= x9+((x10-x9)-fontMetrics.stringWidth(text))/2;
             //g2d.drawString (text, (int) textX, (int) intestY);       
             textY=intestY+6;
             //g2d.drawLine(0, (int)textY, (int)pageFormat.getImageableWidth(), (int)textY);
             textY=textY+12;
             double initialTextY=textY;
             System.out.println("maximum Y: "+pageFormat.getImageableY());
             Vector maxPens=new Vector();
             boolean vai=true;
             for(int i=0;  i<12; i++ )
                 if(textY<400.00 && vai)
                     System.out.println("");
                     System.out.println("-- "+i+" --"+df.format(new Date()));
                     //data
                     text = Integer.toString(i);
                     //textX= x1+((x2-x1)-fontMetrics.stringWidth(text))/2;
                     pen.x=x1+2;                
                     printJustified(text, x2-x1-4,textY);
                     //ora
                     text = "10:00";
                     //textX= x2+((x3-x2)-fontMetrics.stringWidth(text))/2;          
                     pen.x=x2+2;                
                     //printJustified(text, x3-x2,textY);
                     //cliente
                     text = "Costruzioni Benedini";        
                     pen.x=x3+2;
                     //printJustified(text, x4-x3-4,textY);
                     //referente
                     text = "Sig. Alessandro mmmm mmmm mmm mmmm mm  ";
                     pen.x=x4+2;
                     //printJustified(text, x5-x4-4, textY);
                     //indirizzo
                     text = "Via del Ca'";
                     pen.x=x5+2;
                     //printJustified(text, x6-x5-4,textY);
                     //citta' + (prov)
                     text = "Pozzolengo S. (VR)";
                     pen.x=x6+2;
                     //printJustified(text, x7-x6-4,textY);
                     //telefono
                     text = "335/6998523";
                     pen.x=x7+2;
                     //printJustified(text, x8-x7-4,textY);
                     //motivazione
                     //text = "Primo Appun";
                     pen.x=x8+2;
                     //printJustified(text, x9-x8-4,textY);
                     //Appuntamento con
                     //text = "Alessandro";
                     pen.x=x9+2;
                     //printJustified(text, x10-x9-4,textY);        
                     //textY=pen.y+12;
                     try
                        textY=Double.valueOf(maxPens.get(i).toString()).doubleValue()+12;
                        System.out.println(i+" recuperato");
                     catch(ArrayIndexOutOfBoundsException a)
                         maxPens.add(Double.toString(maxPen));
                         textY=maxPen+12;
                         System.out.println(i+" aggiunto");
                 else
                     System.out.println("aaaaaaaaaaaaaa ("+textY+")");
                     vai=false;
             //--- Validate the page
             return (PAGE_EXISTS);
             //return(NO_SUCH_PAGE);
          void printJustified(String text, double width, double y)
             pen.y=y;
             String txt=text;   
             System.out.println("text: "+text+" - pen.y= "+y);
             paragraphText = new AttributedString (txt);
             paragraphText.addAttribute (TextAttribute.FONT, new Font ("arial", Font.PLAIN, 8));
            //--- Create a LineBreakMeasurer to wrap the text for the TextLayout object
            //--- Note the second parameter, the FontRendereContext. I have set the second
            //--- parameter antiAlised to true and the third parameter useFractionalMetrics
            //--- to true to get the best possible output
            lineBreaker = new LineBreakMeasurer (paragraphText.getIterator(), new FontRenderContext (null, true, true));
             //--- Create a Vector to temporaly store each line of text
             Vector lines = new Vector ();
             //--- Get the output of the LineBreakMeasurer and store it in a Vector
             while ((layout = lineBreaker.nextLayout ((float) width)) != null) {
                lines.add (layout);
             pen.y = pen.y - 7.373047;
             //--- Scan each line of the paragraph and justify it except for the last line
             for (int i = 0; i < lines.size (); i++)
                //--- Get the line from the vector
                layout = (TextLayout) lines.get (i);
                //--- Check for the last line. When found print it
                //--- with justification off
                //--- Align the Y pen to the ascend of the font, remember that
                //--- the ascend is origin (0, 0) of a font. Refer to figure 1
                pen.y += layout.getAscent ();
                //--- Draw the line of text
                layout.draw (g2d, (float) pen.x, (float) pen.y);
                //--- Move the pen to the next position adding the descent and
                //--- the leading of the font
                pen.y += layout.getDescent () + layout.getLeading ();
                if (pen.y>maxPen)
                    maxPen=pen.y;
                    System.out.println("-----------------------------------------------txt: "+txt+" new maxPeny= "+maxPen);
       }in Document i use the printJustified method that simply splits the text in rows.
    i'll don't explain the method 'cause my question is another.
    thanx a lot
    please!!!
    sandro

    Basically you need to write some smart code. Your application needs to be able to determine what to print on each page because the print api will call the following function passing a page number. Your application must know what to paint on each page. If you think it sounds complicated you better believe it is !!
    public int print(Graphics g, PageFormat pf, int pageIndex) {
    PageNumber = pageIndex+1;
    // Need to calc the pages here
    page = (Graphics2D)g;
    calcPages();
    say("Printing page " + PageNumber);
    if (PageNumber <= getNumPages()) {
    paint(g);
    return Printable.PAGE_EXISTS;
    } else
    return Printable.NO_SUCH_PAGE;
    The code above comes from my report printer class and as you can see a calcPages() function is called prior to the paint() function being called. This function sets up a whole bunch of things including exactly what needs to be printed on each page. Note that the calcPages() function is smart enought to simply return is it has already been called. This way the paint function simply checks the PageNumber variable when painting to establish what to draw on the page.
    So imagine when you are generating a very large report from a database ! You basically have to process the report doing all the formatting prior to actually allowing the paint function to be called. Its quite a complicated business but fortunately even the largest report does'nt really take up that much memory. I basically just create buffers of the data for each page - its a bit of a pain but the same logic is required for pagination anyway.
    Be happy to provide you with the source code but you might need the whole application to get anything working.

  • Printing only 1 page not whole document?

    When you are proofing a page, you must remember to check the page range button as it defaults to all after each page is printed. How do you change this default? We have printed many copies when we are thinking that only one page will go. We toggle between idd5 and pagemaker 7. When you print a page in pagemaker 7.0 it keeps printing that page until you select another option. We are reluctant to move up because of lack of compatability with our print devices and the ppd's. Thanks

    Stephen Del wrote:
    When you are proofing a page, you must remember to check the page range button as it defaults to all after each page is printed. How do you change this default? We have printed many copies when we are thinking that only one page will go. We toggle between idd5 and pagemaker 7. When you print a page in pagemaker 7.0 it keeps printing that page until you select another option. We are reluctant to move up because of lack of compatability with our print devices and the ppd's. Thanks
    Perhaps some knows of a script that can do this. Have you tried asking on the InDesign scripting forum?
    Have you considered exporting to PDF, extracting the single pages, printing them from Acrobat or Reader? With full Acrobat, you can create a document from all open PDF files, then you can print that collection of pages from Acrobat. Another approach would be to placed the saved single-page PDFs into a new InDesign file and printing that file.
    Yes, it's extra steps to create one, but if you have many singles to print, collecting them in a file would let you print as many singles as are in your assembled document in one print command.
    HTH
    Regards,
    Peter
    Peter Gold
    KnowHow ProServices

  • How to print a empty page in a Layout

    Hi experts,
    i have a small requirement in forms. In my sapscript form i have 2 pages. its displaying properly the invoice layout.
    But the new requirement is the user want to print a empty page as 1st page and remaining as per now current setting.
    How to print a empty first page in a layout using sapscript?
    Anyone help this issue?
    Mohaha

    Hi Mohana,
                    Create one new page and one window of almost page size with no contents.  Move that window to this page.  Keep this page as first page and give earlier first page as next page to this newly created page.
                    Hope this should solve the problem.
    Regards
    Sravan

  • How to print a specific page from a given PDF document, using command line, please?

    Hello,
    I need your advise, please. My customer requires to print a specfic page from a pdf document they receive, using command line or 3rd party solution.
    Anything you can advise, please? I have seen AcroRD32.exe options, but can only print the whole document.
    Kind Regards

    Not sure if there are any examples. The Acrobat SDK is a must, but it is best treated as documentation to study rather than examples to copy. The examples only illustrate a tiny fraction of the capabiliies.
    (One other note: the solution must involve the client owning Acrobat; Acrobat is not for server use).

  • How to print a specific page from the internet

    I have tried to print a specific page, and get about seven pages that are linked to it, without
    seeing the specific page I wanted printed out. The page settings under printer only lists header and footer
    info, and no choices to print only this page or frame. There is no way to print  one specific page on this printer?
    I always was able to do this  with the Epson printer I just replaced, but unable to with this printer.
    Please help! There must be a way to do this when printing from the internet. Thanks for any help.

    deezire
    Welcome to the HP Community Forum.
    I don't have any idea what you are trying to print, nor do I wish to know.  Smiling.
    The key may be to control this in Print Preview like you would with most things when you are printing from a Browser.
    Manage Print Output with Print Preview
    ========================================================================
    Depending on which browser you are using, you might also be able to make use of Smart Print:
    Downloads and Information:
    HP Printing Software
    Scroll down > look on the right side of the page under Web Page Printing for the HP Smart Print download
    How-To:
    Smart Print Help and FAQ
    Includes: How to update your installed version of Smart Print:
    #6: How do I get the latest version of Smart Print?
    Smart Print updates automatically using the default settings. You can choice to update manually by selecting the "?" on the Smart Print Preview/Print bar located in the upper left corner of Smart Print. Select the Updates tab to get the latest version.
    Click the Kudos Thumbs-Up to say Thank You!
    And...Click Accept as Solution when my Answer provides a Fix or Workaround!
    I am pleased to provide assistance on behalf of HP. I do not work for HP. 
    Kind Regards,
    Dragon-Fur

  • How to print chinese web page with netscape browserver in Solaris 9 OS ?

    Dear All,
    I would like to print chinese web page within netscape browser in Solaris 9 Traditional Chinese OS, the print out result is garbage code on the paper not correctly chinese fonts.
    I can print out correctly the chinese document create by StarSuite 7.0 on Solaris 9 OS environment and also the chinese web page is correctly display within Netscape browser but for printing is abnomal result.
    Can someone point me to how to do print chinese web page with browser in Solaris 9 environment ?
    Best Regards,
    -- Kuo

    hi
    i have encountered this problem before and i remember downloading some fonts package and installing it. u could google search your question and it should provide the solution.thats how i stumbled upon the package.
    cheers,
    bunny

Maybe you are looking for

  • MacOS 10.7 and Subwoofer

    Can anybody help? My 10-year-old Harman/Kardon subwoofer worked fine with my iMac of 2003 (Motorola-based). The new iMac (MacOS 10.7) doesn't recognise the device. H/K-support says the subwoofer was developed in cooperation with Apple and the Apple p

  • Audio "crackles" after extended uptime

    Hi all, I've had a problem with my iMac (mid-2011 model [gestalt ID of iMac12,2]) basically ever since I got it... I suspect the problem is in software, not hardware, but I can't reproduce it on my MacBook Pro (mid-2010 model) running the same OS and

  • Wifi keeps disconnecting, only at work

    I have a Macbook Pro Retina 13" and at work it keeps disconnecting from the router. I've tried a lot to try to fix it and there are certain conditions that apply (none of the fixes work): This ONLY happens at work and ONLY with my computer. There are

  • CTS Project in System Landscape

    Hi, for chaRM,i want to clarrify about CTS project creation. 1. Whether CTS & IMG Project Should Exist in all satellite system ? 2. How to create a IMG & CTS Project.? In tx Solar_project_admin we can able to create the IMG project for all roles (DEV

  • Hp laser jet m1005 mfp is in initializing state not coming to ready how can i solve it

    hp laser jet m1005 mfp is in initializing state not coming to ready how can i solve it