Extraer adjuntos de archivo .PDF
Publicado por CELSO OMAR (6 intervenciones) el 16/05/2023 16:31:41
Hola muy buenos dias a todos, mi consulta es la siguiente, necesito extraer el o los adjuntos q viene en un PDF, he probado varios metodos pero sin resultados favorables, si alguien conoce algun mettodo que les ete funcionando agradeceria infinitamente la colaboracion o sujerencia.
desde ya muchas gracias.-
Les dejo unas lineas que estoy utilizando aculamente pero no esta funcionando.
PdfLoadedDocument loadedDocumenta = new PdfLoadedDocument("c:\\Temp\\Archivo.PDF");
PdfLoadedPage page = loadedDocumenta.Pages[0] as PdfLoadedPage;
//Get the annotation collection from pages
PdfLoadedAnnotationCollection annotations = page.Annotations;
foreach (PdfLoadedAnnotation annot in annotations)
{
if (annot is PdfLoadedAttachmentAnnotation)
{
PdfLoadedAttachmentAnnotation file = annot as PdfLoadedAttachmentAnnotation;
FileStream stream = new FileStream(file.FileName, FileMode.Create);
stream.Write(file.Data, 0, file.Data.Length);
stream.Dispose();
}
}
if (loadedDocumenta.Attachments.Count != 0)
{
foreach (PdfAttachment attachment in loadedDocumenta.Attachments)
{
FileStream stream = new FileStream(attachment.FileName, FileMode.Create);
stream.Write(attachment.Data, 0, attachment.Data.Length);
stream.Dispose();
}
}
loadedDocumenta.Close(true);
desde ya muchas gracias.-
Les dejo unas lineas que estoy utilizando aculamente pero no esta funcionando.
PdfLoadedDocument loadedDocumenta = new PdfLoadedDocument("c:\\Temp\\Archivo.PDF");
PdfLoadedPage page = loadedDocumenta.Pages[0] as PdfLoadedPage;
//Get the annotation collection from pages
PdfLoadedAnnotationCollection annotations = page.Annotations;
foreach (PdfLoadedAnnotation annot in annotations)
{
if (annot is PdfLoadedAttachmentAnnotation)
{
PdfLoadedAttachmentAnnotation file = annot as PdfLoadedAttachmentAnnotation;
FileStream stream = new FileStream(file.FileName, FileMode.Create);
stream.Write(file.Data, 0, file.Data.Length);
stream.Dispose();
}
}
if (loadedDocumenta.Attachments.Count != 0)
{
foreach (PdfAttachment attachment in loadedDocumenta.Attachments)
{
FileStream stream = new FileStream(attachment.FileName, FileMode.Create);
stream.Write(attachment.Data, 0, attachment.Data.Length);
stream.Dispose();
}
}
loadedDocumenta.Close(true);
Valora esta pregunta


0