HTML to PDF / DOCX / RTF Java converter library › Forums › PD4ML v3 Archived Forums (Read Only) › HTML/CSS rendering issues › IMG tag with SRC – HTTPS:// › Re: Re: IMG tag with SRC – HTTPS://
The 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??