Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Tuesday, November 21, 2017 5:15:03 PM(UTC)

Nick  
Nick

Groups: Registered, Tech Support, Administrators
Posts: 54


The DocumentWriter object contains static classes which can be used to obtain information about documents. The DocumentWriter.GetFormatFileExtension() and DocumentWriter.GetFormatFriendlyName() methods can be used to obtain, respectively, the default extension and a user-friendly name for the specified format.
DocumentWriter.GetFormatFileExtension()
DocumentWriter.GetFormatFriendlyName()

The expected parameter is a value in the DocumentFormat enumeration. It is important to note that DocumentFormat.User is a special case and only used under specific circumstances. As such, it is not a valid value to be used with either of these methods and an exception will be generated if so. For more information see the documentation.
DocumentFormat

Code:

         string extension = DocumentWriter.GetFormatFileExtension(DocumentFormat.Docx);
         string friendlyName = DocumentWriter.GetFormatFriendlyName(DocumentFormat.Docx);

This value of "extension" and "friendlyName" would be "docx" and "Microsoft Word" for this code snippet.

Here's one in which all extensions and friendly names can be printed to the console.

Code:

         DocumentFormat[] docFormats = (DocumentFormat[])Enum.GetValues(typeof(DocumentFormat));
         for (int i = 0; i < docFormats.Length; i++)
         {
            if (docFormats[i] == DocumentFormat.User)
            {
               continue;
            }
         
            string extension = DocumentWriter.GetFormatFileExtension(docFormats[i]);
            string friendlyName = DocumentWriter.GetFormatFriendlyName(docFormats[i]);

            Console.WriteLine("DocumentFormat:\t" + Enum.GetName(typeof(DocumentFormat), docFormats[i]).PadRight(8) + "\tExtension: " + extension + "\tFriendlyName: " + friendlyName);
         }

Edited by moderator Friday, December 22, 2017 3:55:36 PM(UTC)  | Reason: Not specified

Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
nick@leadtools.com
www.LEADTOOLS.com
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2018, Yet Another Forum.NET
This page was generated in 0.139 seconds.