Click to See Complete Forum and Search --> : printing html and images with JEditorPane
megamadhu
03-24-2005, 05:21 PM
hi
i am working on printing multiple html and images(png) in a single batch.. i am able to print all in a single batch if html files are single page files but if they are multipage files i am unable to print them. i am rendering html to a JEditorPane. i can print multiple multipage html files in a single batch but unable to do html files and images in a single batch ..
anyone can help me ?
thanx in advance -if you want i can provide code
bye
madhu
sjalle
03-24-2005, 09:36 PM
This problem is connected to setting the base url for the html rendered in
the editorpane. Check that out.
megamadhu
03-25-2005, 09:57 AM
hi
thanx for replying.. but i think my problem is not with html rendering ...
i have some urls like, http://myhost.com/x/one.html . http://myhost.com/x/two.html and http://myhost.com/y/1.png ...etc. now i have to pass those urls to my program and print all in a single batch. for images i am using ImageIO to read and print , for html pages i am using JEditorPane
i am facing problems in adding pages to Book and paginating multipage html files while trying to do all in a single batch. i am able to print multiple multipage html files which contains images (<img src="....">) also ..
bye
madhu
sjalle
03-26-2005, 11:57 AM
I may still be in the blur here but if you create an html Document and that html has
the proper base url set, can't you then create a print job, add that/those documents
to the job and submit it to the printer (or was that the metod that failed ?)
.....may need more info on the scenario you work with; you are downloading html and
images linked to those pages and you want to print them locally, on the fly, right ?.
Should you not use a temp folder for the html and images and direct the printjob to
that folder
megamadhu
03-27-2005, 09:34 PM
hi
i am off these 2 days thats why no reply from me...
actually my requirement is, print some images and some html files in a single batch and there is no link between images and html files.. all images are png images and html files are maximum forms,tables... now i am using a book and create two printable classes - one for images and one for html files..
<code>
Book book = new Book();
book.append(this,pageFormat);
book.append(new htmlPrint(),pageFormat);
</code>
that append code will be in a for loop, for png images first stmt and for html files second stmt is used. two print methods for printing images and html files.......... problem i am getting is, i am unable to print html file if it has more than one page, if it has 2 pags -only 2nd page is printing.
if u want i can post my simplified code
megamadhu
03-30-2005, 03:59 PM
ok
is there any way to print html from JEditorPane without displaying it to the user ? problem is , if i use print on JEditorPane - for 4 pages html file its showing JFrame/JEditorPane almost 8 times to the user.
sjalle
04-03-2005, 01:53 PM
That's a new one...I didn't know that the pane has to be a visible part of the GUI to work for the files...
megamadhu
04-04-2005, 12:45 PM
hi
thanx for helping...
i solved both , now i have to show jeditorpane only once/page to the user and printing both images and html files in a single batch.. but still having one problem, i am using
<code>
JEditorPane.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
String property = propertyChangeEvent.getPropertyName();
if(property.equalsIgnoreCase("page")) {
// page already loaded
pageLoaded = true;
} } });
and
while(!pageLoaded) {
Thread.sleep(1000);
}
</code>
to check whether page is loaded or not (i got it from java forums) . but its not working some times mainly if html file contains images (<img src=" ">) . is there any other way to check whether page is already loaded or not ?
thanx in advance
madhu
devx.com
Copyright Internet.com Inc. All Rights Reserved