DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Jan 2005
    Posts
    10

    printing html and images with JEditorPane

    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

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    This problem is connected to setting the base url for the html rendered in
    the editorpane. Check that out.
    eschew obfuscation

  3. #3
    Join Date
    Jan 2005
    Posts
    10
    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

  4. #4
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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
    eschew obfuscation

  5. #5
    Join Date
    Jan 2005
    Posts
    10
    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

  6. #6
    Join Date
    Jan 2005
    Posts
    10
    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.

  7. #7
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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...
    eschew obfuscation

  8. #8
    Join Date
    Jan 2005
    Posts
    10
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links