🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.api
1 messages
1 total messages Started by Lilia Petrova Sun, 13 Apr 2003 19:25
Print Preview of HTMLDocument
#668
Author: Lilia Petrova
Date: Sun, 13 Apr 2003 19:25
64 lines
2335 bytes
I have problem to make a printPreview of a long html table. The problem
appears when the table takes more than one page. No problem when the table
fits in a page. I am using JTaxtPane, a class that extends HTMLDocument, and
Printable interface. I have implemented the following print() method:



        public int print(Graphics pg, PageFormat pageFormat,

           int pageIndex) throws PrinterException {

            pg.translate((int)pageFormat.getImageableX(),

              (int)pageFormat.getImageableY());

            int wPage = (int)pageFormat.getImageableWidth();

            int hPage = (int)pageFormat.getImageableHeight();

            pg.setClip(0, 0, wPage, hPage);



            // Only do this once per print

            if (m_printView == null) {

              BasicTextUI btui = (BasicTextUI)m_editor.getUI();

              View root = btui.getRootView(m_editor);

                m_printView = new PrintView(

                    m_doc.getDefaultRootElement().getElement(0),

                    root, wPage, hPage);

            }



            boolean bContinue = m_printView.paintPage(pg,

              hPage, pageIndex);

            System.gc();



            if (bContinue)

              return PAGE_EXISTS;

            else {

              m_printView = null;

              return NO_SUCH_PAGE;

            }

          }

where m_editor is JTextPane, m_doc is HTMDocument
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads