+1 800 256 3608 (toll-free in North America) or +49 7531 90 60 10| service@combit.com

Check Whether a Report Contains Certain Objects

net
(combit Team) #1
Valid from List & Label 23
You can use the following DOM code to check whether a project file contains PDF and/or graphic objects, for example:
//Check for image and PDF objects via DOM-API

// Create new ProjectList
ProjectList pf = new ProjectList(LL);
pf.Open(@"<Path>\<Reportname>.lst", LlDomFileMode.Open, LlDomAccessMode.ReadWrite, LlDomSettings.IgnoreErrors);

//Read out image objects
foreach (ObjectBase obj in pf.Objects.OfType<ObjectDrawing>())
{
    MessageBox.Show(obj.Name);
}

//Read out PDF objects
foreach (ObjectBase obj in pf.Objects.OfType<ObjectPdf>())
{
    MessageBox.Show("Filename: " + (obj as ObjectPdf).Definition.Source.FileInfo.FileName + "\nName: "+ (obj as ObjectPdf).Name);
}


OLE containers are a special feature. To check whether a project file contains one or more of these objects, it must be parsed:

//Object counter
int ObjectOleCount = 0;

string Report = @"<Path>\<Reportname>.lst";
string Line;

//Read the file and display it line by line
System.IO.StreamReader file = new System.IO.StreamReader(Report);
while ((Line = file.ReadLine()) != null)
{
       if (Line.Contains("OLE Container"))
       {
              ObjectOleCount++;
              System.Console.WriteLine("#" + ObjectOleCount + ": "+ Line);
        }
...
}
IDKBTE001360 KBTE001360