Excel with hyperlinks, multiple pages, and print titles

I have two large excel files that have hyperlinks to the web. In standard page size, each will have multiple pages. Because it is continuous information, Print Titles are required at both the top rows and left columns. However, along with having to shut off Set Print Area, it seems I must also shut off Print Titles in order for Acrobat to maintain the links. The first problem isn't really a problem. Shutting off print titles, however, makes the document useless to readers. Does anyone have a workaround? The only thing that occurred to me is to manually split the pages (they could be linked to a master sheet so I still have a continuous master) and repeat the print title rows, but that seems like a lot of extra work since Excel isn't fond of linking large sections all at once.

I resolved this myself after much experimentation.
(1) Clear Print Area
(2) Remove values from Print Titles.
(3) Manually insert rows and columns that need to be repeated on each page. You can do this as links if you want to.
(4) If your spreadsheet needs lines all around the borders, make sure you one have one empty row and column on all four sides. Without this, you may lose some of the bordering lines.
(5) Hide ALL other unused rows and columns that you do not want to show. This effectively functions as a Set Print Area.
(6) Make the PDF.
(7) If necessary for further manipulation of the worksheet, hide the extra inserted rows and columns (Step 3) as you work with the worksheet and unhide them before publishing.

Similar Messages

  • How do you Spread an Image across multiple pages and print?

    I'm trying to create a large poster to be put on a bulletin board. I've mangaed to spread the image across multiple pages but I can't figure how to be able to print the pages have the edges line up successfully after cropping. I've been playing with the bleed settings but can't figure it out. Here a shot of what im working with:
    Im working in CS3 on Mac OS X

    Create your InDesign document at your final size and when you print it out put a check mark in the box for Tile

  • Scanning multiple pages from print book into computer

    How to scan multiple pages from print book into computer? Someone supplied a link to this question, but I got stuck at step 1: Where is "HP Director software"? In other directions, it says to open the "HP Scan window," but that option is not available to me when I follow the directions. I have an HP 2159m computer, HP Photosmart Plus all-in-one, Windows 7, and use Firefox, if that's any help.
    TIA

    I have a similar problem:
    I am using an HP Officejet 6310xi via its TWAIN interface.  Regardless of which application invokes TWAIN (whether Irfanview, Thumbs Plus, or something else), the scanner dialog closes after transferring each scanned image.  To scan the next page requires re-starting the scanner, beginning with a whole new preview and re-entering all my scan settings.  This is only an issue with the HP scanner, not with my Cannon CanoScan LIDE 100, Visioneer OneTouch 8920, or any other scanner, each of whose scanner dialogs stay open for scan after scan.  Can anyone help me make the HP scanner dialog stay open for multiple pages?
    Note: Based on a suggestion on another site I set my scan preferences to include "Prompt for Additional Scans from Glass" as follows, but it did not help.
    I am experienced at scanning, but I find it extremely frustrating that the HP scan dialog closes, forgetting its settings, after each page.
    If it helps others, I gladly share my article, "Freedom from Paper--At Last" here
    http://www.richpasco.org/paperless.html

  • Creating a template in Pages is straight-forward as answered here previously. Is there and equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template?

    Creating a template in Pages is straight-forward as answered here previously. Is there an equivalent for iBooks Author which can start with a blank page and build up the template as required? or can one only adapt a ready made template? This has proved unsatisfactory to me so far. Lines are left in etc.

    There are two basic menus for fonts - one from the main menu bar and one from the toolbar. You can also bring up the font manage dialog.
    I don't recommend trying to hard to force an otherwise foreign font, as it inevitably needs to be usable/supported on iOS as well, and that can get tricky w/3rd party fonts, as an example, even with the expanded font support in the latest iBA.
    If you need to discuss fonts more, I suggest starting a new thread....preferably with a slightly more brief title, thanks.

  • I am trying to save a document with the new pages and it will only save as a zip file any ideas on how to change this?

    I am trying to save a document with the new Pages and it is only saving as a ZIP file anyone know how to fix this or choose a different file type?

    Take a look at the FileSelector
    First make sure the FileSelector is expanded so you can see the directory and sidebar. That's what the little disclosure triangle up by the filename is for. Once the FS has been expanded to look like the above picture, look to see what subdirectory has been selected. Use the SideBar to select an appropriate one.

  • Open PDF with disable save as and Print option

    Hello,
    I want a pdf viewer to use it in my website with disabling save as and print ,i mean user only can see my books online.I need something like "books.google.com" viewer. It is possible thru java programming or with the help of any open source. Please provide me some solution i am in deep trouble.
    Thanks for any reply.
    Shambhu Mitra

    You cna do this with the security options in the PDF file itself, which you can set with Adobe Acrobat, assuming you have access to the security options in the first place.

  • I've been working with documents in pages and recently downloaded word for mac. i open the pages documents and they appear to be corrupt. at least, a lot of the font is now in weird boxed pictures. what do i do?

    I've been working with documents in Pages and recently downloaded Word for Mac. Upon opening Pages documents with Pages, the documents appear corrupt. Much of the font has been replaced with boxed little pictures - yet they are identified as times new roman. What do I do?

    You got the new iphone?????   I have same problem.  I transferred audiobooks to device to find no audiobooks on device (despite it being in iTunes as if it was).  Have you found a solution?????   I even tried to change import settings on format transfer but hasn't worked. 

  • PDF files will not open and eratically open multiple pages and then freezes up the page

    PDF files will not open and eratically opens multiple pages and then the laptop freezes up. Please help.

    E Denice wrote:
    PDF files will not open and eratically opens multiple pages and then the laptop freezes up.
    Doesn't make much sense to me. Methinks details are needed.

  • How do i mail merge with the new Pages and Numbers?

    How do I mail merge with the new Pages and Numbers?
    On Pages 09 I have a document that draws variable data from a spreadsheet created in Numbers.
    With the new Pages and Numbers program update, my links are lost and I am unable to see how to correct this.

    Thanks Peter,
    very disappointing.
    My Pages 09 keeps opening in the new one.
    I dont think they want me to be a loyal customer anymore.
    They changed Final Cut Pro, so now I use Premier Pro
    Aperture 3 has been left behind so now I moved to Lightroom 4.
    And now Pages 5 does not have a vital component, so back to Word.
    Sad day
    Thanks again

  • New session started with an advertizing page and all my tabs are lost

    New session started with an advertizing page and all my tabs are lost. Restore the previous session is not active. How can I restore my tabs?

    This advice might come too late, but, don't exit Firefox! Or if you already did, don't start it back up again!
    ''If Firefox is running:'' Open your current Firefox settings (AKA Firefox profile) folder using either
    * "3-bar" menu button > "?" button > Troubleshooting Information
    * (menu bar) Help > Troubleshooting Information
    * type or paste about:support in the address bar and press Enter
    In the first table on the page, click the "Show Folder" button. This should launch a new window listed various files and folders. For best results, change the view to "Details".
    (''If Firefox not running, get to this folder by pasting the following in the Run box on the start menu and pressing Enter: %APPDATA%\Mozilla\Firefox\Profiles and then double-click into the most recently updated semi-randomly-named folder you find there.'')
    In the window that launches, scroll down and double-click into the '''sessionstore-backups''' folder. Save all files here to a safe location, such as your Documents folder, so Firefox doesn't overwrite them. We may be able to use them to recover your lost tabs.
    Also, if you return to the main level of the profile folder, you may find some sessionstore files. Copy those to the safe location as well.
    Could you report back on what you found?
    Note: If Windows hides the .js file extension from you, you can change a setting so that you can see all file extensions (this helps when renaming files). This support article has the steps: http://support.microsoft.com/kb/865219 or http://windows.microsoft.com/en-us/windows/show-hide-file-name-extensions
    The kinds of files you may find among your sessionstore-backup files are:
    * recovery.js: the windows and tabs in your currently live Firefox session (or, if Firefox is closed, your last session)
    * recovery.bak: a backup copy of recovery.js
    * previous.js: the windows and tabs in your last Firefox session
    * upgrade.js-''build_id'': the windows and tabs in the Firefox session that was live at the time of your last update

  • Firefox opens with a window that says "Checking for compatibility for Add-ons" then it always opens 2 tabs... one with my home page and one that says Congratulations, Firefox is up to date. How can I stop it from starting that way?

    Firefox opens with a window that says "Checking for compatibility for Add-ons" then it always opens 2 tabs... one with my home page and one that says Congratulations, Firefox is up

    Hi konee,
    You should look at [https://support.mozilla.com/kb/Firefox+has+just+updated+tab+shows+each+time+you+start+Firefox this article about that specific issue] and the article [http://kb.mozillazine.org/Preferences_not_saved Preferences not saved]. These should give you all the information you need!
    If that doesn't work:
    # Type about:config in the address bar
    # Click ''I'll be careful, I promise'' if prompted
    # In the Filter input field type ''startup''
    # Double click on startup.homepage_override_url
    # Delete the text string and click ''OK''
    # Close Firefox and reopen the window to verify that it has worked.
    Hopefully this helps!

  • My safari opens with a blank page and closes back. What should I do?

    My safari opens with a blank page and closes back. What should I do

    Hi there,
    I would recommed trying this: force close the Safari application and then reset the iPhone.
    -Griff W.

  • Print JTable with Multiple pages and rows

    I took the printing example at http://java.sun.com/developer/onlineTraining/Programming/JDCBook/advprint.html#pe and modified it a bit to include the following:
    1) To Print Multiple pages
    2) To wrap lines that is too long for the column
    3) To print with a more proffesional style, so that it doesn't look like a screen capture is printed
    4) To align the numbers to the right and center column headings
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.print.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.Dimension;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import java.text.*;
    public class Report implements Printable
         private final int LEFT_ALIGN = -1;
         private final int CENTER_ALIGN = 0;
         private final int RIGHT_ALIGN = 1;
         private JFrame frame;
         private JTable tableView;
         private String lastPrintDate;
         private Font defaultFont;
         private Font headerFont;
         private Font footerFont;
         private int headerHeight;
         private int footerHeight;
         private int cellBuffer = 5;
         private boolean first_pass;
         private ArrayList pages;
         public Report()
              frame = new JFrame("Sales Report");
              frame.addWindowListener(new WindowAdapter()
                   public void windowClosing(WindowEvent e)
                        System.exit(0);
              final String[] headers =
                   "ID",
                   "Description",
                   "open price",
                   "latest price",
                   "End Date",
                   "Quantity"
              int count = 0;
              final Object[][] data =
                   {new Integer(count++), "Box of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of BirosBox of Biros ppppppppppppppp", "1.00", "4.99", new Date(), new Integer(200000)},
                   {new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
                   {new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
                   {new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++), "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
                   {new Integer(count++), "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++), "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++), "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++), "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
                   {new Integer(count++),  "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++),  "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)},
                   {new Integer(count++),  "Blue Biro", "0.10", "0.14", new Date(), new Integer(1)},
                   {new Integer(count++),  "legal pad", "1.00", "2.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "tape", "1.00", "1.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "stapler", "4.00", "4.49", new Date(), new Integer(1)},
                   {new Integer(count++),  "Box of Biros", "1.00", "4.99", new Date(), new Integer(2)}
              TableModel dataModel = new AbstractTableModel()
                   public int getColumnCount() { return headers.length; }
                   public int getRowCount() { return data.length;}
                   public Object getValueAt(int row, int col)
                        return data[row][col];
                   public String getColumnName(int column)
                        return headers[column];
                   public Class getColumnClass(int col)
                        return getValueAt(0,col).getClass();
                   public boolean isCellEditable(int row, int col)
                        return (col==1);
                   public void setValueAt(Object aValue, int row, int column)
                        data[row][column] = aValue;
              tableView = new JTable(dataModel);
              JScrollPane scrollpane = new JScrollPane(tableView);
              scrollpane.setPreferredSize(new Dimension(500, 80));
              frame.getContentPane().setLayout(new BorderLayout());
              frame.getContentPane().add(BorderLayout.CENTER,scrollpane);
              frame.pack();
              JButton printButton= new JButton();
              printButton.setText("print me!");
              frame.getContentPane().add(BorderLayout.SOUTH,printButton);
              // for faster printing turn double buffering off
              RepaintManager.currentManager(frame).setDoubleBufferingEnabled(false);
              printButton.addActionListener( new ActionListener()
                   public void actionPerformed(ActionEvent evt)
                        doPrint();
              frame.setVisible(true);
          * Reset variables before printing
         private void prepareForPrint()
              pages = new ArrayList();
              first_pass = true;
          * Display a print dialog with some hardcoded defaults
          * The print fonts are also hardcoded
         public void doPrint()
              try
                   String jobName = "Java Report";
                   defaultFont = new Font("Arial", Font.PLAIN, 8);
                   footerFont = new Font("Arial", Font.PLAIN, 6);
                   headerFont = new Font("Arial", Font.BOLD, 10);
                   PrinterJob prnJob = PrinterJob.getPrinterJob();
                   prnJob.setPrintable(this);
                   PrintRequestAttributeSet prnSet = new HashPrintRequestAttributeSet();
                   prnSet.add(new Copies(1));
                   prnSet.add(new JobName(jobName, null));
                   prnSet.add(MediaSizeName.ISO_A4);
                   PageFormat pf = prnJob.defaultPage();
                   pf.setOrientation(java.awt.print.PageFormat.PORTRAIT);
                   prnJob.setJobName(jobName);
                   PrintService[] services = PrinterJob.lookupPrintServices();
                   if (services.length > 0)
                        if (prnJob.printDialog(prnSet))
                              * Get print date
                             String dateFormat = "dd/MM/yyyy HH:mm:ss";
                             DateFormat m_DateFormat = new SimpleDateFormat(dateFormat);
                             lastPrintDate = m_DateFormat.format(new Date()).toString();
                             prepareForPrint();
                             prnJob.print(prnSet);
                   else
                        JOptionPane.showMessageDialog(frame, "No Printer was found!!", "Printer Error", JOptionPane.ERROR_MESSAGE);
                        return;
              catch (PrinterException e)
                   e.printStackTrace();
         public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
               * Check if this is the first time the print method is called for this print action.
               * It is not guaranteed that the print will be called with synchronous pageIndex'es,
               * so we need to calculate the number of pages and which rows appear on which pages.
               * Then the correct page will be printed regardless of which pageIndex is sent through.
              if (first_pass)
                   calcPages(g, pageFormat);
              first_pass = false;
              // Stop printing if the pageIndex is out of range
              if (pageIndex >= pages.size())
                   return NO_SUCH_PAGE;
              Graphics2D     g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              // The footer will be one line at the bottom of the page, cater for this.
              g2.setFont(footerFont);
              footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
              g2.setFont(defaultFont);
              FontMetrics fontMetrics = g2.getFontMetrics();
              int fontHeight = fontMetrics.getHeight();
              int fontDescent = fontMetrics.getDescent();
              double pageHeight = pageFormat.getImageableHeight() + pageFormat.getImageableY();
              double pageWidth = pageFormat.getImageableWidth();
              double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
              // Shrink or expand the table to fit the page width
              double scale = pageWidth / (tableWidth+ (cellBuffer * tableView.getColumnCount()));
              // Calculate the width in pixels for each column
              double[] columnWidths = new double[tableView.getColumnCount()];
              for(int i = 0; i < tableView.getColumnCount(); i++)
                   columnWidths[i] = (double)tableView.getColumnModel().getColumn(i).getWidth() * scale;
              // Reset the view to the start of the page
              g2.translate(0, 0);
              // Draw a rectangle to see the printable area
              g2.draw3DRect((int)pageFormat.getImageableX(),
                        (int)pageFormat.getImageableY(),
                        (int)pageFormat.getImageableWidth(),
                        (int)pageFormat.getImageableHeight(),
                        false);
              // Calculate the header height
              g2.setFont(headerFont);
              fontMetrics = g2.getFontMetrics();
              // Print the headers and retreive the starting position for the data
              int next_row = printLine(g2, pageFormat, fontMetrics, -1, (int)pageFormat.getImageableY() + fontHeight, columnWidths);
              g2.setFont(defaultFont);
              fontMetrics = g2.getFontMetrics();
              // Start printing the detail
              ArrayList page = (ArrayList)pages.get(pageIndex);
              int start = ((Integer)page.get(0)).intValue();
              int end = ((Integer)page.get(1)).intValue();
              for (int i = start; i <= end; i++)
                   next_row = printLine(g2, pageFormat, fontMetrics, i, next_row, columnWidths);
              // Print the footer
              g2.setFont(footerFont);
              String pageFooter = "Page " + (pageIndex + 1) + " - " + lastPrintDate;
              g2.drawString(pageFooter,
                             (int)pageFormat.getWidth() / 2 - (fontMetrics.stringWidth(pageFooter) / 2),
                             (int)(pageHeight - fontDescent));
              return PAGE_EXISTS;
          * We can't guarantee that the same amount of rows will be displayed on each page,
          * the row heights are dynamic and may wrap onto 2 or more lines.
          * Thus we need to calculate the height of each row and then test how may rows
          * fit on a specific page. eg. Page 1 contains rows 1 to 10, Page 2 contains rows 11 to 15 etc.
         public void calcPages(Graphics g, PageFormat pageFormat) throws PrinterException
              Graphics2D     g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              // The footer will be one line at the bottom of the page, cater for this.
              g2.setFont(footerFont);
              footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
              g2.setFont(defaultFont);
              FontMetrics fontMetrics = g2.getFontMetrics();
              int fontHeight = fontMetrics.getHeight();
              int fontDescent = fontMetrics.getDescent();
              double pageHeight = pageFormat.getImageableHeight() - fontHeight;
              double pageWidth = pageFormat.getImageableWidth();
              double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
              // Shrink or expand the table to fit the page width
              double scale = pageWidth / (tableWidth+ (cellBuffer * tableView.getColumnCount()));
              // Calculate the width in pixels for each column
              double[] columnWidths = new double[tableView.getColumnCount()];
              for(int i = 0; i < tableView.getColumnCount(); i++)
                   columnWidths[i] = (double)tableView.getColumnModel().getColumn(i).getWidth() * scale;
              // Calculate the header height
              int maxHeight = 0;
              g2.setFont(headerFont);
              fontMetrics = g2.getFontMetrics();
              for (int j = 0; j < tableView.getColumnCount(); j++)
                   String value = tableView.getColumnName(j).toString();
                   int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                   if (numLines > maxHeight)
                        maxHeight = numLines;
              headerHeight = g2.getFontMetrics().getHeight() * maxHeight;
              g2.setFont(defaultFont);
              fontMetrics = g2.getFontMetrics();
              int pageNum = 0;
              int bottom_of_page = (int)(pageFormat.getImageableHeight() + pageFormat.getImageableY()) - footerHeight;
              int prev_row = 0;
              int next_row = (int)pageFormat.getImageableY() + fontHeight + headerHeight;
              int i = 0;
              ArrayList page = new ArrayList();
              page.add(new Integer(0));
              for (i = 0; i < tableView.getRowCount(); i++)
                   maxHeight = 0;
                   for (int j = 0; j < tableView.getColumnCount(); j++)
                        String value = tableView.getValueAt(i, j).toString();
                        int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                        if (numLines > maxHeight)
                             maxHeight = numLines;
                   prev_row = next_row;
                   next_row += (fontHeight * maxHeight);
                   // If we've reached the bottom of the page then set the current page's end row
                   if (next_row > bottom_of_page)
                        page.add(new Integer(i - 1));
                        pages.add(page);
                        page = new ArrayList();
                        page.add(new Integer(i));
                        pageNum++;
                        next_row = (int)pageFormat.getImageableY()
                                       + fontHeight
                                       + ((int)pageFormat.getHeight() * pageNum)
                                       + headerHeight;
                        bottom_of_page = (int)(pageFormat.getImageableHeight()
                                            + pageFormat.getImageableY())
                                            + ((int)pageFormat.getHeight() * pageNum)
                                            - footerHeight;
                        //Include the current row on the next page, because there is no space on this page
                        i--;
              page.add(new Integer(i - 1));
              pages.add(page);
          * Print the headers or a row from the table to the graphics context
          * Return the position of the row following this one
         public int printLine(Graphics2D g2,
                                       PageFormat pageFormat,
                                       FontMetrics fontMetrics,
                                       int rowNum,
                                       int next_row,
                                       double[] columnWidths)
                   throws PrinterException
              int lead = 0;
              int maxHeight = 0;
              for (int j = 0; j < tableView.getColumnCount(); j++)
                   String value = null;
                   int align = LEFT_ALIGN;
                   if (rowNum > -1)
                        Object obj = tableView.getValueAt(rowNum, j);
                        if (obj instanceof Number)
                             align = RIGHT_ALIGN;
                        value = obj.toString();
                   else
                        align = CENTER_ALIGN;
                        value = tableView.getColumnName(j);
                   int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                   if (numLines > maxHeight)
                        maxHeight = numLines;
                   if (fontMetrics.stringWidth(value) < columnWidths[j])
                        // Single line
                        int offset = 0;
                        // Work out the offset from the start of the column to display alignment correctly
                        switch (align)
                             case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
                             case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
                             default: offset = 0; break;
                        g2.drawString(value,
                                       lead + (int)(pageFormat.getImageableX() + offset),
                                       next_row);
                   else
                        for(int a = 0; a < numLines; a++)
                             //Multi-Line
                             int x = 0;
                             int width = 0;
                             for(x = 0; x < value.length(); x++)
                                  width += fontMetrics.charWidth(value.charAt(x));
                                  if (width > columnWidths[j])
                                       break;
                             int offset = 0;
                             // Work out the offset from the start of the column to display alignment correctly
                             switch (align)
                                  case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
                                  case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
                                  default: offset = 0; break;
                             g2.drawString(value.substring(0, x),
                                            lead + (int)(pageFormat.getImageableX() + offset),
                                            next_row + (fontMetrics.getHeight() * a));                    
                             value = value.substring(x);
                   lead += columnWidths[j] + cellBuffer;
              // Draw a solid line below the row
              g2.draw(new Line2D.Double(pageFormat.getImageableX(),
                             next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent(),
                             pageFormat.getImageableY() + pageFormat.getImageableWidth(),
                             next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent()));
              // Return the position of the row following this one
              return next_row + (fontMetrics.getHeight() * maxHeight);
         public static void main(String[] args)
              new Report();
    }

    Fixed some bugs and added a title. Just pass in a JTable and the class will do the rest.
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.print.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.print.*;
    import javax.print.attribute.*;
    import javax.print.attribute.standard.*;
    import java.text.*;
    import java.math.*;
    public class PrintJTable implements Printable
         private final int LEFT_ALIGN = -1;
         private final int CENTER_ALIGN = 0;
         private final int RIGHT_ALIGN = 1;
         private JFrame m_parent;
         private String m_title;
         private JTable tableView;
         private String lastPrintDate;
         private Font defaultFont;
         private Font headerFont;
         private Font footerFont;
         private int headerHeight;
         private int footerHeight;
         private int cellBuffer = 5;
         private boolean first_pass;
         private ArrayList pages;
         public PrintJTable(JFrame parent, JTable table)
              m_parent = parent;
              tableView = table;
              doPrint();
         public PrintJTable(JFrame parent, String title, JTable table)
              m_parent = parent;
              m_title = title;
              tableView = table;
              doPrint();
          * Reset variables before printing
         private void prepareForPrint()
              pages = new ArrayList();
              first_pass = true;
          * Display a print dialog with some hardcoded defaults
          * The print fonts are also hardcoded
         public void doPrint()
              try
                   String jobName = "Java Report";
                   defaultFont = new Font("Arial", Font.PLAIN, 8);
                   footerFont = new Font("Arial", Font.PLAIN, 6);
                   headerFont = new Font("Arial", Font.BOLD, 8);
                   PrinterJob prnJob = PrinterJob.getPrinterJob();
                   prnJob.setPrintable(this);
                   PrintRequestAttributeSet prnSet = new HashPrintRequestAttributeSet();
                   prnSet.add(new Copies(1));
                   prnSet.add(new JobName(jobName, null));
                   prnSet.add(MediaSizeName.ISO_A4);
                   PageFormat pf = prnJob.defaultPage();
                   pf.setOrientation(java.awt.print.PageFormat.PORTRAIT);
                   prnJob.setJobName(jobName);
                   PrintService[] services = PrinterJob.lookupPrintServices();
                   if (services.length > 0)
                        if (prnJob.printDialog(prnSet))
                              * Get print date
                             String dateFormat = "dd/MM/yyyy HH:mm:ss";
                             DateFormat m_DateFormat = new SimpleDateFormat(dateFormat);
                             lastPrintDate = m_DateFormat.format(new Date()).toString();
                             prepareForPrint();
                             prnJob.print(prnSet);
                   else
                        JOptionPane.showMessageDialog(m_parent, "No Printer was found!!", "Printer Error", JOptionPane.ERROR_MESSAGE);
                        return;
              catch (PrinterException e)
                   e.printStackTrace();
         public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException
               * Check if this is the first time the print method is called for this print action.
               * It is not guaranteed that the print will be called with synchronous pageIndex'es,
               * so we need to calculate the number of pages and which rows appear on which pages.
               * Then the correct page will be printed regardless of which pageIndex is sent through.
              if (first_pass)
                   calcPages(g, pageFormat);
              first_pass = false;
              // Stop printing if the pageIndex is out of range
              if (pageIndex >= pages.size())
                   return NO_SUCH_PAGE;
              Graphics2D     g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              // The footer will be one line at the bottom of the page, cater for this.
              g2.setFont(footerFont);
              footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
              g2.setFont(defaultFont);
              FontMetrics fontMetrics = g2.getFontMetrics();
              int fontHeight = fontMetrics.getHeight();
              int fontDescent = fontMetrics.getDescent();
              double pageHeight = pageFormat.getImageableHeight() + pageFormat.getImageableY();
              double pageWidth = pageFormat.getImageableWidth();
              double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
              // Shrink or expand the table to fit the page width
              double scale = (pageWidth - (cellBuffer * tableView.getColumnCount())) / tableWidth;
              // Calculate the width in pixels for each column
              double[] columnWidths = new double[tableView.getColumnCount()];
              double test = 0;
              for(int i = 0; i < tableView.getColumnCount(); i++)
                   columnWidths[i] = (double)Math.floor(tableView.getColumnModel().getColumn(i).getWidth() * scale);
                   test += columnWidths;
              // Reset the view to the start of the page
              g2.translate(0, 0);
              // Draw a rectangle to see the printable area
              g2.draw3DRect((int)pageFormat.getImageableX(),
                        (int)pageFormat.getImageableY(),
                        (int)pageFormat.getImageableWidth(),
                        (int)pageFormat.getImageableHeight(),
                        false);
              // Calculate the header height
              g2.setFont(headerFont);
              fontMetrics = g2.getFontMetrics();
              // Print the headers and retreive the starting position for the data
              int next_row = (int)pageFormat.getImageableY() + fontMetrics.getHeight();
              if ((m_title != null) && (!m_title.equalsIgnoreCase("")))
                   g2.drawString(m_title,
                                       (int)(pageFormat.getImageableX()),
                                       next_row);
                   Color current_color = g2.getColor();
                   g2.setColor(Color.lightGray);
                   int y = next_row + fontMetrics.getDescent();
                   g2.draw(new Line2D.Double(pageFormat.getImageableX(),
                                  y,
                                  (pageFormat.getImageableY() + pageFormat.getImageableWidth()),
                                  y));
                   g2.setColor(current_color);
                   next_row += fontMetrics.getHeight();
              next_row = printLine(g2, pageFormat, fontMetrics, -1, next_row, columnWidths);
              g2.setFont(defaultFont);
              fontMetrics = g2.getFontMetrics();
              // Start printing the detail
              ArrayList page = (ArrayList)pages.get(pageIndex);
              int start = ((Integer)page.get(0)).intValue();
              int end = ((Integer)page.get(1)).intValue();
              for (int i = start; i <= end; i++)
                   next_row = printLine(g2, pageFormat, fontMetrics, i, next_row, columnWidths);
              // Print the footer
              g2.setFont(footerFont);
              String pageFooter = "Page " + (pageIndex + 1) + " - " + lastPrintDate;
              g2.drawString(pageFooter,
                             (int)pageFormat.getWidth() / 2 - (fontMetrics.stringWidth(pageFooter) / 2),
                             (int)(pageHeight - fontDescent));
              return PAGE_EXISTS;
         * We can't guarantee that the same amount of rows will be displayed on each page,
         * the row heights are dynamic and may wrap onto 2 or more lines.
         * Thus we need to calculate the height of each row and then test how may rows
         * fit on a specific page. eg. Page 1 contains rows 1 to 10, Page 2 contains rows 11 to 15 etc.
         public void calcPages(Graphics g, PageFormat pageFormat) throws PrinterException
              Graphics2D     g2 = (Graphics2D) g;
              g2.setColor(Color.black);
              // The footer will be one line at the bottom of the page, cater for this.
              g2.setFont(footerFont);
              footerHeight = g2.getFontMetrics().getHeight() + g2.getFontMetrics().getDescent();
              g2.setFont(defaultFont);
              FontMetrics fontMetrics = g2.getFontMetrics();
              int fontHeight = fontMetrics.getHeight();
              int fontDescent = fontMetrics.getDescent();
              double pageHeight = pageFormat.getImageableHeight() - fontHeight;
              double pageWidth = pageFormat.getImageableWidth();
              double tableWidth = (double) tableView.getColumnModel().getTotalColumnWidth();
              // Shrink or expand the table to fit the page width
              double scale = (pageWidth - (cellBuffer * tableView.getColumnCount())) / tableWidth;
              // Calculate the width in pixels for each column
              double[] columnWidths = new double[tableView.getColumnCount()];
              for(int i = 0; i < tableView.getColumnCount(); i++)
                   columnWidths[i] = (double)Math.floor(tableView.getColumnModel().getColumn(i).getWidth() * scale);
              // Calculate the header height
              int maxHeight = 0;
              g2.setFont(headerFont);
              fontMetrics = g2.getFontMetrics();
              headerHeight = 0;
              if ((m_title != null) && (!m_title.equalsIgnoreCase("")))
                   headerHeight = fontMetrics.getHeight();
              for (int j = 0; j < tableView.getColumnCount(); j++)
                   String value = tableView.getColumnName(j).toString();
                   int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                   if (numLines > maxHeight)
                        maxHeight = numLines;
              headerHeight += g2.getFontMetrics().getHeight() * maxHeight;
              g2.setFont(defaultFont);
              fontMetrics = g2.getFontMetrics();
              int pageNum = 0;
              int bottom_of_page = (int)(pageFormat.getImageableHeight() + pageFormat.getImageableY()) - footerHeight;
              int prev_row = 0;
              int next_row = (int)pageFormat.getImageableY() + fontHeight + headerHeight;
              int i = 0;
              ArrayList page = new ArrayList();
              page.add(new Integer(0));
              for (i = 0; i < tableView.getRowCount(); i++)
                   maxHeight = 0;
                   for (int j = 0; j < tableView.getColumnCount(); j++)
                        String value = formatObject(tableView.getValueAt(i, j));
                        int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                        if (numLines > maxHeight)
                             maxHeight = numLines;
                   prev_row = next_row;
                   next_row += (fontHeight * maxHeight);
                   // If we've reached the bottom of the page then set the current page's end row
                   if (next_row > bottom_of_page)
                        page.add(new Integer(i - 1));
                        pages.add(page);
                        page = new ArrayList();
                        page.add(new Integer(i));
                        pageNum++;
                        next_row = (int)pageFormat.getImageableY()
                                       + fontHeight
                                       + ((int)pageFormat.getHeight() * pageNum)
                                       + headerHeight;
                        bottom_of_page = (int)(pageFormat.getImageableHeight()
                                            + pageFormat.getImageableY())
                                            + ((int)pageFormat.getHeight() * pageNum)
                                            - footerHeight;
                        //Include the current row on the next page, because there is no space on this page
                        i--;
              page.add(new Integer(i - 1));
              pages.add(page);
         * Print the headers or a row from the table to the graphics context
         * Return the position of the row following this one
         public int printLine(Graphics2D g2,
                                       PageFormat pageFormat,
                                       FontMetrics fontMetrics,
                                       int rowNum,
                                       int next_row,
                                       double[] columnWidths)
                   throws PrinterException
              int lead = 0;
              int maxHeight = 0;
              for (int j = 0; j < tableView.getColumnCount(); j++)
                   String value = null;
                   int align = LEFT_ALIGN;
                   if (rowNum > -1)
                        Object obj = tableView.getValueAt(rowNum, j);
                        if (obj instanceof Number)
                             align = RIGHT_ALIGN;
                        value = formatObject(obj);
                   else
                        //align = CENTER_ALIGN;
                        value = tableView.getColumnName(j);
                   int numLines = (int)Math.ceil(fontMetrics.stringWidth(value) / columnWidths[j]);
                   if (numLines > maxHeight)
                        maxHeight = numLines;
                   if (fontMetrics.stringWidth(value) < columnWidths[j])
                        // Single line
                        int offset = 0;
                        // Work out the offset from the start of the column to display alignment correctly
                        switch (align)
                             case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)); break;
                             case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value)) / 2; break;
                             default: offset = 0; break;
                        g2.drawString(value,
                                       lead + (int)(pageFormat.getImageableX() + offset),
                                       next_row);
                   else
                        for(int a = 0; a < numLines; a++)
                             //Multi-Line
                             int x = 0;
                             int width = 0;
                             for(x = 0; x < value.length(); x++)
                                  width += fontMetrics.charWidth(value.charAt(x));
                                  if (width > columnWidths[j])
                                       break;
                             int offset = 0;
                             // Work out the offset from the start of the column to display alignment correctly
                             switch (align)
                                  case RIGHT_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value.substring(0, x))); break;
                                  case CENTER_ALIGN: offset = (int)(columnWidths[j] - fontMetrics.stringWidth(value.substring(0, x))) / 2; break;
                                  default: offset = 0; break;
                             g2.drawString(value.substring(0, x),
                                            lead + (int)(pageFormat.getImageableX() + offset),
                                            next_row + (fontMetrics.getHeight() * a));                    
                             value = value.substring(x);
                   lead += columnWidths[j] + cellBuffer;
              // Draw a solid line below the row
              Color current_color = g2.getColor();
              g2.setColor(Color.lightGray);
              int y = next_row + (fontMetrics.getHeight() * (maxHeight - 1)) + fontMetrics.getDescent();
              g2.draw(new Line2D.Double(pageFormat.getImageableX(),
                             y,
                             (pageFormat.getImageableY() + pageFormat.getImageableWidth()),
                             y));
              g2.setColor(current_color);
              // Return the position of the row following this one
              return next_row + (fontMetrics.getHeight() * maxHeight);
         public String formatObject(Object obj)
              String value = (obj == null) ? "" : obj.toString();
              return value;

  • Error printing multiple pages and incomplete pages if minimise document

    I have had this issue before but can't remember how I resolved it.  When I print from my Lenovo desktop the printer fails to print multiple pages at a time and also if I close or minimise a document I am printing then the printer will stop mid page.

    Hello @Lindseyjc81 , and welcome to the HP Forums, I hope you enjoy your experience!
    I see you're having issues printing multiple pages.  I would like to help!
    Do you have any issues making a copy?
    I'd recommend starting with a power reset.  Disconnect the power cord from the printer and the power outlet, then wait 60 seconds. After 60 seconds, plug the printer back in. Ensure you plug the printer directly to a wall outlet. Make sure to bypass any sort of surge protector or power bar.
    I would also recommend downloading and running the HP Print and Scan Doctor.
    Good luck and please let me know the results of your troubleshooting steps. Thank you for posting on the HP Forums!
    Please click “Accept as Solution " if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks" for helping!
    Jamieson
    I work on behalf of HP
    "Remember, I'm pulling for you, we're all in this together!" - Red Green.

  • How do I "Print Booklet" with just odd pages and even pages for duplexing . . options disabled

    I have InDesign CS5.5 on a Windows 7 64-bit machine hooked to a Xerox 7750 printer.  I have created a 8.5x11 portrait document and trying to create a booklet on 12x18 sheets.
    I need to print duplex manually and so I need to print just the odd spreads and then the even spreads.
    I have printed to Adobe PDF and printed from my created PDF file and have it working, but I want to know why InDesign won't let me do it.  When I click "File > Print Booklet > Print Settings" then it shows the Print Dialog box with the Pages section, which includes the Sequence that normally would allow me to do Odd Pages or Even Pages, but it is disabled.  Why?  I can define Print Presets and I can choose Odd Pages, but when I choose that in the Preset box it does not show anything, everything is still disabled.
    Anybody have any idea of why it is disabled?  Is it my printer driver?

    I too was very frustrated after upgrading to indesign cs5.5 and the latest LION OS on my new MAC.  I missed the odd/even page selection in the print dialog box within Indesign.  I tried about everything and found little of value in various forums.  But I did find a workable solution that makes since in terms of Apple's OS.
    My objective is to "impose" my document and also end up with a file that I can just print again and again without "ripping" in the InDesign Print Booklet Dialog.
    Here is the quick version of what to do.  I am not including every little step with pictures. =)  (I can if there is interest.)
    1. create your document
    2. Print Booklet
    3. At the first dialog box, just ignore the printer in print preset (you will come back to this) and go to the 2-up perfect bound option and select 16 page signatures.  This will impose 2-up on 4 physical pieces of paper printed both sides.  So 16 of your document pages printed duplex on 4 physical sheets of paper.  It would be nice to then just select the printer and scaling, etc. and the option to print even pages, flip over and then print odd pages but that ain't an option.  If you have different needs, do the math and input the correct numbers before proceeding
    4. Click on Print Settings  to pull up a second dialog box.
    5. Select for Printer PostScript File (not your printer)  Also select for PPD your printer or Adobe PDF 9 if you have that installed.  Don't obsess on this just pick your Printer for the PPD.
    6. Select 1 copy and All Pages while in the General Tab
    7. Select the Setup Tab Here is where you put in the actual physical paper size that you are going to print your document on. Don't scale to fit.  You must do this.  If you feel the need, check out all the tabs and options but for now, you are just trying to get an output file.  You probably do want to select CENTER for page position in this same setup tab.
    8. Hit OK whcih will return you to the original dialog.  Check when you return to be sure that at the top Printer is populated with PostScript File.  Click on Print and give the thing a name and a location to save at the resulting dialog.
    Breathe as you are almost home.  You have sucessfully created a file that can be called up again and again without opening InDesign. (albeit, a postscript file but not a problem)
    Now,
    1. Double click on this new file (it will have a .ps extention) or just open it in your PREVIEW (apple supplied utility)   Preview is where you accomplish the even and odd page objective.
    2. Preview will show you a short progress dialog while it rips this postscript file into a PDF.
    3. Click on PRINT
    4. Select your printer,page range, select the Paper Size (again not document size  but  the size sheet that you are printing the 2-up , imposed (booklet) document on. If not in the selection dialog, then use the custom option to create it (custom paper size) and give it a name.
    5. Click on SCALE and insert 100% in place of the weird number that it will insert for you.  You will then see your document correctly displayed in the sidebar preview window.
    6.  OK, now what you have been waiting for. Click on the box that says Preview (the active window) and select Paper Handling from the drop-down and select from Pages to Print the coveted odd or even page selection.  You can also do other things that should have been back at the InDesign print dialog but are now gone.  Explore. Enjoy.
    7.  You will have to work out your own work flow about reverse or no reverse order and how to flip, etc. But you will be working with something predictable at this point.
    8.  Since this has been ripped into a PDF , you might as well Click on the PDF button and click on save as a PDF at this point to save that postscript to PDF rip.   Also print using PREVIEW for the newly created PDF file next time as you will not have to learn a bunch of new dialogs and be frustrated all over again.
    I am now back in business printing the book blocks for my handbound journals.

Maybe you are looking for

  • Open file & close folder that it's in - in one step

    I want to be able to double click a file to open it and then the folder this file is in closes so that it is no longer open on my desktop. Is there a one step way to do this?

  • Itunes is purple...how do i get it back to normal

    I upgraded to itunes 8 and after using it for a while, the backdrop is now purple instead of white. This makes reading the song lists and creating playlists very hard. Does anyone know what causes this and/or how to get it back to normal? Do I have t

  • SharedPageFlows / GlobalApp / Portal 9.2 Upgrade

    Hello all. I am in need of some assistance regarding the updated GlobalApp. We are working on upgrading an application from WebLogic Server/Portal 8.1 to WebLogic Server/Portal 9.2 In so doing, I've run across some behavior I don't understand and wit

  • Start-process -arguments

    Hi, Can anyone see why this is running the program but not passing the arguments across.  It fires up but then closes, with no logs that I can find $startRichCopy = "C:\RichCopy4.0\RichCopy64.exe" $arguments = "d:\internal \\remotenas.qav-dr.com\QAV-

  • Mac OS 10.3 and Windows NT server

    Is it possible to get a Mac running OS 10.3 to see a Windows NT server and access the data in the Mac Volume?