Forum How do I...?

Java http-proxy

I am using prince 6.0 rev 5 and using java input output streams to generate pdf. The generated pdf does not include images if my java application runs under a http-proxy. To overcome this issue I modified as below, to indicate the proxy for prince.exe. After that pdf is being generated with images, but now the css, depicted in html, is not being applied.
Do you have an idea to use http-proxy without any malfunctionality?

Application Code
is = url.openStream();
fos = new FileOutputStream( pdfFilePath );
success = prince.convert(is, fos);
public class Prince{
    //Proxy settings
    private String mHttpProxyHost;
    private String mHttpProxyPort;
    private List getCommandLine(){


Generated commandline
[C:\Program Files\Prince\Engine\bin\Prince.exe, --input=html, --baseurl=http://localhost/pdf/PMW-EX1.html, --http-proxy=someIP:8080, --server, --silent, -]
I found the reason, this malfunctionality occurs for urls with domain "localhost". For input streams opened from localhost domain, if a proxy defined, reponse returns http error 503 (Service unavailable). I think given http-proxy should be discarded for localhost and domains. This should be implemented in prince.exe.
Thanks, we'll fix this issue for the next maintenance release of Prince.
The new Prince 6.0 rev 6 release includes a fix for this issue, and it should not use the specified HTTP proxy for localhost URLs. Thanks for reporting the issue! :)
It would be nice if we could specify host that we don't want to use proxy when we specify a proxy:

example :
 prince -o out.pdf --http-proxy=proxy:8080 --non-proxy-hosts=,localhost,...

It is more flexible.

Could you please be so kind as to let me know we you can specify a password for a proxy, if you don't mind? I tried --http-proxy=ip:port:name:password but that didn't work. Thanks.
How about "--http-proxy=http://name:password@ip:port"?
Yes, that works. Thanks, Mike!