roffir wrote:
> Hi,
> I am trying to open a pdf document using pdfreader. The problem is that the
> url that the pdf is in requires authentication... I have tried setting the
> url as: username:"passw...@url", but this works in a browser but when
> running the code using that url I get the same: "java.io.IOException: Server
> returned HTTP response code: 401" Error...
>
> Searching around I have tried this:
>
> URL url = new URL (file_name);
> String userPassword = user + ":" + password;
> String encoding = new sun.misc.BASE64Encoder().encode
> (userPassword.getBytes());
> URLConnection uc = url.openConnection();
> uc.setRequestProperty("Authorization", "Basic " + encoding);
> PdfReader reader = new PdfReader(uc.getURL());
>
> But that just returns the same thing.
>
> Any suggestions on how to do this would be appreciated.
> Thank you.
In this case, you should use Java functionality to get
the bytes of the PDF file. Once you have this byte[],
use it to create an instance of PdfReader.
--
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.itextpdf.com/book/
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/