Extract File Format Information

Export can detect a file’s format, and report the information to the API, which in turn reports the information to the developer’s application. This feature enables you to apply customized conversion settings based on a file’s format. See File Format Detection for more information on format detection.

To extract file format information

  1. Set the input source using the setInputSource method.

  2. Call the getAutoDetectInfo method of the Export object to retrieve an object of the AutoDetectInfo class.

  3. Use the methods of the AutoDetectInfo object to retrieve the format information.

The HtmlTest sample program demonstrates how to extract format information through the Java API. See HtmlTest.


AutoDetectInfo adinfo = objHtmlExport.getAutoDetectInfo();
if(adinfo != null)
  outf_format = new File(docFormatOutFile);
  fos_format = new FileOutputStream(outf_format);
  DataOutputStream dos_format = new DataOutputStream(fos_format);
  dos_format.writeBytes("Auto-detection result: \n");
  dos_format.writeBytes("\nCharacter set:   " + adinfo.getCharacterSet());
  dos_format.writeBytes("\nDocument class:  " + adinfo.getDocumentClass());
  dos_format.writeBytes("\nDocument format: " + adinfo.getDocumentFormat());
  dos_format.writeBytes("\nFormat version:  " + adinfo.getVersion());
  dos_format.writeBytes("\nOther attributes:");
    dos_format.writeBytes("\nApple double encoded.");
    dos_format.writeBytes("\nApple single encoded.");
    dos_format.writeBytes("\nMac binary encoded.");
    dos_format.writeBytes("\nWang GDL encoded.");
  adinfo = null;