I have the below method that was supposed to return the number of layers in a PDF but it doesn't appear to work. When I pass the path to a PDF file containing two layers, the layer count property has a value of 1. I confirmed with two different PDF readers that there are two layers in the PDF. My only thought is ABCPDF is flattening the PDF layers during the read. If so, how can I prevent that so an accurate count of the number of layers in the PDF is returned?
Thank you
public static int GetPDFLayerCount(string pdfFile)
{
int layerCount = 0;
Doc doc = new Doc();
doc.SetInfo(0, "License", _License);
// Attempt to read File
try
{
if (System.IO.File.Exists(pdfFile) == false)
{
throw new ApplicationException("File does not exist.");
}
doc.Read(pdfFile);
layerCount = doc.LayerCount;
doc.Clear();
doc.Dispose();
}
catch (Exception ex)
{
System.ApplicationException appException = new ApplicationException(ex.Message + "\r\n\r\n" + pdfFile,ex);
throw appException;
}
return layerCount;
}