below is my program.But currently it downloads the file and after that it encrypt.So there is a original copy which is not encrypted.I need to encrypt the original one.How to do this?
I used iText library for encryption.
sam liya wrote:currently its download and then encrypt.so there is a copy which is not encrypted.
Well if you're doing the encryption in your client, then of course that's going to be the case.
If you want the file encrypted before you download it, then the encryption needs to be done on the server.
Are you able to change the server side application ?
but my question is when i used iText how to write data to pdf using BufferedOutputStream.
Not following - you're asking precisely what the code you posted does, which is "how to write data to pdf using BufferedOutputStream". So the glib answer would be "look at the code you posted", but obviously I'm missing something. Don't assume that code you post explains anything about what you're trying to understand. Words -and even better: elaborate words- do a better job at that.
But its better if we can write using BufferedOutputStream than document.add method.
Just out of curiosity, I'll ask: why? I say out of curiosity, because the answer doesn't matter much - you will use both. See http://www.coderanch.com/how-to/java/ItextExample for how to store a PDF using iText via an OutputStream. That example uses a FileOutputStream, but you can just as easily use any other OutputStream, because that's the parameter PdfWriter.getInstance takes.
SO my question is how to use this with iText?
I'd be curious about the use case behind this. It doesn't seem to me that handling multiple downloaded files, much less encrypted one, would be something people want to do on their mobile devices.
sam liya wrote: Actually my problem is there are several urls which contain pdf. I need to write a app which download the those pdfs and encrypt them.I used iText for encryption.So currently i download the pdf first and then encrypt it using iText.So i already have original one without encrypting.So it must be to delete.this is the my current approach.can you tell me how to improve this approach?
I'm having trouble understanding why you need to encrypt the downloaded files. To me it only makes any sense at all if the URLs use HTTPS (to protect the file content during transit) and then only if used with client authentication (to restrict who can download the files). I don't see anything in your code to indicate you are using HTTPS with client authentication.
sam liya wrote:Imagin if i get the one copy of pdf,then i can send it to so many of them.If we use encryption other unable to view them.
Only if they can't get the ID of the device that downloaded the PDF. That ID will have to be kept very very secret because once revealed it will allow access by anyone to ALL documents encrypted with it. How secret is the ID?
i found below example,but most of the codes used are deprecated now.
can anyone give me example please?