Printing a HTML Document

O

Oitne.Inside

Hi there,

We have a little problem. We just started coding in Java and now we
need to load a html document from a webserver and print it out. We
figgured out this can be done using HTML component, but when we
execute this code, the pages stay blank. My guess is that we aren't
loading the page inside the HTML Component. Anyone got an idea???

Our code:

HTMLDocument x = new HTMLDocument();
URL u;
InputStream is = null;
DataInputStream dis;
u = new URL("http://www.mysite.com/htmlfile.php");
x.setBase(u);
dr.print(x);
 
R

rossum

Hi there,

We have a little problem. We just started coding in Java and now we
need to load a html document from a webserver and print it out. We
figgured out this can be done using HTML component, but when we
execute this code, the pages stay blank. My guess is that we aren't
loading the page inside the HTML Component. Anyone got an idea???

Our code:

HTMLDocument x = new HTMLDocument();
URL u;
InputStream is = null;
DataInputStream dis;
u = new URL("http://www.mysite.com/htmlfile.php");
x.setBase(u);
dr.print(x);

Can you print a very simple HTML document?

<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>

from the local hard disc?

HTMLDocument x = new HTMLDocument();
URL u;
InputStream is = null;
DataInputStream dis;
u = new URL("file://localhost/C:/temp/helloworld.html");
x.setBase(u);
dr.print(x);

Once you get that working then add complications to the source of the
HTML file and to the HTML file itself.

rossum
 
M

Michael Jung

We have a little problem. We just started coding in Java and now we
need to load a html document from a webserver and print it out. We
figgured out this can be done using HTML component, but when we
execute this code, the pages stay blank. My guess is that we aren't
loading the page inside the HTML Component. Anyone got an idea???
HTMLDocument x = new HTMLDocument();
URL u;
InputStream is = null;
DataInputStream dis;
u = new URL("http://www.mysite.com/htmlfile.php");
x.setBase(u);
dr.print(x);

What are "is" and "dis" good for? What's a"dr"? In general
HTMLDocument don't render by themselves. You have to lay them out
somewhere. Remember HTML can be rendered in narrow or wide screens.

Michael
 
O

Oitne.Inside

What are "is" and "dis" good for? What's a"dr"? In general
HTMLDocument don't render by themselves. You have to lay them out
somewhere. RememberHTMLcan be rendered in narrow or wide screens.


So we have to render the code before sending it to the printer. Can
you tell us how we render it?
 
L

Lew

So we have to render the code before sending it to the printer. Can
you tell us how we render it?

Now, to be fair, you should really answer Michael's questions, then ask your own.
 
A

Andrew Thompson

Lew said:
Now, to be fair, ..

Fair? I hate that word. To me it means 'light coloring'.

I would say OTOH, that is is both sensible and constructive
to answer the questions of people trying to help.
..you should really answer Michael's questions, then ask your own.

One good way to answer most of those questions,
would be to prepare an SSCCE* of the current code.

* <http://www.physci.org/codes/sscce.html>

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
O

Oitne.Inside

Andrew, could you ask your question more specific? Then I will be able
to answer it, and maybe you could help us out here.
 
O

Oitne.Inside

Got it fixed :

import java.net.*;
import java.io.*;
import javax.swing.*;
public class FileDownload {
public static void main(String[] args){
JEditorPane output = new JEditorPane();
output.setContentType( "text/html" );
output.setEditable( false );
try{
output.setPage("mysite.com/file.php");
output.print();
}catch(Exception e){System.err.print(e);}

}
}
 
A

Andrew Thompson

Andrew, could you ask your question more specific?

I felt Michael's questions were fairly specific, but ultimatety,
"code* answers a thousand questions".

* Specifically, code that is an SSCCE.
...Then I will be able
to answer it, and maybe you could help us out here.

What did you *not* understand about Michael's questions?

Note there is only so much 'guesswork' that people are prepared
to do on your behalf - the rest needs to be filled in
(stated/written/explained), specifically, by you.

Have you *read* the SSCCE document yet? If there was anything
in it that was incomprehensible (gobble-de-gook, nonsense, ..) I
would like to be told that (since I created the document, and it is
intended to help programmers).

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 
L

Lew

Andrew said:
Fair? I hate that word. To me it means 'light coloring'.

That's like saying you don't use the word "good" as a moral judgment because
it (also!) means "an item of commerce".

Anyway, "fair" means "between the baselines", thus allowing the runner to
attempt to reach first and be safe, while the fielders attempt to throw him out.

If you want to test a ferris wheel, give it a fair trial.

<http://en.wiktionary.org/wiki/fair>
 
L

Lew

Andrew said:
Lew wrote:
...

Yeah, yeah.. just allowing some of my 'petty (word)
prejudices' show through. ;-)

( I prefer the roller-coaster, ..or dodgem' cars, BTW ;)

You can try those at the fair, too. (In the U.S., the latter ride is called
"bumper cars". It looks like one term focuses on the defense, the other on
the offense.)
 
A

Andrew Thompson

Lew said:
[quoted text clipped - 3 lines]
( I prefer the roller-coaster, ..or dodgem' cars, BTW ;)

You can try those at the fair, too. (In the U.S., the latter ride is called
"bumper cars". It looks like one term focuses on the defense, the other on
the offense.)

Well actually ..now you mention it (wicked grin) my strategy
was never the 'dodge' so much as the 'strategic bump'. ;-)

--
Andrew Thompson
http://www.physci.org/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top