Printing with Book and paint()

I'm posting this because I'm hoping someone can unconfuse me!
I'm trying to use a Book class, so the correct number of pages appears in the printer dialogue. However, I don't seem to be able to get this to work. My confusion is over the following. In http://java.sun.com/j2se/1.3/docs/guide/2d/spec/j2d-print.fm4.html (section 7.4.2) it has an example with the following three lines:
Book bk = new Book();
bk.append(new PaintCover(), pfl);
bk.append(new PaintContent(), job.defaultPage(), 2);
and it states this is used to print two pages. Yet the API states the third parameter 'Appends numPages pages to the end of this Book.' This would imply three pages are printed, one of PaintCover and two of PaintContent.
Furthermore, there is the pgnum parameter in the print() method. Now I would have thought that is tied in with this third Book parameter. But that seems to have a life of its own. It is supposed to be a zero-based index. But does that mean that PaintContent.print() will initially receive the value 1 (ie page 2), and be called twice (because of the argument 2) in the code extract above?
If so, do you need to have the Printable.NO_SUCH_PAGE return value in the method?
Perhaps my question should be: how do the third parameters of the Book class and paint() methods work, and how do they relate to each other.
As I say I am very badly confused, and any advice, help or otherwise prodding in the correct direction will be welcomed! :-)
Joe.

Printable.NO_SUCH_PAGE is usefull when u r not using Book ..
ex, if you use
book = new Book();
book.append(this,pageFormat,10);
printJob.setPageable(book); it will print 10 pages
and
printJob.setPrintable(this,pageFormat); will print until you call Printable.NO_SUCH_PAGE - which is usefull when you dont know number of pages

Similar Messages

  • Pdf files print with horizontal and vertical lines

    All of a sudden, today, when I print pdf files, they print with horizontal and vertical lines.  I thaught it was the computer or printer. So I printed from another computer on the network, and printed to a different printer with the same result.  It is not just that one pdf file either, I have tried multiple files.  HELP.  Does anyone have any ideas?

    It is not clear how you are creating the files. It appears that they were created by Distiller from PS files that were created in some way. I also noted that you are using AA8.1.0. You may want to try to update (do all the updates in order) as a possible fix. It may be in the creation process also. Several packages will split large graphics into parts and create the image. I think this is a characteristic of OFFICE 2007 (docx) files - but I am not sure yet. Tell us how you created the files - step by step, including the scan.
    If you have the original documents, why not simply print to the Adobe PDF printer. The result would be smaller and a lot cleaner.

  • Share printer with XP and Vista

    I have an HP psc 2110xi connected to a PC running XP. This PC is connected (hardwired) to a Linksys wireless router. Another PC running Vista is connected to the wireless network. I am trying to share the printer with the Vista PC. Is this possible??????I fear it is not but await confirmation from any guru willing to commit him/her self.........

    hello,
    yes, it is possible since your host computer is the XP. make sure the firewall is turned off. try to ping the computer first with each other to make sure that the computers are communicating well with each other.
    go to printers and faxes
    right click on the printer driver and click Sharing.
    put a check mark on Share this printer.
    take note of the share name.
    then from your vista computer type \\ xp ip address.
    for example, \\192.168.1.100
    the printers and faxes window of the XP will show up.
    right click on the driver and click Connect.
    try to print.
    keep me informed please..

  • Pin names and numbers do not print with black and white printer setup option

    Multisim V12
    Printer HP LaserJet 1320
    File -> Print Options -> Print Sheet Setup, check In black/white, OK
    Then
    File ->  Print Preview, shows all elements of the drawing in black white
    Then  select Print and the drawing prints without pin names and pin numbers.
    The same procedure with the black/white unchecked previews in color and then prints all circuit elements

    Hi HiZTrace,
    I used Multisim 12 with the same configuration and printed with a HP LaserJet 4250, but it seemed to be working well for me. There could be some incompatibility issue with your printer driver. A workaround you can try is to install a PDF Converter and print the file in color, then print the generated PDF file in black and white. There are many PDF Converters available, for example, CutePDF Writer (free)
    Sorry for the inconvenience.
    Derek Z.
    National Instruments

  • HP 6940 suddenly printing with lines and red hue

    Hello,
    I was printing photos tonight with my 6940 and suddenly the photos started coming out with the first half (left sides) printed correctly, and the right half has a red hue and striated lines.  I thought the black cartridge might be out, so I replaced it and the photos are coming out the same.  I've just replaced the color cartridge a few weeks ago, so it is not empty.  Any suggestions?
    I tried printing 5 photos, and all came out the same way - left side is printed correctly, right side is ruined.
    Right-click here and choose "Save As" to download a high res photo of the photos as they are coming out of the printer.
    -Gina

    Hi CrazySaguaro,
    It appears as if your colour cartridge is out of ink. If this is the case you should be able to see this in your ink gauge through the driver tool box.
    Here is steps how to check this
    http://h10025.www1.hp.com/ewfrf/wc/document?docname=c00575972&lc=en&cc=us&dlc=&product=467980
    it is located approx half way down the page
    Please let me know what you find out.
    Although I am an HP employee, I am speaking for myself and not for HP

  • Problem to print with iPhoto and epson stylus photo RX620

    I asked a question about the print with Iphoto. Larry gave some explainations but it still doesn't work. I can change the reglages with Safari, with Mail but not with Iphoto. So when I try to print photos, the reglage is standard and the result is bad. I would like to change the reglage, if i use glassy photo paper. With my PC, I have no problem to print with window or picassa. Thanks for your answer.

    First I have no idea in the world what "reglage" is
    But what ever printer specific options are available are supplied by the manafacturer's print driver and these are available on the last print window
    LN

  • Trouble Printing with CS4 and Epson

    I wish to print a 13x19 photo on my Epson Photo Stylus R3000.  After entering all the info correctly with paper size, type, quality, etc I get a print with a one inch blank border on the top and bottom.  I called Epson and they said it was not their problem, it must be something with Adobe.  I am using Photoshop CS4 and Windows 7.  Help, please.  Doro

    So, I found this little piece of info on Epson's site, the question doesn't quite match our problem, but the answer (you would think) would fix us...
    Q: I don’t see my printer driver on the Epson Macintosh Snow Leopard Support page. Where can I find a Mac OS 10.6.x driver for my product?
    A: Try the following:
    Rosetta needs to be installed in Snow Leopard. If necessary, install Rosetta.
    Go to Drivers & Support, select your product category, then select your product name.
    Select Drivers & Downloads, then select Macintosh Operating Systems from the drop-down list and click Go.
    Download the Macintosh 10.5.x drivers for your product.
    Note: If there are no Macintosh OS X 10.5.x drivers available for your product, download and install the Macintosh OS X 10.4.x drivers and the Common Updater software for your product.
    Follow the on screen instructions to finish the driver installation.
    I followed the instructions to the letter.... no results, I still don't see the driver in the drop-down list of available Printer Drivers!

  • Navigation structure with books and pages

    We are setting up a navigation system in Portal 8.1. When setting this up, we have
    run into some issues with the fact that books appear in the navigation structure,
    but contain no content. As a result, we have had to create a homepage for each
    book. This creates a repeat of the section name in the navigation structure, one
    for the book and one for the page. For example, we have our Home book. Then we
    have our Home page (since books cannot directly contain portlets). In our navigation
    "Home" is repeated twice, but the book link just goes to the default page (either
    the last visited page within that session or the top page in that book if the
    no page has been visited).
    The navigation we are trying to get is very similar to the one here on bea's website.
    For example, when you click on Partners, it takes you to the Partners home page.
    This section has many other pages located inside of it as well. Does anyone have
    any suggestions on how to set this up?
    Thanks!!!
    Erin

    I've opened a support case for this item. When I get this resolved I will post
    the solution. But, to clarify the issue, the standard way that portal navigation
    works is that when a user clicks on a book the user is directed to a default page.
    This default page is either the last page visited during the session or the first
    page in the book if no page has been visited. The problem is that the book itself
    does not contain content. So if you wanted the "Partners" book to have a homepage
    titled "Partners" (just like here on BEA's site) then the word "Partners" would
    appear twice in the left nav (once as a book and once as a page). But only the
    page would actually contain content. Plus when a user clicked on the "Partners"
    book it would not always take them to the "Partners" homepage.
    "Chris Jolley" <[email protected]> wrote:
    >
    Not sure i understand your problem:
    However:
    Books can contain 1 or more Books and Pages, and can have an optional
    menu.
    Pages can contain Portlets and Books.
    What is it that you want on the 'Partners' Book?
    "Erin Powell" <[email protected]> wrote:
    We are setting up a navigation system in Portal 8.1. When setting this
    up, we have
    run into some issues with the fact that books appear in the navigation
    structure,
    but contain no content. As a result, we have had to create a homepage
    for each
    book. This creates a repeat of the section name in the navigation structure,
    one
    for the book and one for the page. For example, we have our Home book.
    Then we
    have our Home page (since books cannot directly contain portlets). In
    our navigation
    "Home" is repeated twice, but the book link just goes to the default
    page (either
    the last visited page within that session or the top page in that book
    if the
    no page has been visited).
    The navigation we are trying to get is very similar to the one hereon
    bea's website.
    For example, when you click on Partners, it takes you to the Partners
    home page.
    This section has many other pages located inside of it as well. Does
    anyone have
    any suggestions on how to set this up?
    Thanks!!!
    Erin

  • Printing with Aperture and HP B9100

    I am new to Aperture. I just purchased the new 24" iMac and have installed Aperture and a new HP B9100 Pro Printer. I have been making test prints directly from Aperture with photos taken on a Nikon D80. None of the prints have come out anywhere near close to how good things look on my monitor. The prints are darker and lack the vividness and detail I see on my screen.
    I got better prints from iPhoto and my Canon MP780.
    Any suggestions? I apologize for being so green about this stuff.
    Thanks.
    Roger
    24" iMac   Mac OS X (10.4.8)  
    24" iMac   Mac OS X (10.4.8)  

    I have the HP D7160 (uses six inks). I had the same problem, until I spent countless hours testing different parameters.
    I had problems with Aperture printing too muddy/dark until I did the following:
    On an HP Photosmart D7160:
    In Aperture, I have the "system management" as my Color Sync preference. Printer gamma set to 1.25 Black comp "on"
    In my printer dialog, there is a dropdown menu when you select "print". Under the printer presets, I select "Paper type/quality". In this dropdown, there is a selection for Paper: Color:- I select "Color Sync" (not the printer selected "ColorSmart/RGB")
    I also go to the "Color Options" tab and decrease my magenta output to -5.
    I saved this as a "HP D7160" preset, so whenever I print, it automatically changes these for me.
    Works like a charm now, after a lot of trial and error.

  • Printing With XP And Airport

    I installed Bonjour For Windows and my Epson printer was recognized and made the default printer. It seems that everything is set up right, but it just doesn't print. No errors or anything like that reported. It works OK in OSX.
    I have a MacBook Pro and use Airport and my printer is hooked to that via USB.
    Everything else in Bootcamp with Windows XP works fine, just this problem.
    Is there something else I should do?
    Thanks a lot for your help.

    For those others who might be having the same problem, I found this: The printer you're trying to use with Windows needs to have a name of 15 characters or less.
    http://docs.info.apple.com/article.html?artnum=306514
    When I renamed my default printer "EPSON" in the printer and fax control panel, down from "Epson Stylus CX9400Fax Series" which is the name of the driver and was put in by the Printer Wizard, it gave me a new Printer Wizard window. I just selected the driver and everything works well. Then I just deleted the old printer icons from the printer and fax control panel. End of problem.

  • Printing with SL and Epson 7600

    Would be very interested in hearing from anyone who has installed SL and printed with the Epson 7600... I still use this fossil everyday and don't want to upgrade until I'm sure there won't be issues.

    So, I found this little piece of info on Epson's site, the question doesn't quite match our problem, but the answer (you would think) would fix us...
    Q: I don’t see my printer driver on the Epson Macintosh Snow Leopard Support page. Where can I find a Mac OS 10.6.x driver for my product?
    A: Try the following:
    Rosetta needs to be installed in Snow Leopard. If necessary, install Rosetta.
    Go to Drivers & Support, select your product category, then select your product name.
    Select Drivers & Downloads, then select Macintosh Operating Systems from the drop-down list and click Go.
    Download the Macintosh 10.5.x drivers for your product.
    Note: If there are no Macintosh OS X 10.5.x drivers available for your product, download and install the Macintosh OS X 10.4.x drivers and the Common Updater software for your product.
    Follow the on screen instructions to finish the driver installation.
    I followed the instructions to the letter.... no results, I still don't see the driver in the drop-down list of available Printer Drivers!

  • Using printer with cellphone and ipad

    Do I need my printer hooked to a computer or can I just use it for my iPad and cell phone (Samsung galaxy 5). My desk top computer took a dive but I want to use printer for pics on my cell and ipad

    Hello , Welcome to the HP Forums, and thanks for posting! I understand you are trying to use your HP Photosmart Plus All-in-One printer with your iPad and Android phone. I'd love to help you with this. Was the printer connected wirelessly when you were using it with your computer? If it is still connected to your Wireless network, then you'll be able to print from your mobile devices. On the Android, search for HP ePrint in your Play Store and download it. (Note: the phone will need to have the Wifi turned on and connected to the same network as the printer). On the iPad, open your app store and search for the HP ePrint app. Both devices should be able to work using the same app. Hope this helps!

  • Print with pasta and getting error

    hello, i have customs printing driver for pasta but as i print report i find an error,
    APP-FND-00500: AFPPRN received a return code of failure from routine FDUPRN. Program exited with status 1
    Cause: AFPPRN received a return code of failure from the OSD routine FDUPRN. Program exited with status 1.
    The output .pdf has zero file size.
    Any one help? .
    And how can i locate which part cause this problems?
    Thanks.

    Please post the details of the application release, database version and OS.
    Please see if these docs help.
    How to investigate printing issues and work towards its resolution ? (Doc ID 297522.1)
    APP-FND-00500: Afpprn when Using pdf2ps with Pasta (Doc ID 413402.1)
    APP-FND-00500: AFPPRN ... An Error Occurred In Getting Printer Driver Information (Doc ID 867965.1)
    How to Print PDF with UTF8 in R12? (Doc ID 778970.1)
    11i : Pasta Pasta Printing Setup Test (Doc ID 264118.1)
    Diagnostic Test Catalog for 12.1.3 (Doc ID 1083807.1) -- PASTA
    Thanks,
    Hussein

  • Trying to do something very strange with layouts and painting components

    I'm trying to do something very strange with changing the layout of a container, then painting it to a bufferedImage and changing it back again so nothing has changed. However, I am unable to get the image i want of this container in a new layout. Consider it a preview function of the different layouts. Anyway. I've tried everything i know about swing and have come up empty. There is probably a better way to do what i am trying to do, i just don't know how.
    If someone could have a look perhaps and help me out i would be much appreciative.
    Here is a self contained small demo of my conundrum.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.BoxLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.border.LineBorder;
    // what is should do is when you click on the button "click me" it should place a image on the panel of the buttons in a
    // horizontal fashion. Instead it shows the size that the image should be, but there is no image.
    public class ChangeLayoutAndPaint
         private static JPanel panel;
         private static JLabel label;
         public static void main(String[] args)
              // the panel spread out vertically
              panel = new JPanel();
              panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
              // the buttons in the panel
              JButton b1, b2, b3;
              panel.add(b1 = new JButton("One"));
              panel.add(b2 = new JButton("Two"));
              panel.add(b3 = new JButton("Three"));
              b1.setEnabled(false);
              b2.setEnabled(false);
              b3.setEnabled(false);
              // the label with a border around it to show size in a temp panel with flowlayout to not stuff around
              // with the actual size we want.
              JPanel thingy = new JPanel();
              label = new JLabel();
              label.setBorder(new LineBorder(Color.black));
              thingy.add(label);
              // the button to make things go
              JButton button = new JButton("click me");
              button.addActionListener(new ActionListener(){
                   public void actionPerformed(ActionEvent e)
                        //change layout
                        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
                        panel.doLayout();
                        //get image
                        BufferedImage image = new BufferedImage(panel.getPreferredSize().width, panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
                        Graphics2D g = image.createGraphics();
                        panel.paintComponents(g);
                        g.dispose();
                        //set icon of jlabel
                        label.setIcon(new ImageIcon(image));
                        //change back
                        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                        panel.doLayout();
              // the frame
              JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setSize(400,200);
              frame.setLocation(100,100);
              frame.getContentPane().add(panel, BorderLayout.NORTH);
              frame.getContentPane().add(thingy, BorderLayout.CENTER);
              frame.getContentPane().add(button, BorderLayout.SOUTH);
              frame.setVisible(true);
    }

    Looks like you didn't read the API for Container#doLayout().
    Causes this container to lay out its components. Most programs should not call this method directly, but should invoke the validate method instead.
    There's also a concurrency issue here in that the panel's components may be painted to the image before revalidation completes. And your GUI, like any Swing GUI, should be constructed and shown on the EDT.
    Try this for size -- it could be better, but I've made the minimum possible changes in your code:import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.BoxLayout;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.border.LineBorder;
    public class ChangeLayoutAndPaint {
      private static JPanel panel;
      private static JLabel label;
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            // the panel spread out vertically
            panel = new JPanel();
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            // the buttons in the panel
            JButton b1, b2, b3;
            panel.add(b1 = new JButton("One"));
            panel.add(b2 = new JButton("Two"));
            panel.add(b3 = new JButton("Three"));
            b1.setEnabled(false);
            b2.setEnabled(false);
            b3.setEnabled(false);
            // the label with a border around it to show size in a temp panel with flowlayout to not stuff around
            // with the actual size we want.
            JPanel thingy = new JPanel();
            label = new JLabel();
            // label.setBorder(new LineBorder(Color.black));
            thingy.add(label);
            // the button to make things go
            JButton button = new JButton("click me");
            button.addActionListener(new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                //change layout
                panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
                //panel.doLayout();
                panel.revalidate();
                SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                    //get image
                    BufferedImage image = new BufferedImage(panel.getPreferredSize().width,
                        panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
                    Graphics2D g = image.createGraphics();
                    panel.paintComponents(g);
                    g.dispose();
                    //set icon of jlabel
                    label.setIcon(new ImageIcon(image));
                    //change back
                    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
                    //panel.doLayout();
                    panel.revalidate();
            // the frame
            JFrame frame = new JFrame();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(400, 200);
            frame.setLocation(100, 100);
            frame.getContentPane().add(panel, BorderLayout.NORTH);
            frame.getContentPane().add(thingy, BorderLayout.CENTER);
            frame.getContentPane().add(button, BorderLayout.SOUTH);
            frame.setVisible(true);
    }db
    edit I prefer this:import java.awt.BorderLayout;
    import java.awt.Graphics;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class LayoutAndPaint {
      JPanel panel;
      JLabel label;
      public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            new LayoutAndPaint().makeUI();
      public void makeUI() {
        JButton one = new JButton("One");
        JButton two = new JButton("Two");
        JButton three = new JButton("Three");
        one.setEnabled(false);
        two.setEnabled(false);
        three.setEnabled(false);
        panel = new JPanel();
        panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
        panel.add(one);
        panel.add(two);
        panel.add(three);
        label = new JLabel();
        JButton button = new JButton("Click");
        button.addActionListener(new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            layoutAndPaint();
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setSize(400, 400);
        frame.add(panel, BorderLayout.NORTH);
        frame.add(label, BorderLayout.CENTER);
        frame.add(button, BorderLayout.SOUTH);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      private void layoutAndPaint() {
        panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
        panel.revalidate();
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            BufferedImage image = new BufferedImage(panel.getPreferredSize().width,
                panel.getPreferredSize().height, BufferedImage.TYPE_INT_ARGB);
            Graphics g = image.createGraphics();
            panel.paintComponents(g);
            g.dispose();
            label.setIcon(new ImageIcon(image));
            panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
            panel.revalidate();
    }db
    Edited by: DarrylBurke

  • Word document pdf printing with vertical and horizontal pages

    I have a Word document that has both vertical and horizontal formatted pages.  When I print to PDF, the I get a new pdf file whenever a page orientation change is found.  pages 1 to 7 are vertical, 8 to 12 are horizontal and 13 to 20 are vertical again.  If I print to a file named "out_to_PDF" I get 3 files named "out_to_PDF", "out_to_PDF2" and "out_to_PDF3", the first one with pages 1 to 7, the second one with pages 8 to 12 and the third one with the remaining pages.  Is there a way to get only one file with all the pages?
    I know I can merge the files later.  This file with 20 pages is no problem.  I have several 70+ page docs, with multiple changes between horizontal and vertical that will result in 20 or more separate pdf files.
    Any pointers?

    Word renders print jobs that change the orientation as separate print jobs. So, each print job becomes its own PDF.
    You can make an Automator workflow to combine PDFs. I’m not sure how it decides the order it combines them, so you’d have to experiment.
    This is built as an Application where you’d drop all of the PDFs onto the App icon and it will open the combined PDF where you can edit, name, and save.

Maybe you are looking for