HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › IMG tag with SRC – HTTPS://
- This topic has 11 replies, 3 voices, and was last updated Oct 28, 2009
12:30:04 by Anonymous.
-
AuthorPosts
-
October 20, 2009 at 10:19#26279
Hi,
I am having a problem with using a URL that is of type https. If I change the src to a none secure website URL it works fine.
The html generated renders fine in the browser but when pd4ml library generates the pdf the images are not rendered …This is quite important to us and may lead to the purchase of an unlimited licence as we will need this library on several servers but 9/10 servers have an SSL cert …
Any help would be great.
Thanks,
Nick
Snip of HTML:
[language=xml:1xlgopq4]
[/language:1xlgopq4]
October 20, 2009 at 10:39#27583“Officially” PD4ML does not support SSL, however it tries to load SSL resources with the standard SSL interfaces of JDK.
Often it works well, but there are some application servers (Weblogic, WebSphere,…), which implement proprietary SSL classes, not derived from the standard ones. If PD4ML is deployed to a such server it fails to load external HTTPS resources (internally it throws ClassCastException).
It it is your case, as a workaround we would recommend to develop a custom SSL resource loader, which consumes the proprietary SSL classes.
Some info about PD4ML custom resource loaders:
pd4ml-html-css-pdf-tips-tricks-f7/a-definition-of-custom-resource-loaders-t40.htmlPlease contact PD4ML support by email if you need further assistance with the loaders.
October 20, 2009 at 11:19#27584I am using Lotus Domino so this may be the case.
I have created the above class file and included it as i have with the pd4ml library and it all compiles fine. The following is how i added the resource provider:
[language=java:1trbjb29]PD4ML pd4ml = new PD4ML();
pd4ml.setPageInsets(new Insets(20, 10, 10, 10));
pd4ml.setHtmlWidth(1000);
pd4ml.setPageSize(format);HashMap map = new HashMap();
map.put( “pd4ml.extra.resource.loaders”, “CustomFileResourceProvider” );
pd4ml.setDynamicParams(map);[/language:1trbjb29]
How ever this does not seem to have made any different/affect? I put a System.out.println statement in the Custom Resource Provider to see if it is used and my output never appears ….Can you provide me with anymore help??
Thanks,
Nick
October 20, 2009 at 12:31#27585I guess you use pd4ml_demo.jar pre-installed in the demo lotus notes database.
The custom resource loaders support feature is relatively new, so I would recommend you to download the most recent version v351b17 from PD4ML download area and install it instead of the default one.
October 20, 2009 at 12:43#27586Ah ok ill try that now.
The library is not within the database but added to the common librarys used by domino so the library can exist only the once and be available to everyone on that server. How ever, if it was in the local database or not the code wouldn’t compile if the library was not available …
We are currently testing the use of pd4ml on a live secure server before we can go ahead with it’s use and purchase an unlimited license …
Changing the library will means i will need to restart the domino service before it will recognise the new library so i will not be able to give feedback until tomorrow.
The version i am currently using is pd4ml.lib.trial.351b7
October 21, 2009 at 08:57#27587OK I have put in place the newest version of the trial library and i still have the problem of images not rendering on a SSL server.
Here is the code that performs the pdf creation:
[language=java:1rum0qmq]public static final void generatePDF(String inputHTML, OutputStream fos,
Dimension format, String fontsDir, String footerBody)
throws Exception {// the method uses only basic PD4ML API calls
// more info:
// Reference: http://pd4ml.com/reference.htm
// Javadoc: http://pd4ml.com/api/index.htmlPD4ML pd4ml = new PD4ML();
pd4ml.setPageInsets(new Insets(20, 10, 10, 10));
pd4ml.setHtmlWidth(1000);
pd4ml.setPageSize(format);HashMap map = new HashMap();
map.put( “pd4ml.extra.resource.loaders”, “CustomFileResourceProvider” );
pd4ml.setDynamicParams(map);if (fontsDir != null && fontsDir.length() > 0) {
pd4ml.useTTF(fontsDir, true);
}if (footerBody != null && footerBody.length() > 0) {
PD4PageMark footer = new PD4PageMark();
footer.setAreaHeight(-1);
footer.setHtmlTemplate(footerBody);
pd4ml.setPageFooter(footer);
}// pd4ml.enableDebugInfo(); // in Lotus environment the debug info appears under
// File->Tools->Show Java Debug Console
pd4ml.render(new StringReader(inputHTML), fos, new URL(“file:.”), “utf-8”);
fos.flush();
fos.close();
}[/language:1rum0qmq]This code compiles and executes and still creates a PDF but again with no images. If i copy the HTML that was used to a text file and save it as .html it renders fine in a browser so the HTML is fine …
Can you provide me with anymore help at all???
October 21, 2009 at 10:14#27588The Java code seems to be correct. Now it would be helpful if you post code of your version of CustomFileResourceProvider.
Of course if you use the original CustomFileResourceProvider sample, it cannot load SSL resources. You need to add SSL connection/loading code there.
First I would recommend to add
[language=java:x3knzdo9]System.out.println( “resource request: ” + resource );[/language:x3knzdo9]
to the class and inspect the server’s log to make sure the loader is called.October 21, 2009 at 10:34#27589By the way: as I see, the images are located on “www.reachsuite.com”. Very often servers have different external (Internet) and internal (intranet) names. “www.reachsuite.com” looks like an external name.
It is not always true, that the servers within intranet are able to resolve the external names or to establish a connection using the external name.
Just to make sure that it is not your case, try to temporarily substitute “www.reachsuite.com” in the image URL with its local IP address.
Also pd4ml.enableDebugInfo(); forces PD4ML to dump connection statistics to STDOUT (or server’s log), which could be also useful to analyze the problem.
October 26, 2009 at 14:17#27590The code for CustomFileResourceProvider is as (creating CustomFileResourceProvider):
[language=java:bxc7ifsk]import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;import org.zefer.cache.ResourceProvider;
public class CustomFileResourceProvider extends ResourceProvider {
public byte[] getResourceAsBytes(String resource, boolean debugOn) throws IOException {
ByteArrayOutputStream fos = new ByteArrayOutputStream();
byte buffer[] = new byte[2048];InputStream is = null;
//resource = “http://pd4ml.com/i/” + resource;
URL src = new URL(resource);
URLConnection urlConnect = src.openConnection();
try {
urlConnect.connect();
} catch (Throwable e) {
return new byte[0];
}
is = urlConnect.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);int read;
do {
read = is.read(buffer, 0, buffer.length);
if (read > 0) { // something to put down
fos.write(buffer, 0, read);
}
} while (read > -1);fos.close();
bis.close();
is.close();return fos.toByteArray();
}
}[/language:bxc7ifsk]
I’ll try output diagnostic information next but i think i tried before to output the resource location to see if this appear in the system log and nothing appear which suggested the CustomFileResourceProvider never got used/called.What code do i need to add to the above to get it to work with HTTPS locations?
I also have access to our servers so if they do not resolve the website URL then I will add them to the hosts file so it should. Am i correct in thinking that would solve any resolving issue pd4ml may have??
October 26, 2009 at 15:06#27591Hi,
After turning on the debug information i got the following:
[language=xml:1benp1rv]AMgr: Start executing agent 'CreateContractPDFs' in 'EAA090114ccoweb.nsf'
Agent Manager: Agent printing: testing CustomFileResourceProvider.test: test works
Agent Manager: Agent printing: version: PD4ML 351b17 (eval)
Agent Manager: Agent printing: image not yet in cache: https://www.reachsuite.com/EAA090114/cxpweb.nsf/PublicDocs/NCOY-7UKH4E/$File/CompanyLogo.gif
Agent Manager: Agent printing: not yet in cache: https://www.reachsuite.com/EAA090114/cxpweb.nsf/PublicDocs/NCOY-7UKH4E/$File/CompanyLogo.gif
Agent Manager: Agent printing: External resource loader: CustomFileResourceProvider not found. Make sure “pd4ml.extra.resource.loaders” value is correct
Agent Manager: Agent printing: External resource loader: CustomFileResourceProvider not found. Make sure “pd4ml.extra.resource.loaders” value is correct
Agent Manager: Agent printing: resource https://www.reachsuite.com/EAA090114/cxpweb.nsf/PublicDocs/NCOY-7UKH4E/$File/CompanyLogo.gif not found.
Agent Manager: Agent printing: image https://www.reachsuite.com/EAA090114/cxpweb.nsf/PublicDocs/NCOY-7UKH4E/$File/CompanyLogo.gif not found.
Agent Manager: Agent printing: can not load image: https://www.reachsuite.com/EAA090114/cxpweb.nsf/PublicDocs/NCOY-7UKH4E/$File/CompanyLogo.gif
Agent Manager: Agent printing: done in 343ms.
AMgr: Agent 'CreateContractPDFs' in 'EAA090114ccoweb.nsf' completed execution[/language:1benp1rv]I also added a function test() to CustomFileResourceProvider to return a dummy string and did the following:[language=java:1benp1rv]PD4ML pd4ml = new PD4ML();
pd4ml.setPageInsets(new Insets(20, 10, 10, 10));
pd4ml.setHtmlWidth(1000);
pd4ml.setPageSize(format);
HashMap map = new HashMap();
map.put( “pd4ml.extra.resource.loaders”, “CustomFileResourceProvider” );
pd4ml.setDynamicParams(map);
ustomFileResourceProvider obTest = new CustomFileResourceProvider();
System.out.println(“testing CustomFileResourceProvider.test: ” + obTest.test());[/language:1benp1rv]
The Agent Manager output above shows the CustomFileResourceProvider is available as a class and working. How ever i don’t think this class is available in the java generally available classes.
I am going to test changing the IP from a web URL to xx.xx.xx.xx but the ResourceProvider as a class doesn’t seem to behave correctly …Again anymore help would be great so we can then purchase the unlimited licence.
October 26, 2009 at 15:26#27593replacing http://www.reachsuite.com with the servers internal IP address had no effect also …
i think it is to do with the fact the CustomFileResourceProvider java script class/library exists in the notesdatabase and not as an external library like pd4ml so when i specify this class as an extra resource provider is is unable to find it …
I might try and create/compile this seperate class using a java IDE and compile it that way and put the .java file along side pd4ml library and include it like you would …Do you have a working basic example of a notes database with this implemented??
October 28, 2009 at 12:30#27592Sorry for the delay with the reply.
> External resource loader: CustomFileResourceProvider not found. Make sure “pd4ml.extra.resource.loaders” value is correct
Obviously the classloader cannot find CustomFileResourceProvider class (which is expected to be in the classpath)
Well, your idea to add the class to the pd4ml_demo.jar is not that bad. But before you re-packed the JAR and deployed it to the Domino environment, try to debug CustomFileResourceProvider offline. You may run PD4ML in GUI mode:
java -Xmx512m -cp .;pd4ml_demo.jar;ss_css2.jar -Dpd4ml.extra.resource.loaders=CustomFileResourceProvider org.zefer.pd4ml.tools.PD4Browser
(The application will auto-create pd4browser.properties. In the file you may set debug.info.enable=true to allow the debug output)
You would also need to add to the classpath the specific domino SSL lib(s)
-
AuthorPosts
The forum ‘HTML/CSS rendering issues’ is closed to new topics and replies.