I found this document
http://itextpdf.com/book/digitalsignatures20120823.pdf

There is a chapter :

2.2.4 Signing large PDF files

"When you use the createSignature() method as shown in code sample 10,
iText will create a copy of the document you’re about to sign in memory,
leaving the bytes that are reserved for the signature blank. iText needs
this copy so that it can provide the bytes that need to be hashed and
signed. This can be problematic for files with a large file size: you risk
OutOfMemoryExceptions.
Take a look at code sample 13 if you want to store the copy on disk instead
of keeping it in memory:
Code sample 13: Signing a document using a temporary file
public void sign(String src, String tmp, String dest,
Certificate[] chain, PrivateKey pk, String digestAlgorithm,
String provider, CryptoStandard subfilter, String reason, String location)
throws GeneralSecurityException, IOException, DocumentException {
// Creating the reader and the stamper
PdfReader reader = new PdfReader(src);
FileOutputStream os = new FileOutputStream(dest);
PdfStamper stamper =
PdfStamper.createSignature(reader, os, '\0', new File(tmp));
// Creating the appearance
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setReason(reason);
appearance.setLocation(location);
appearance.setVisibleSignature(new Rectangle(36, 748, 144, 780), 1, "sig");
// Creating the signature
ExternalSignature pks = new PrivateKeySignature(pk, digestAlgorithm,
provider);
ExternalDigest digest = new BouncyCastleDigest();
MakeSignature.signDetached(appearance, digest, pks, chain,
null, null, null, 0, subfilter);
}"

This looks like a possible solution :) but i would like to have it
confirmed by someone who used it .

Of course I try myself.



On Wed, Jan 23, 2013 at 11:11 AM, Andreas Kuehne <[email protected]>wrote:

>  Hi Cristian,
>
> the problem is not the signing itself but the modification of the PDF
> (insert the signature element). Afaik iText does this in memory, but I
> would love to learn that I'm wrong.
> The hashing and signing can be in two additional steps.
>
> Greetings,
>
> Andreas
>
> Hi
>
> I use Itext to sign some PDF's on server side.
>
> Because is a webapp and we might have in the future more users, I wonder if
> there is a possibility to sign the PDFs via a streaming method.
>
>
> So the user upload the document, the IText engine somehow gets access to
> the inputstream , SIGN , and then put into the outstream back to the client.
>
> SIGN is possible without having the document in the memory ?
>
> In the book Itext in Action second editon ther is nothing regarding signing
> via a streaming way (BTW i use it via safari books online so i can't ask
> this question on the book forum. Unfortunately despite is a legal way to
> read the book because i pay subscription to Safari , i do not have the
> codes to register to the book forum)
>
> Now things are done not optimally via WS and the whole byte[] is in the
> memory.
>
> On a small load test we get OOME.
>
> Any ideas how it can be done ?
>
> Thanks
>
> Cristian Chiovari.
>
>
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more 
> at:http://p.sf.net/sfu/learnnow-d2d
>
>
>
> _______________________________________________
> iText-questions mailing 
> [email protected]https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a 
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples: 
> http://itextpdf.com/themes/keywords.php
>
>
>
> --
> Andreas Kühne
> phone: +49 177 293 24 97
> mailto: [email protected]
>
> Trustable Ltd. Niederlassung Deutschland Ströverstr. 18 - 59427 Unna 
> Amtsgericht Hamm HRB 5868
>
> Directors Andreas Kühne, Heiko Veit
>
> Company UK Company No: 5218868 Registered in England and Wales
>
>
>
> ------------------------------------------------------------------------------
> Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
> MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
> with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
> MVPs and experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
>
> iText(R) is a registered trademark of 1T3XT BVBA.
> Many questions posted to this list can (and will) be answered with a
> reference to the iText book: http://www.itextpdf.com/book/
> Please check the keywords list before you ask for examples:
> http://itextpdf.com/themes/keywords.php
>
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to