please provide instructions on how to create a PdfSignature
omerbrandis opened this issue · comments
Hi,
I'm trying to create a new pdf and sign it.
I'm using the latest version of Podofo, downloaded today on 17.3.2024.
I have manged to follow the "hello world" documentation to create a new doc.
I am trying to follow examples provided in tests , as instructed in issue 143,
but in those examples, it is assumed that the document already has an annotation for signatures, which mine does not have,
thus its no surprise that annot = FirstPage.GetAnnotations().GetAnnotAt(0); fails with PdfErrorCode::ValueOutOfRange.
( i do not load the generated document from disk, I continue using the variable after FinishDrawing,GetMetadata().Set,Save)
I have tried to create one using :
PoDoFo::Rect AnnoRect(0,0,100,50);
PoDoFo::PdfAnnotation & annot = FirstPage.GetAnnotations().CreateAnnot(PoDoFo::PdfAnnotationType::Widget,AnnoRect);
PoDoFo::PdfField & field = dynamic_castPoDoFo::PdfAnnotationWidget&(annot).GetField();
PoDoFo::PdfSignature & signature = dynamic_castPoDoFo::PdfSignature&(field);
but the last statement, fails with std::bad_cast.
:-)
used the info in the FAQ,
auto& page = doc.GetPages().GetPageAt(0);
auto& signature = page.CreateField("Signature", Rect());
:-)
...