A format family is a group of several file types for which an application provides additional information. For example, archive files (.7z, .rar, .zip, etc.) or Outlook files (.ost, .pst) are format families.
You can get the format family and the additional information using the GetViewInfo method that returns a ViewInfo object.
GroupDocs.Viewer provides additional information for the following format families:
The following code snippet shows how to get the file type and the pages count from a file:
usingSystem;usingGroupDocs.Viewer;usingGroupDocs.Viewer.Options;usingGroupDocs.Viewer.Results;// ...using(Viewerviewer=newViewer("sample.pdf")){// Get file information.ViewInfoOptionsviewInfoOptions=ViewInfoOptions.ForHtmlView();ViewInfoviewInfo=viewer.GetViewInfo(viewInfoOptions);// Display file type and pages count.Console.WriteLine("Document type is: "+viewInfo.FileType);Console.WriteLine("Pages count: "+viewInfo.Pages.Count);}
ImportsSystemImportsGroupDocs.ViewerImportsGroupDocs.Viewer.OptionsImportsGroupDocs.Viewer.Results' ...
ModuleProgramSubMain(argsAsString())UsingviewerAsViewer=NewViewer("sample.pdf")' Get file information.
DimviewInfoOptionsAsViewInfoOptions=ViewInfoOptions.ForHtmlView()DimviewInfoAsViewInfo=viewer.GetViewInfo(viewInfoOptions)' Display file type and pages count.
Console.WriteLine("Document type is: "&viewInfo.FileType.ToString())Console.WriteLine("Pages count: "&viewInfo.Pages.Count.ToString())EndUsingEndSubEndModule
sample.pdf is the sample file used in this example. Click here to download it.
Document type is: Portable Document Format File (.pdf)
Pages count: 4
Get the file type and the pages count from a stream
The following code snippet shows how to get the file type and the pages count from a stream:
usingSystem;usingSystem.IO;usingGroupDocs.Viewer;usingGroupDocs.Viewer.Options;usingGroupDocs.Viewer.Results;// ...using(Viewerviewer=newViewer(File.OpenRead("sample.pdf"))){ViewInfoOptionsviewInfoOptions=ViewInfoOptions.ForHtmlView();ViewInfoviewInfo=viewer.GetViewInfo(viewInfoOptions);Console.WriteLine("Document type is: "+viewInfo.FileType);Console.WriteLine("Pages count: "+viewInfo.Pages.Count);}
ImportsSystemImportsSystem.IOImportsGroupDocs.ViewerImportsGroupDocs.Viewer.OptionsImportsGroupDocs.Viewer.Results' ...
ModuleProgramSubMain(argsAsString())UsingviewerAsViewer=NewViewer(File.OpenRead("sample.pdf"))DimviewInfoOptionsAsViewInfoOptions=ViewInfoOptions.ForHtmlView()DimviewInfoAsViewInfo=viewer.GetViewInfo(viewInfoOptions)Console.WriteLine("Document type is: "&viewInfo.FileType.ToString())Console.WriteLine("Pages count: "&viewInfo.Pages.Count.ToString())EndUsingEndSubEndModule
sample.pdf is the sample file used in this example. Click here to download it.
Document type is: Portable Document Format File (.pdf)
Pages count: 4