Question

I am using a primitive type of Java (1.1.2) to program an eSF application for a Lexmark printer. The problem with printing from the device is that I need to send a URL to the printing service and this makes it hard to print specifics such as string.

For my project I am trying to print the explanation of an XKCD comic. These explanations are retrieved and formatted from explainXKCD.com. Is there any way I can access just a specific part of a URL, such as the explanations portion of the webpage? That way I could just link the explanation and that will be printed instead of linking the entire webpage and it printing the entire webpage? The other method I can use to print is from a URL and it would be much easier if I could only print the explanation from some "sub" URL of the original URL.

I have looked into HTTPURLConnection and getSpecificHeader but I am not really sure what that does. I have also looked into creating a temporary URL that only contains string and linking that but I am not sure how difficult that would be or if it is even possible.

I am just looking for a nudge in the right direction if anyone has any ideas.

Was it helpful?

Solution

Your problem has nothing to do with HttpURLConnection. In any case, you have to fetch the whole page and then cut the HTML-part of the page and print it.

There are some libraries which help to parse even bad HTML, but I suppose (I'm almost sure) that they do not work with Java 1.1. Most of them will need Java 5 to work.

If you can be sure that the source won't change in the future, you could do some Regular Expressions magic and cut the interesting part of the page. But who will render the HTML to something like PostScript or PCL?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top