0
I’m developing a certified digital signature system A1 and A3 (token) for pdfs along with iTextsharp (v5.5.13.1, via NuGet Package Manager). I use the c# and I came across the following error in creating an object PdfReader:
$Exception {"Cannot convert an object of type 'iTextSharp.text.pdf.Pdfarray' to type 'iTextSharp.text.pdf.Pdfdictionary'." } System.Invalidcastexception
The file in question is a pdf digitized, with the other forms, nothing occurs, works normally.
I do the reading of all pdfs from a directory as below, and proceed with a foreach in the array:
pgbAssinaturas.Maximum = aArquivos.Length;
string[] aArquivos = Directory.GetFiles(txbPathPdfs2.Text, "*.pdf");
foreach (string sArquivo in aArquivos) {
// atualiza progressbar
iContadorProgressBar++;
pgbAssinaturas.Value = iContadorProgressBar;
pgbAssinaturas.Refresh();
// abre arquivo original
PdfReader pdfReader = new PdfReader(sArquivo); // <-- linha do erro
// prepara um nome final
sNomeArquivoFinal = "Assinados\\sign_" + Path.GetFileName(sArquivo);
sNomeArquivoFinal = txbPathPdfs2.Text + "\\" + sNomeArquivoFinal;
// [...]
}
Does anyone know what might be going on with this PDF?
IDE: visual studio community 2019, .Net Framework 4.8.03752
in which code snippet the error occurs?
– Jefferson Mello Olynyki
PdfReader pdfReader = new PdfReader(sArquivo);. I edited the post.– Luiz Roberto Furtuna