We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Create new Document with Multiple Namespaces


I would like to conditionally set a variable in one class to be either:

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
Aspose.Words.Document doc = new Aspose.Words.Document();

Depending on the incoming variable, I would like to determine which namepspace to use to create a new Document (either have the one class create a new Pdf Document, or a new Words Document).

Do you know if it is possible to conditionally set a variable to use different namespaces/classes?



You can use FileFormatUtil.DetectFileFormat Method (String) to detect the information about a format of a document. If the incoming document is detected as a Word document i.e. DOCX, DOC, RTF etc, then you can instantiate the Aspose.Words Document object. Hope, this helps.