Article View: borland.public.jbuilder.java.api
Article #668Print Preview of HTMLDocument
From: Lilia Petrova
Date: Sun, 13 Apr 2003 19:25
Date: Sun, 13 Apr 2003 19:25
64 lines
2335 bytes
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
Technical Details
Message-ID:
<3e99b8fa$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,770c0fa2aab7be90,start X-Google-Attributes: gid1089d0,public X-Google-ArrivalTime: 2003-04-13 12:28:03 PST From: "Lilia Petrova" <lpetrova@icygen.com> Newsgroups: borland.public.jbuilder.java.api Subject: Print Preview of HTMLDocument Date: Sun, 13 Apr 2003 22:25:18 +0300 Lines: 72 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1067 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1067 NNTP-Posting-Host: 195.96.228.205 Message-ID: <3e99b8fa$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1050261754 195.96.228.205 (13 Apr 2003 12:22:34 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail