Hello PDFBOX team,
We are digital signing pdf and want to add validity symbol layer (green tick)
but it should only be visible on pdf reader and not on any browser screen.
We achieved same using itextsharp by manipulating n1,n3 and n4 layer- attached
is reference code. same we want to achieve using pdfbox and java.
Any update on this will be helpful.
Thanks and Regards,
Urmi Vijayvargiy
Disclaimer: The information contained in this message and attachment may be
CONFIDENTIAL and is for the intended addressee only. Any unauthorized use,
dissemination of the information, or copying of this message is prohibited and
may be unlawful. If you are not the intended addressee, please notify the
sender immediately and delete this message. Cygnet Infotech Private Limited or
its Subsidiary does not accept any liability for any errors, loss, delayed
delivery, tampering, corruption or presence of viruses in this message or any
attachment.
public void ClearValidityLayer(byte[] data, string dest)
{
using (PdfReader pdfReader = new PdfReader(data))
using (PdfStamper pdfStamper = new PdfStamper(pdfReader,
new FileStream(dest, FileMode.Create, FileAccess.Write), '\0',
true))
{
AcroFields fields = pdfStamper.AcroFields;
List<string> names = fields.GetSignatureNames();
foreach (string name in names)
{
PdfDictionary normal =
PdfReader.GetPdfObject(fields.GetNormalAppearance(name)) as PdfDictionary;
PdfDictionary frm =
normal?.GetAsDict(PdfName.RESOURCES)?.GetAsDict(PdfName.XOBJECT)
?.GetAsStream(PdfName.FRM);
PdfDictionary frmResources =
frm?.GetAsDict(PdfName.RESOURCES);
PdfDictionary frmXobjectResources =
frmResources?.GetAsDict(PdfName.XOBJECT);
if (frmXobjectResources != null)
{
Console.WriteLine("Found XObject resources of FRM
XObject");
clearLayer(pdfStamper.Writer, frmXobjectResources,
PdfName.N1);
clearLayer(pdfStamper.Writer, frmXobjectResources,
PdfName.N3);
clearLayer(pdfStamper.Writer, frmXobjectResources,
PdfName.N4);
pdfStamper.MarkUsed(frmXobjectResources);
pdfStamper.MarkUsed(frmResources);
pdfStamper.MarkUsed(frm);
}
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]