HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › Base URL Issue
- This topic has 6 replies, 2 voices, and was last updated Feb 10, 2010
15:11:23 by mica.cooper.
-
AuthorPosts
-
February 2, 2010 at 03:37#26325
Dear Sirs,
I am trying to render a PDF on a server other than the web server.
I need to access a resource such as g:/acme/web/ (css or images)
such that I would get the following result
file:/g:/acme/web/images/dot_000000.pngI have tried the following with the each result listed:
URL base = new URL(“file:/g:/acme/web);
image not yet in cache: file:/images/dot_000000.pngURL base = new URL(“file://g:/acme/web”);
not yet in cache: file://g:/images/dot_000000.pngURL base = new URL(“file://g://acme//web”);
not yet in cache: file://g:/images/dot_000000.pngURL base = new URL(“file:///g://acme//web”);
not yet in cache: file:/images/dot_000000.pngURL base = new URL(“file:///g:/acme/web”);
not yet in cache: file:/images/dot_000000.pngEvery time it appears that the “acme/web” is dropped from the path. Can you point me to the correct Base URL format?
Thank you,
MicaFebruary 2, 2010 at 14:09#27830URL base = new URL(“file:/g:/acme/web);
should work if the image SRC defined as “images/image.png”, not as “/images/image.png”
February 2, 2010 at 15:49#27831The css and images are stored root web folder like “/images/image.png”.
How can this be resolved?
February 4, 2010 at 15:59#27832An information regarding the mapping of the root web folder to the physical file system is known only to the web application container. So the container/server should be somehow taken into the path resolving. There are two methods:
- Request the resources via HTTP. In your case it is going to be a definition of URL base = new URL(“http://yourserver/”);
- Let PD4ML to talk to the server directly with pd4ml.useServletContext(ServletContext ctx)
February 9, 2010 at 20:30#27833For now, modifying the html with the following works to remove the leading slash
[language=java:2cbj9nop]data = data.replaceAll(“src=”/images/”, “src=”images/”);
data = data.replaceAll(“href=”/style/”, “href=”style/”);[/language:2cbj9nop]
and the following javascript in the page will set a ‘checked’ into the html[language=Java:2cbj9nop]function processFormData(oForm) {
var e, i = 0;
while (e = oForm.elements[i++]) {
if (e.type == 'checkbox') {
if (e.checked == true) {
e.defaultChecked = true;
} else {
e.defaultChecked = false;
}
}
if (e.type == 'radio') {
var x = e.name;
if (e.checked == true) {
e.defaultChecked = true;
} else {
e.defaultChecked = false;
}
}
}
}[/language:2cbj9nop]February 10, 2010 at 14:01#27834I am afraid the trick with JavaScript is not going to work. PD4ML does not support JavaScript. The source HTML should already have “CHECKED” attributes on their places.
February 10, 2010 at 15:11#27835Actually,
This code is working quite well. It is executed on the client browser prior to getting the copy of the HTML. I refactored the code and am reposting it :function processFormData(oForm) {
var e, i = 0;
while (e = oForm.elements[i++]) {
if (e.type == ‘checkbox’ || e.type == ‘radio’) {
if (e.checked == true) {
e.defaultChecked = true;
} else {
e.defaultChecked = false;
}
}
if (e.type == ‘select’) { // Still needs to be done
}
}
} -
AuthorPosts
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.