Zhen (Tim) Wang wrote:
> 1) I have problem in open a PDF file which have set a password for
> opening with PoDoFo lib. Follows is my code:
>
> PdfVecObjects objects;
> PdfParser parser( &objects );
> objects.SetAutoDelete( true );
> try{
> parser.ParseFile(pszFilename);
> }catch( PdfError & e ) {
> cout<<e.GetError()<<endl;
> }
> parser.SetPassword("123");
> PdfWriter writer(&parser);
> writer.Write("test_en.pdf");
>
> I'am sure the password is "123"
Does it work when you unlock the PDF with Acrobat Professional?
Does Acrobat report that the file is also encrypted?
Can you post the PDF, or a suitable test file, somewhere?
> 2) I get the mean from manual that the PoDoFo and change the content of
> exist file, but when I code like follows, the file will be destroy.
>
> PdfMemDocument *document = new PdfMemDocument(pszFilename);
> document->GetInfo()->SetAuthor("nextlabs");
> document->Write(pszFilename);
PdfMemDocument uses delayed loading of objects to save memory. Thus, the
call to Write needs to read from the original file. The first thing you
do when writing to the file is truncate it, making it unreadable.
You need to write to a temporary file then rename the temporary to
replace the original once writing succeeds.
PoDoFo can open and edit an existing PDF file, but when you save your
changes you must still do so to a new file.
Later on PoDoFo might support appending changes to an existing PDF file
but it does not currently.
--
Craig Ringer
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users