• Post Reply Bookmark Topic Watch Topic
  • New Topic

secure pdf view  RSS feed

 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need pdf viewer with encription.If there is a free one better.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Start by telling us in which ways Acrobat Reader does not meet your requirements.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ULF.Actually i need a library which can use to encrypt the PDF file.I need this library to add for my app.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://pdfbox.apache.org/ can encrypt and decryt PDFs. https://github.com/yarick123/pdf-renderer/ has a viewer component to display them.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ULF. Does pdfbox. provide encription?
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That question is readily answered by the internet. When I used pdfbox encryption for my search keywords, the first link returned was this one, which clearly contains an answer to that question.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to encript pdf when users tyr to downloading using Device id.can we do encryption for downloading pdf?
below shows how to create new pdf and encript it using iText library.


 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a simple program to download and encrypt pdf file.PDF file is in the url.
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.

 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm confused as what's supposed to happen where. Is it: PDF is generated on the server -> PDF is encrypted -> PDF is downloaded to the device? If yes, what problem are you facing in encrypting the PDF before download? If not, what exactly is the sequence of actions?
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually i need to download a pdf with encryption. currently its download and then encrypt.so there is a copy which is not encrypted.Its not safe.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a way to create a pdf with encryption using iText library as below.



but my question is when i used iText how to write data to pdf using BufferedOutputStream.Because i used to below code for writing data to pdf.


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ULF,

actually i need to know how to use iText library to write using BufferedOutputStream.
I know we can write using document.add(new Paragraph("Hello World, iText"));. But its better if we can write using BufferedOutputStream than document.add method.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THe reason why i like to use BufferedOutputStream is we don't need to consider each part separately when we use BufferedOutputStream .If we use iText normal way we have to add font,Header,.... separately. but if we use BufferedOutputStream we don't need to consider those parts separately.Actually i am getting pdf from url.It contains several pages.If i use normal iText approach it is difficult to write all those pages .So its easy to use BufferedOutputStream as below in normal way.



SO my question is how to use this with iText?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The point of IText and other such libraries is that you don't have to think about what goes into the binary file - that's why those APIs exist: so you can use higher-level abstractions like documents and paragraphs. If you want to write bytes to an OutputStream directly you wouldn't need iText at all; better to drop that idea right now. PDF is not a simple file format that you can (easily, at least) or want to create directly.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Ulf,
I downloaded and create PDF through url from below code.It creates pdf file successfully.So for downloading and creating pdf we can use below code.I used iText for encription part only.


 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code does not create a PDF at all - it seems to download an existing one. You said you wanted to create one, and for that you will end up using a library like iText or PDFBox.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks ULF. 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?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mobile app downloads them? Then they'll be on the device unencrypted, which is what you said you didn't want. The alternative is to write a web app that downloads the PDFs, encrypts them, and then streams them to the device, either singly or as an archive.

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.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no.i need to make a app which downloaded files are unable to copy to other devices.So if we encrypted using device id non of the other devices able to open those pdf.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam liya wrote:no.i need to make a app which downloaded files are unable to copy to other devices.So if we encrypted using device id non of the other devices able to open those pdf.


So why can't the 'other device' go straight to the original source URL?
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These are paid ones.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam liya wrote:These are paid ones.


So authentication is being used. Why do you have to use PDF encryption? Why can't you use a general file/stream encryption approach? What stops the the 'other devices' getting hold of the ID used as the encryption key?
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually id is a part of the code.we add some other details to it.
 
sam liya
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
by the way i checked examples for pdfbox, i am unable to found good one.Documentation also don't have encryption part https://pdfbox.apache.org/cookbook/documentcreation.html

i found below example,but most of the codes used are deprecated now.

http://www.docjar.com/html/api/org/apache/pdfbox/encryption/DocumentEncryption.java.html

can anyone give me example please?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PDFBox has a built-in encryption tool (which is documented on its web site). If you look at its source code you should be able to figure out how to use the relevant classes programmatically. If you can't, tell us what specific steps you have taken in trying to figure it out.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!