0

Escribo en esta oportunidad porque estoy trabajando con C# y necesito obtener las propiedades de un pdf, estas se anexan antes de escanearlo, que Liberia se puede utilizar? o cual sería la mejor manera de obtener esa información? introducir la descripción de la imagen aquí

También me gustaría saber si se puede visualizar un listado de pdf que se encuentra en una carpeta, en forma tipo lista o en miniatura?

1 respuesta 1

0

La información que muestras en la imagen se conoce como metadatos, si estas usando .NET Framework puedes agregar una referencia a

Shell32.dll

Asi:

  1. Click derecho en el proyecto
  2. Agregar referencia
  3. Click en la pestaña COM
  4. Seleccionas Microsoft Shell Controls and Automation
  5. Click OK

Y hacer algo como esto:

List<string> arrHeaders = new List<string>();
List<Tuple<int, string, string>> attributes = new List<Tuple<int, string, string>>();

Shell32.Shell shell = new Shell32.Shell();
var strFileName = @"C:\Users\Admin\Google Drive\image.jpg";
Shell32.Folder objFolder = shell.NameSpace(System.IO.Path.GetDirectoryName(strFileName));
Shell32.FolderItem folderItem = objFolder.ParseName(System.IO.Path.GetFileName(strFileName));


    for (int i = 0; i < short.MaxValue; i++)
    {
        string header = objFolder.GetDetailsOf(null, i);
        if (String.IsNullOrEmpty(header))
            break;
        arrHeaders.Add(header);
    }

    // The attributes list below will contain a tuple with attribute index, name and value
    // Once you know the index of the attribute you want to get, 
    // you can get it directly without looping, like this:
    var Authors = objFolder.GetDetailsOf(folderItem, 20);

    for (int i = 0; i < arrHeaders.Count; i++)
    {
        var attrName = arrHeaders[i];
        var attrValue = objFolder.GetDetailsOf(folderItem, i);
        var attrIdx = i;

        attributes.Add(new Tuple<int, string, string>(attrIdx, attrName, attrValue));

        Debug.WriteLine("{0}\t{1}: {2}", i, attrName, attrValue);
    }
1
  • Gracias por responderme, siii eso es lo quiero hacer leer los metadatos de un pdf, voy revisar el codigo para probarlo, es la primera vez que trabajo con C# y no se mucho pero quisiera aprender
    – Teresa
    el 15 jul. 2018 a las 6:12

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.