' here the program raises an error if the doc does not contain any signature
ExistingFields = loadedDocument.Form.Fields.Count
'here I don't update the String_Signature field name, so, it us "Signature_0"
signature = New PdfSignature(loadedDocument, page, pdfCert, String_Signature, SigField)
Dim TempStream As MemoryStream = New MemoryStream loadedDocument.Save(TempStream)
loadedDocument = New PdfLoadedDocument(TempStream)
String_Signature = "Signature_" & ExistingFields.ToString
signature = New PdfSignature(loadedDocument, page, pdfCert, String_Signature)
Catch ex As Exception
'here I don't update the String_Signature field name, so, it us "Signature_0"
End Try
'Other settings like displacement of visible field"
Dim y As Single = CSng(Y_Coord.Text)
signature.TimeStampServer =New TimeStampServer(New Uri("<time stamp server>"))
signature.EnableValidationAppearance = False
signature.EnableLtv = True
'So, I draw the logo and write some graphic texts - this is only a sample to see what I'm doing..."
loadedDocument.Pages(0).Graphics.DrawImage(bmp, New PointF(x, y), New SizeF(w,h))
loadedDocument.Pages(0).Graphics.DrawString("Serial: xxxxxxxxxxxxxx")
loadedDocument.Pages(0).Graphics.DrawString("TimeStamp: YES")
Well, after doing this, if I
- sign a virgin document (without any signature), NOT certifying the sign;
- save the document;
- load the saved one (signed);
- make another signature using another certificate.
... the seconds one is INVALID and I see BOTH fields with the same name "Signature_0".
So, I believe we have problems with this control!
Notice that in your sample you're signing twice the same document and using available PFX's - which in practice is not applicable. I'm talking about to receive a signed doc from anyone which I don't have PFX file (the AUTHOR but with a no certified signature) and re-sign it like a REVIEW.
Can you help on this situation?
Kindest regards,
David
I couldn't compile de source since even using the latest libraries (17.2460.0.46) the source points to:
warning MSB3277: Found conflicts between different versions of "Syncfusion.Compression.Base" that could not be resolved |
We suspect that this issue may occurs due to conflicts in App.config file. So please remove the “Syncfusion.Compression.Base” dependency assembly reference other than v17.2.0.46 in App.config file of provided sample. However we have created the sample for the same with the product version 17.2.0.46.
|
I'm curious about why a pre-existent signature is invalidated in a PDF even if we set both siganures (older and newer) to "AllowFormFills" - or in other words, we do not forbid the document to be modified. |
|
//Get values from SQL
SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation);
conn.CreateTable<Post>();
var posts = conn.Table<Post>().ToList();
conn.Close();
//Create a new PDF document
PdfDocument document = new PdfDocument();
//Add a page
PdfPage page = document.Pages.Add();
//Create the parent grid
PdfGrid parentPdfGrid = new PdfGrid();
//Add the columns to parent grid
parentPdfGrid.Columns.Add(1);
for (int i = 0; i < posts.Count; i++)
{
//Add the rows to parent grid based on the post count
PdfGridRow parentRow = parentPdfGrid.Rows.Add();
//Create the child table
PdfGrid childPdfGrid = new PdfGrid();
//Set the column and rows for child grid
childPdfGrid.Columns.Add(2);
for (int j = 0; j < 3; j++)
{
childPdfGrid.Rows.Add();
}
//create and customize the string formats
PdfStringFormat format = new PdfStringFormat();
format.Alignment = PdfTextAlignment.Center;
//Add values to cell respective to post values for row1
PdfGridRow childRow1 = childPdfGrid.Rows[0];
childRow1.Cells[0].Value = posts[i].CDateTime;
childRow1.Cells[0].ColumnSpan = 2;
childRow1.Cells[0].StringFormat = format;
//Row2
PdfGridRow childRow2 = childPdfGrid.Rows[1];
childRow2.Cells[0].Value = posts[i].rain1Lbl;
childRow2.Cells[1].Value = posts[i].rain1vol;
//Row3
PdfGridRow childRow3 = childPdfGrid.Rows[2];
childRow3.Cells[0].Value = posts[i].rain2Lbl;
childRow3.Cells[1].Value = posts[i].rain2vol;
//Assign child grid to parent grid cell
parentRow.Cells[0].Value = childPdfGrid;
}
//Draw parent grid
parentPdfGrid.Draw(page, PointF.Empty);
//Save the document to the stream
MemoryStream stream = new MemoryStream();
document.Save(stream);
//Close the document
document.Close(true); |
//Load PDF document
PdfLoadedDocument loadedDocument = newPdfLoadedDocument("SignatureDocument.pdf");
//Load PDF page
PdfPageBase page = loadedDocument.Pages[0];
PdfCertificate pdfCert = new PdfCertificate(DataPathBase+@"PDF.pfx", "syncfusion");
//Creates a digital signature
PdfSignature signature = new PdfSignature(loadedDocument, page, pdfCert, signatureName);
//Sets signature information
signature.Bounds = new RectangleF(300,300,150,50);
signature.ContactInfo = "johndoe@owned.us";
signature.LocationInfo = "Honolulu, Hawaii";
signature.Reason = "I am author of this document.";
signature.EnableValidationAppearance = true;
//Sets an image for the signature field
PdfBitmap signatureImage = new PdfBitmap(DataPathBase + @"signature.png");
signature.Appearance.Normal.Graphics.DrawImage(signatureImage, new RectangleF(0,0, 150,50));
|