Bonjour,

Mon projet est le suivant :
Des PDF avec des métadonnées sont ajoutés dans une bibliothèque de document.
Chaque colonne de ma bibliothèque doit contenir les métadonnées extraits des PDF, pour cela j'utilise la Dll : iTextsharp.

J'arrive très bien à lire les métadonées des PDF en faisant des tests avec une console Csharp, voir ci-dessous le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
 
using System;
using iTextSharp.text;
using iTextSharp.text.pdf;
 
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            //Gestion des métadonnées
            string PdfFile = null;
            PdfFile = @"c:\test.pdf";
 
            PdfReader reader = new PdfReader(PdfFile);
 
            string Auteur = reader.Info["Author"];
            string DateCreation = reader.Info["CreationDate"];
            string Creer = reader.Info["Creator"];
            string MotCle = reader.Info["Keywords"];
            string ModifDate = reader.Info["ModDate"];
            string Product = reader.Info["Producer"];
            string Sujet = reader.Info["Subject"];
            string Titre = reader.Info["Title"];
 
            Console.WriteLine("Auteur : " +Auteur);
            Console.WriteLine("DateCreation : " + DateCreation);
            Console.WriteLine("Creer : " + Creer);
            Console.WriteLine("MotCle : " + MotCle);
            Console.WriteLine("ModifDate : " + ModifDate);
            Console.WriteLine("Product : " + Product);
            Console.WriteLine("Sujet : " + Sujet);
            Console.WriteLine("Titre : " + Titre);
        }
    }
}
Mais quand j'applique ce code dans un EventReceiver avec Visual Studio 2010, en mode sandbox, s'il trouve cette ligne de code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
PdfReader oReader = new PdfReader(pdfFile);
Il ne traite aucun évenement, il ne dit rien, aucune erreur et dès que je l'enlève, le code fonctionne très bien.

Ci-dessous le code du EventReceiver :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
 
using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using System.IO;
using System.Text;
using System.Collections;
using iTextSharp.text;
using iTextSharp.text.pdf;
 
namespace ImportMetaPDF.EventReceiver1
{
    public class EventReceiver1 : SPItemEventReceiver
    {
 
        public override void ItemAdded(SPItemEventProperties properties)
       {
           base.ItemAdded(properties);
 
           // Un élément a été ajouté.
           string _DestUrlPath = "http://revitest";
           string _DestFolder = string.Empty;
           SPSite oSite = null;
           SPWeb oWeb = null;
 
           oSite = new SPSite(_DestUrlPath);
           oWeb = oSite.AllWebs["votre_espace"];
 
           if (properties.ListTitle == "test")
           {
               string[] SrcPdfFile = properties.AfterUrl.Split('/');
               string pdfFile = SrcPdfFile[1];
 
               //Info Métadonnées
               PdfReader oReader = new PdfReader(pdfFile);
 
               string Auteur = oReader.Info["Author"];
               string DateCreation = oReader.Info["CreationDate"];
               string Creer = oReader.Info["Creator"];
               string MotCle = oReader.Info["Keywords"];
               string ModifDate = oReader.Info["ModDate"];
               string Product = oReader.Info["Producer"];
               string Sujet = oReader.Info["Subject"];
               string Titre = oReader.Info["Title"];
           }
       }
    }
}
Quelqu'un à une idée??