Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need to convert encrypted pdf->text with the password given by the user.

IN C++

I am able to open(unencrypted) pdf by using VC++ using zlib.
I am opening pdf in 'rb' mode

Do I need to write a custom function to decrypt stream by the given password ?

[STATUS: code working for unencrypted PDF ]


IN JAVA

I have found code in java which do PDF to Text extraction by using PDFBox-0.7.3, but have some issues with the code.
There is a null pointer exception at PDFBox-0.7.3\src\org\pdfbox\ExtractText.java

 AccessPermission ap = document.getCurrentAccessPermission();  

if (!ap.canExtractContent())



http://www.apache.org/dist/pdfbox/1.5.0/pdfbox-1.5.0-src.zip[^]


[STATUS: code just creates empty file ]


Am I doing extraction of the pdf in wrong way ?
What can be the correct steps to decrypt PDF ?
Posted
Updated 24-Mar-11 3:36am
v4
Comments
Richard MacCutchan 23-Mar-11 5:05am    
So what is your problem? Have you checked the zlib documentation?
01.mandar 24-Mar-11 8:53am    
user inputs are pdf path ,password ,txt file
i need to decrypt pdf by user password
how to decrypt stream ?
will inflate() versions be useful

is above possible to do in zilb?
Richard MacCutchan 24-Mar-11 11:40am    
I think you may be looking at this from the wrong point of view. You need to find a library that can handle encrypted PDF files. I am not certain, but I do not think you can just read it as a stream and pass it through a decryption process.
HimanshuJoshi 23-Mar-11 15:46pm    
Edited to remove unnecessary bold tag.
Dalek Dave 24-Mar-11 9:37am    
Edited for Grammar and Readability.

You either:

(the fast route)
  • Use a library (free or commercial). As already suggested, Google would help you finding it


or

(the 'scenic' route)
  • Study the PDF specifications (freely available) and write your own code to do the job.
 
Share this answer
 
Comments
01.mandar 24-Mar-11 9:02am    
i have seen 2 library
zlib in c++
Pdfbox in java
coding for both mostly work on unencrypted pdf
my difficult is the pdf encryption
it just creates blank txt file when encrypted pdf is passed
Dalek Dave 24-Mar-11 9:38am    
Good Call.
It sounds like what you need is an SDK that has APIs to allow you to open and extract text from a PDF file. I'm sure you will find lots by googling 'PDF SDK'.
 
Share this answer
 
Comments
01.mandar 24-Mar-11 9:08am    
i have seen some pdf sdk but they are mostly in .NET or for trial/demo basis
i will continue looking more for c++ or java

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900