Tom,
Did you get a
chance to look at the issue? Here is some more technical details with the code
dealing with signing PDF documents. Please see the code/comments for any clue of
bugs?
private bool
SignImpl(Signature signature, String signatureId)
{
if(
!(signature is PdfSignature) )
{
throw new
ArgumentException("Signature is not instance of
PdfSignature");
}
MemoryStream tempPdf =
new MemoryStream();
MemoryStream signedPdf =
new MemoryStream();
FormEditor formEditor =
new FormEditor( _pdfDocStream, tempPdf ); //Create a
FormEditor based on the
current pdf document (current PDF has 270 degree rotation by
PdfFileInfo.getPageRotation())
PdfSignature posSig =
(PdfSignature) signature;
int page =
posSig.Page;
float x =
posSig.X;
float y =
posSig.Y;
float width =
posSig.Width;
float height =
posSig.Height;
//logger.Debug("Applying
signature to PDF at: {0},{1},{2},{3},{4}", page, x, y, width,
height);
//add a button field, need
to use the lowleftx,y and upright x,y.
formEditor.AddField(FieldType.PushButton,
signatureId, page, x, y, x+width, y+height);
//Add a
button in current PDF document at the correct coordinates (x,y,width,height we
passed in are correct with units in points)
formEditor.Save(); //The button is saved correctly at the
correct coordinates with correct orientation. We can click the button on the
document.
tempPdf.Seek(0,
SeekOrigin.Begin);
// Set the signature image
on the button added above...
Form form = new
Form(tempPdf, signedPdf); //Create a form based on the temp PDF documents where we
had added a button above
form.FillImageField(signatureId,
signature.AsStream()); //Fill an
signature image on the button (the same signature image works for PDF documents
without rotations)
form.Save(); //Our expectation is that the image be
filled on the button (same size as the button and same orientation). For some
PDF documents with rotations, the image is completely not on the button and not
on the page! Even for some rare cases it is there, the image is
twisted!
signedPdf.Seek(0,
SeekOrigin.Begin);
_pdfDocStream = signedPdf;
//We expect the PDF document be
added a signature button/image at the right coordinates and
orientation.
return
true;
}
Thanks,
Frank