Exemplo n.º 1
0
        public async Task <string> DocToHTML(int contentId)
        {
            var content = await db.ContentFiles
                          .Include(x => x.FileDocument)
                          .FirstOrDefaultAsync(x => x.Id == contentId);

            if (content == null)
            {
                return("<bold>Error</strong>");
            }

            var fileFullPath = Path.Combine(storageDir, content.FileDocument.FileNameOnStorage);

            try
            {
                var converter = new DocumentConverter();
                var result    = converter.ConvertToHtml(fileFullPath);
                var html      = result.Value; // The generated HTML
                var warnings  = result.Warnings;

                if (String.IsNullOrEmpty(html))
                {
                    return("Error reading the document.");
                }

                return(html);
            }
            catch (Exception e)
            {
                return("Error reading the document.");
            }
        }
Exemplo n.º 2
0
 public DocumentBuilder(
     WebClient webClient, DocumentConverter documentConverter, IUpload upload)
 {
     this.webClient         = webClient;
     this.documentConverter = documentConverter;
     iUpload = upload;
 }
        public static void ConvertHandler(HttpContext context)
        {
            DocumentConverterResult result;

            try
            {
                var inputDocument  = new BackSlashPath(ExamplesConfiguration.UnprotectString(context.Request["inputDocument"]));
                var outputFormat   = (DocumentFormat)Enum.Parse(typeof(DocumentFormat), context.Request["outputFormat"]);
                var fileName       = inputDocument.FileNameWithoutExtension + "." + DocumentFormatInfo.Get(outputFormat).DefaultExtension;
                var outputPath     = ConvertedPath.Append(context.Session.SessionID).Append(fileName);
                var outputDocument = outputPath.Append(fileName);

                if (Directory.Exists(outputPath))
                {
                    Directory.Delete(outputPath, true);
                }
                Directory.CreateDirectory(outputPath);
                result = DocumentConverter.Convert(inputDocument, outputDocument, outputFormat);
            }
            catch (Exception exception)
            {
                context.Response.Write("<span style=\"color: red; font-weight: bold\">Conversion failed</span><br/>");
                context.Response.Write(exception.Message);
                return;
            }

            context.Response.Write("<span style=\"color: green; font-weight: bold\">Conversion successful</span>");
            context.Response.Write("<br/>Conversion time: " + result.ElapsedTime);
            context.Response.Write("<br/>Output files:");

            if (result.OutputFiles.Length > 1)
            {
                context.Response.Write(" - " + GetZipDownloadLink(new FileInfo(result.OutputFiles[0]).Directory));
            }

            context.Response.Write("<br/><ol>");
            foreach (var outputFile in result.OutputFiles)
            {
                if (outputFile.EndsWith("\\"))
                {
                    var directoryInfo = new DirectoryInfo(outputFile);
                    context.Response.Write(string.Format(
                                               "<br/><li><b>{0}\\</b> - {1}</li>",
                                               directoryInfo.Name,
                                               GetZipDownloadLink(directoryInfo))
                                           );
                }
                else
                {
                    var fileInfo = new FileInfo(outputFile);
                    context.Response.Write(string.Format(
                                               "<br/><li><b>{0}</b> ({1} bytes) - {2}</li>",
                                               fileInfo.Name,
                                               fileInfo.Length,
                                               GetDownloadLink(fileInfo))
                                           );
                }
            }
            context.Response.Write("<br/></ol>");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Uploads the Document and file in byte[] to the package.
        /// </summary>
        /// <param name="packageId">The package id.</param>
        /// <param name="fileName">The name of the document.</param>
        /// <param name="fileBytes">The file to upload in bytes.</param>
        /// <param name="document">The document object that has field settings.</param>
        internal Document UploadDocument(DocumentPackage package, string fileName, byte[] fileBytes, Document document)
        {
            string path = template.UrlFor(UrlTemplate.DOCUMENT_PATH)
                          .Replace("{packageId}", package.Id.Id)
                          .Build();

            Silanis.ESL.API.Package  internalPackage = new DocumentPackageConverter(package).ToAPIPackage();
            Silanis.ESL.API.Document internalDoc     = new DocumentConverter(document).ToAPIDocument(internalPackage);

            try
            {
                string json         = JsonConvert.SerializeObject(internalDoc, settings);
                byte[] payloadBytes = Converter.ToBytes(json);

                string boundary = GenerateBoundary();
                byte[] content  = CreateMultipartContent(fileName, fileBytes, payloadBytes, boundary);

                string response = restClient.PostMultipartFile(path, content, boundary, json);

                Silanis.ESL.API.Document uploadedDoc = JsonConvert.DeserializeObject <Silanis.ESL.API.Document>(response);
                return(new DocumentConverter(uploadedDoc, internalPackage).ToSDKDocument());
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not upload document to package." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not upload document to package." + " Exception: " + e.Message, e);
            }
        }
Exemplo n.º 5
0
        public Project(string name, Uri location)
            : base(name, location)
        {
            AssemblyLocation = GenerateAssemblyLocation();

            FReferenceConverter = new ReferenceConverter(location);
            FDocumentConverter  = new DocumentConverter(location);

            FReferences = new EditableIDList <IReference>("References");
            FReferences.Mapper.RegisterMapping <IConverter>(FReferenceConverter);
            Add(FReferences);

            FDocuments = new EditableIDList <IDocument>("Documents");
            FDocuments.Mapper.RegisterMapping <IConverter>(FDocumentConverter);
            Add(FDocuments);

            FReferences.Added += Reference_Added;
            FDocuments.Added  += Document_Added;

            References = FReferences;
            Documents  = FDocuments;

            FBackgroundWorker = new BackgroundWorker();
            FBackgroundWorker.WorkerReportsProgress      = false;
            FBackgroundWorker.WorkerSupportsCancellation = false;

            FBackgroundWorker.DoWork             += DoWorkCB;
            FBackgroundWorker.RunWorkerCompleted += RunWorkerCompletedCB;
        }
Exemplo n.º 6
0
        public Project(string path)
            : base(path)
        {
            LocalPath = path;

            FReferenceConverter = new ReferenceConverter(path);
            FDocumentConverter  = new DocumentConverter(path);

            FReferences = new EditableIDList <IReference>("References");
            FReferences.RootingChanged += FReferences_RootingChanged;
            Add(FReferences);

            FDocuments = new EditableIDList <IDocument>("Documents");
            FDocuments.RootingChanged += FDocuments_RootingChanged;
            Add(FDocuments);

            FReferences.Added += Reference_Added;
            FDocuments.Added  += Document_Added;

            References = FReferences;
            Documents  = FDocuments;

            FBackgroundWorker = new BackgroundWorker();
            FBackgroundWorker.WorkerReportsProgress      = false;
            FBackgroundWorker.WorkerSupportsCancellation = false;

            FBackgroundWorker.DoWork             += DoWorkCB;
            FBackgroundWorker.RunWorkerCompleted += RunWorkerCompletedCB;
        }
Exemplo n.º 7
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var converter = new DocumentConverter();

            converter.SetOcrEngineInstance(_ocrEngine, false);

            var jobData = new DocumentConverterJobData()
            {
                Document               = _documentViewer.Document,
                DocumentFormat         = Leadtools.Forms.DocumentWriters.DocumentFormat.Docx,
                JobName                = "SaveToDocx",
                OutputDocumentFileName = "sample.docx"
            };

            var job = converter.Jobs.CreateJob(jobData);

            converter.Jobs.RunJob(job);

            if (job.Status == DocumentConverterJobStatus.Success)
            {
                MessageBox.Show("Word Document Created");
            }
            else
            {
                MessageBox.Show("Word Document Creation Failed");
            }
        }
Exemplo n.º 8
0
        public void UnrecognisedStylesAreStatedInMessages()
        {
            var documentConverter = new DocumentConverter();
            var result            = documentConverter.ConvertToHtml("TestDocuments/unrecognised-paragraph-styles.docx");

            Assert.AreEqual("Unrecognised paragraph style: 'Funky' (Style ID: style20)", result.Messages[0].Value);
        }
 public void TestHtmlLinkRoundTrip()
 {
   var html = "<A HREF=\"http://www.orf.at\">Orf</A>";
   var rtf = new DocumentConverter().ConvertHtmlToRtf(html);
   var htmlRoundTrip = new DocumentConverter().ConvertRtfToHtml(rtf);
   Assert.That(htmlRoundTrip.Contains("<A HREF"));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Updates the document's data, but not the actually document binary..
        /// </summary>
        /// <param name="package">The DocumentPackage to update.</param>
        /// <param name="document">The Document to update.</param>
        public void UpdateDocumentMetadata(DocumentPackage package, Document document)
        {
            string path = template.UrlFor(UrlTemplate.DOCUMENT_ID_PATH)
                          .Replace("{packageId}", package.Id.Id)
                          .Replace("{documentId}", document.Id)
                          .Build();

            Silanis.ESL.API.Package  apiPackage  = new DocumentPackageConverter(package).ToAPIPackage();
            Silanis.ESL.API.Document apiDocument = new DocumentConverter(document).ToAPIDocument(apiPackage);

            foreach (Silanis.ESL.API.Document apiDoc in apiPackage.Documents)
            {
                if (apiDoc.Id.Equals(document.Id))
                {
                    apiDocument = apiDoc;
                    break;
                }
            }
            if (apiDocument == null)
            {
                throw new EslException("Document is not part of the package.", null);
            }

            try
            {
                string json = JsonConvert.SerializeObject(apiDocument, settings);
                restClient.Post(path, json);
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not update the document's metadata." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not update the document's metadata." + " Exception: " + e.Message, e);
            }

            IContractResolver prevContractResolver = settings.ContractResolver;

            settings.ContractResolver = DocumentMetadataContractResolver.Instance;

            try
            {
                string json = JsonConvert.SerializeObject(apiDocument, settings);
                restClient.Post(path, json);
            }
            catch (EslServerException e)
            {
                throw new EslServerException("Could not upload document to package." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not upload document to package." + " Exception: " + e.Message, e);
            }
            finally
            {
                settings.ContractResolver = prevContractResolver;
            }
        }
Exemplo n.º 11
0
 public void ConvertSDKToSDK()
 {
     sdkDocument1 = CreateTypicalSDKDocument();
     converter    = new DocumentConverter(sdkDocument1);
     sdkDocument2 = converter.ToSDKDocument();
     Assert.IsNotNull(sdkDocument2);
     Assert.AreEqual(sdkDocument2, sdkDocument1);
 }
Exemplo n.º 12
0
 public void ConvertAPIToAPI()
 {
     apiDocument1 = CreateTypicalAPIDocument();
     converter    = new DocumentConverter(apiDocument1, apiPackage);
     apiDocument2 = converter.ToAPIDocument();
     Assert.IsNotNull(apiDocument2);
     Assert.AreEqual(apiDocument2, apiDocument1);
 }
 public void WarnIfDocumentHasImagesStoredOutsideOfDocumentWhenPathOfDocumentIsUnknown()
 {
     using (var file = File.OpenRead(TestFilePath("external-picture.docx"))) {
         var result = new DocumentConverter().ConvertToHtml(file);
         Assert.Equal("", result.Value);
         Assert.Equal(new[] { "could not open external image 'tiny-picture.png': path of document is unknown, but is required for relative URI" }, result.Warnings);
     }
 }
Exemplo n.º 14
0
 public IFacadeUpdateResult <DocumentData> SaveDocument(DocumentDto document)
 {
     using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey))
     {
         DocumentFacade facade = new DocumentFacade(uow);
         return(facade.SaveDocument(DocumentConverter.ConvertToData(document)));
     }
 }
Exemplo n.º 15
0
        public void SingleWordParagraphIsConvertedToSingleHtmlParagraph()
        {
            var documentConverter = new DocumentConverter();
            var result            = documentConverter.ConvertToHtml("TestDocuments/single-paragraph.docx");

            Assert.AreEqual("<p>Walking on imported air</p>", result.Value);
            Assert.IsEmpty(result.Messages);
        }
        public void TestHtmlLinkRoundTrip()
        {
            var html          = "<A HREF=\"http://www.orf.at\">Orf</A>";
            var rtf           = new DocumentConverter().ConvertHtmlToRtf(html);
            var htmlRoundTrip = new DocumentConverter().ConvertRtfToHtml(rtf);

            Assert.That(htmlRoundTrip.Contains("<A HREF"));
        }
Exemplo n.º 17
0
        //Convert any doc to text file
        public static string DocToText(string filePath)
        {
            var converter = new DocumentConverter();
            var result    = converter.ConvertToHtml(filePath);
            var html      = result.Value;

            return(html);
        }
        private void Run()
        {
            // Initialize Trace
            var traceListener = new OutputWindowTraceListener(_outputWindow);

            Trace.Listeners.Add(traceListener);

            // Create it here and hook to the operation event so we can cancel
            var converter = new DocumentConverter();
            EventHandler <DocumentConverterJobEventArgs> jobOperationHandler = (sender, e) =>
            {
                if (this._cancelPending)
                {
                    e.Status = DocumentConverterJobStatus.Aborted;
                }
            };

            converter.Jobs.JobOperation += jobOperationHandler;

            try
            {
                this.Preferences.Run(this.Cache, this.InputDocument, converter, null);
            }
            catch (OcrException ex)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    UI.Helper.ShowError(this, string.Format("OCR error code: {0}\n{1}", ex.Code, ex.Message));
                });
            }
            catch (RasterException ex)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    UI.Helper.ShowError(this, string.Format("LEADTOOLS error code: {0}\n{1}", ex.Code, ex.Message));
                });
            }
            catch (Exception ex)
            {
                this.BeginInvoke((MethodInvoker) delegate
                {
                    UI.Helper.ShowError(this, ex);
                });
            }
            finally
            {
                Trace.Listeners.Remove(traceListener);
                converter.Jobs.JobOperation -= jobOperationHandler;

                _isWorking = false;

                this.BeginInvoke((MethodInvoker) delegate
                {
                    this.ControlBox    = true;
                    _cancelButton.Text = "C&lose";
                });
            }
        }
Exemplo n.º 19
0
 /// <summary>
 /// 文章转换为PDF格式
 /// </summary>
 /// <param name="OpenOffice_HOME">OpenOffice安装目录</param>
 /// <param name="docPath">文件目录</param>
 /// <param name="pdfPath">pdfPath输入目录</param>
 public static void DocToPdf(string OpenOffice_HOME, string docPath, string pdfPath)
 {
     OpenOfficeConnection connection = null;
     DocumentConverter converter = null;
     Process p = null;
     try
     {
         System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses();
         foreach (System.Diagnostics.Process process in processList)
         {
             if (process.ProcessName.Contains("soffice"))
             {
                 p = process;
                 break;
             }
         }
         if (p == null)
         {
             ProcessStartInfo FilestartInfo = new ProcessStartInfo(OpenOffice_HOME);
             FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
             FilestartInfo.Arguments = " -headless -accept=\"socket,host=127.0.0.1,port=8101;urp;\"";
             //转换
             p = Process.Start(FilestartInfo);
         }
         File inputFile = new File(docPath);
         File outputFile = new File(pdfPath);
         connection = new SocketOpenOfficeConnection("127.0.0.1", 8101);
         connection.connect();
         converter = new OpenOfficeDocumentConverter(connection);
         converter.convert(inputFile, outputFile);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (connection != null)
         {
             try
             {
                 connection.disconnect();
             }
             catch (Exception)
             {
             }
         }
         try
         {
             p.Kill();
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Filter = "MS Word 2016 (*.docx)|*.docx";
            dialog.Title  = "Выберите документ для загрузки данных";
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textBox1.Text = dialog.FileName;
                var converter = new DocumentConverter();
                var result    = converter.ConvertToHtml(dialog.FileName);
                html = result.Value; // The generated HTML

                string br1 = "<br /><br /><br />";
                string br2 = "<br />\n< br /> ";
                string br3 = "<br /></h2>";
                string br4 = "<br /><br />";
                string br5 = "<br />";
                html = html.Replace("</li>", "</li>\n").Replace("<ul>", "<ul>\n").Replace("<ol>", "<ol>\n").Replace("</p>", "\n\n").Replace("<p>", "").Replace("</ul>", "</ul>\n\n").Replace("</ol>", "</ol>\n\n").Replace("< br />", "").Replace("< br />", "").Replace("тысячей", "тысяч").Replace("привёдшее", "приведшее").Replace("</strong>: <strong>", ": ").Replace("<strong> </strong>", " ");
                if (chIfMfc.Checked == true)
                {
                    html = html.Replace("<strong>", "<h2>").Replace("</strong>", "</h2>\n\n").Replace("</h3>", "</h3>\n\n").Replace("</h1>", "\n\n").Replace("<h1>", "").Replace("</h2>", "</h2>\n\n").Replace("< br />", "");
                }
                else
                {
                    html = html.Replace("<strong>", "<h2>").Replace("</strong>", "</h2>\n\n").Replace(br1, " ").Replace(br4, "\n\n").Replace(br2, "\n\n").Replace(br3, "</h2>").Replace(br5, "");
                }

                html = html.Replace("<strong> </strong>", " ");

                //Блок Ютьюб
                string[] words = html.Split(' ');
                string   s0    = words[1];
                string   sCont = "href";
                bool     b     = s0.Contains(sCont);
                if (b)
                {
                    s0 = s0.Replace("<strong>", "").Replace("</strong>", "");
                }
                else
                {
                    s0 = html.Remove(html.IndexOf("\n"), html.Length - html.IndexOf("\n"));
                }
                //Search.q = html.Remove(html.IndexOf("\n"), html.Length - html.IndexOf("\n"));
                Search.q = s0;
                Search.YTBsearch();


                rtbYTBlist.Text = Search.listUrl;
                YtbZagolovok    = $"<h3 style=\"text-align: center;\">{nazvYtb}</h3>\n";
                html           += YtbZagolovok;
                html           += sborkaYoutube;
            }
        }
Exemplo n.º 21
0
        public void ConvertToAPIWithNullDescription()
        {
            sdkDocument1 = DocumentBuilder.NewDocumentNamed("sdkDocumentNullDes")
                           .WithId("sdkDocumentId")
                           .FromFile(file.FullName)
                           .WithSignature(SignatureBuilder.SignatureFor("*****@*****.**")
                                          .OnPage(0))
                           .Build();

            converter = new DocumentConverter(sdkDocument1);
            Assert.IsNull(converter.ToAPIDocument().Description);
        }
        public void ConvertRtfToHtml()
        {
            var html = new DocumentConverter().ConvertRtfToHtml(@"{\rtf1
 Guten Tag!
 \line
 {\i Dies} ist \b{\i ein 
 \i0 formatierter \b0Text}.
 \par
 \i0 Das \b0Ende.
 }");

            var rtf = new DocumentConverter().ConvertHtmlToRtf(html);
        }
Exemplo n.º 23
0
        private Document GetCurrentDocument()
        {
            var dao       = new DocumentDao();
            var converter = new DocumentConverter();
            var document  = converter.Convert(dao.GetByDraftee(DrafteeId));

            if (document == null)
            {
                document           = new Document();
                document.DrafteeId = DrafteeId;
            }
            return(document);
        }
Exemplo n.º 24
0
        public ActionResult ConvertToPdf(HttpPostedFileBase file)
        {
            Gnostice.Documents.Framework.ActivateLicense("495D-ED31-5353-EDE4-9969-EEFE-3860-1561-3A5F-0140-5CC2-B121");
            DocumentConverter dc = new DocumentConverter();

            if (file.FileName.EndsWith(".docx"))
            {
                var    wordFile = @"N:\New folder\JAHAL Satish.docx";
                string pdfFile  = file.FileName.Replace(".docx", ".pdf");
                dc.ConvertToFile(wordFile, @"C:\Users\rakesh\Documents\Gnostice\new\" + pdfFile);
            }
            return(View());
        }
    public void ConvertRtfToHtml()
    {
      var html = new DocumentConverter().ConvertRtfToHtml(@"{\rtf1
 Guten Tag!
 \line
 {\i Dies} ist \b{\i ein 
 \i0 formatierter \b0Text}.
 \par
 \i0 Das \b0Ende.
 }");

      var rtf = new DocumentConverter().ConvertHtmlToRtf(html);

    }
Exemplo n.º 26
0
        public void ComposedConversion()
        {
            string message = "It's à tèst with a basic document.";

            //Convert a string document to a base64 document
            DocumentConverter <string> documentConverter = DocumentConverter
                                                           .STRING
                                                           .Compose(DocumentConverter.BASE64);

            Document document       = documentConverter.Get(message);
            string   stringDocument = documentConverter.Get(document);

            Assert.AreEqual(message, stringDocument);
        }
Exemplo n.º 27
0
        private DocumentConverterJob CreateConverterJob(DocumentConverter converter, LEADDocument document)
        {
            // Set the maximum page
            var firstPage = this.InputFirstPage;

            if (firstPage == 0)
            {
                firstPage = 1;
            }

            var lastPage = this.InputLastPage;

            if (lastPage == 0)
            {
                lastPage = -1;
            }

            if (document != null && this.InputMaximumPages > 0)
            {
                if (lastPage == -1)
                {
                    lastPage = document.Pages.Count;
                }
                lastPage = Math.Min(lastPage, firstPage + this.InputMaximumPages - 1);
            }

            // Create a job
            var jobData = new DocumentConverterJobData
            {
                InputDocumentFileName = document == null ? this.InputDocumentFileName : null,
                Document = document,
                InputDocumentFirstPageNumber = firstPage,
                InputDocumentLastPageNumber  = lastPage,
                DocumentFormat            = this.DocumentFormat,
                RasterImageFormat         = this.RasterImageFormat,
                RasterImageBitsPerPixel   = this.RasterImageBitsPerPixel,
                OutputDocumentFileName    = this.OutputDocumentFileName,
                AnnotationsMode           = this.OutputAnnotationsMode,
                OutputAnnotationsFileName = this.OutputAnnotationsFileName,
                JobName  = this.JobName,
                UserData = null,
            };

            jobData.InputAnnotationsFileName = this.InputAnnotationsFileName;

            var job = converter.Jobs.CreateJob(jobData);

            return(job);
        }
Exemplo n.º 28
0
        public void UsesDocumentWriterFactory()
        {
            // Background: Proves that the converter uses the factory
            // Arrange
            var factory   = Substitute.For <IDocumentWriterFactory>();
            var converter = new DocumentConverter(factory);
            var input     = new MemoryStream();
            var output    = new MemoryStream();

            // Act
            converter.Convert(input, output);

            // Assert
            factory.Received(1).Create(output);
        }
        public void WarnIfImagesStoredOutsideOfDocumentAreNotFound()
        {
            var tempDirectory = Path.Combine(Path.GetTempPath(), "mammoth-" + Guid.NewGuid());

            Directory.CreateDirectory(tempDirectory);
            try {
                var documentPath = Path.Combine(tempDirectory, "external-picture.docx");
                File.Copy(TestFilePath("external-picture.docx"), documentPath);
                var result = new DocumentConverter().ConvertToHtml(documentPath);
                Assert.Equal("", result.Value);
                Assert.StartsWith("could not open external image 'tiny-picture.png':", result.Warnings.Single());
            } finally {
                Directory.Delete(tempDirectory, recursive: true);
            }
        }
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            FillData(GetCurrentDraftee());
            var dao       = new DocumentDao();
            var converter = new DocumentConverter();
            var document  = converter.Convert(dao.GetByDraftee(DrafteeId));

            if (document != null)
            {
                Document = document;
            }
            else
            {
                Document           = new Document();
                Document.DrafteeId = DrafteeId;
            }
        }
        } // getMainSchemaName()

        public override DataSet materializeMainSchemaTable(Table table, Column[] columns, int maxRows)
        {
            DocumentConverter documentConverter = _schemaBuilder.getDocumentConverter(table);

            SelectItem[]   selectItems    = MetaModelHelper.createSelectItems(columns);
            DataSetHeader  header         = new CachingDataSetHeader(selectItems);
            DocumentSource documentSource = getDocumentSourceForTable(table.getName());

            DataSet dataSet = new DocumentSourceDataSet(header, documentSource, documentConverter);

            if (maxRows > 0)
            {
                dataSet = new MaxRowsDataSet(dataSet, maxRows);
            }

            return(dataSet);
        } // materializeMainSchemaTable()
Exemplo n.º 32
0
        private void Act(string input, Action <IDocumentWriter> assert)
        {
            var factory      = Substitute.For <IDocumentWriterFactory>();
            var writer       = Substitute.For <IDocumentWriter>();
            var converter    = new DocumentConverter(factory);
            var inputStream  = new MemoryStream();
            var outputStream = new MemoryStream();

            factory.Create(outputStream).Returns(writer);

            using (var streamWriter = new StreamWriter(inputStream, leaveOpen: true))
            {
                streamWriter.Write(input);
            }

            inputStream.Position = 0;

            converter.Convert(inputStream, outputStream);

            assert(writer);
        }
Exemplo n.º 33
0
		/// <summary>
		/// Uploads the Document and file in byte[] to the package.
		/// </summary>
		/// <param name="packageId">The package id.</param>
		/// <param name="fileName">The name of the document.</param>
		/// <param name="fileBytes">The file to upload in bytes.</param>
		/// <param name="document">The document object that has field settings.</param>
		internal Document UploadDocument (DocumentPackage package, string fileName, byte[] fileBytes, Document document)
		{
			string path = template.UrlFor (UrlTemplate.DOCUMENT_PATH)
				.Replace ("{packageId}", package.Id.Id)
					.Build ();

			Silanis.ESL.API.Package internalPackage = new DocumentPackageConverter(package).ToAPIPackage();
			Silanis.ESL.API.Document internalDoc = new DocumentConverter(document).ToAPIDocument(internalPackage);

			try 
			{
				string json = JsonConvert.SerializeObject (internalDoc, settings);
				byte[] payloadBytes = Converter.ToBytes (json);

				string boundary = GenerateBoundary ();
				byte[] content = CreateMultipartContent (fileName, fileBytes, payloadBytes, boundary);

				string response = restClient.PostMultipartFile(path, content, boundary, json);

				Silanis.ESL.API.Document uploadedDoc = JsonConvert.DeserializeObject<Silanis.ESL.API.Document>(response);
				return new DocumentConverter(uploadedDoc, internalPackage).ToSDKDocument();
			} 
            catch (EslServerException e) 
            {
                throw new EslServerException ("Could not upload document to package." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) 
			{
				throw new EslException ("Could not upload document to package." + " Exception: " + e.Message, e);
			}
		}
Exemplo n.º 34
0
        /// <summary>
        /// Updates the document's data, but not the actually document binary..
        /// </summary>
        /// <param name="package">The DocumentPackage to update.</param>
        /// <param name="document">The Document to update.</param>
		public void UpdateDocumentMetadata(DocumentPackage package, Document document)
        {
            string path = template.UrlFor(UrlTemplate.DOCUMENT_ID_PATH)
				.Replace("{packageId}", package.Id.Id)
				.Replace("{documentId}", document.Id)
				.Build();

            Silanis.ESL.API.Package apiPackage = new DocumentPackageConverter(package).ToAPIPackage();
            Silanis.ESL.API.Document apiDocument = new DocumentConverter(document).ToAPIDocument(apiPackage);

            foreach (Silanis.ESL.API.Document apiDoc in apiPackage.Documents)
            {
                if (apiDoc.Id.Equals(document.Id))
                {
                    apiDocument = apiDoc;
                    break;
                }
            }
            if (apiDocument == null)
            {
                throw new EslException("Document is not part of the package.", null);
            }
            
			try 
			{
				string json = JsonConvert.SerializeObject (apiDocument, settings);
				restClient.Post(path, json);
			} 
            catch (EslServerException e) 
            {
                throw new EslServerException ("Could not update the document's metadata." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) 
			{
                throw new EslException ("Could not update the document's metadata." + " Exception: " + e.Message, e);
			}

            IContractResolver prevContractResolver = settings.ContractResolver;
            settings.ContractResolver = DocumentMetadataContractResolver.Instance;            
            
            try
            {
                string json = JsonConvert.SerializeObject(apiDocument, settings);
                restClient.Post(path, json);
            }
            catch (EslServerException e) 
            {
                throw new EslServerException ("Could not upload document to package." + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e)
            {
                throw new EslException("Could not upload document to package." + " Exception: " + e.Message, e);
            }
            finally
            {
                settings.ContractResolver = prevContractResolver;
            }
		}
Exemplo n.º 35
0
        static void Main(string[] args)
        {
            // Activate Gnostice product
            Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369");

            // Instantiate DocumentConverter
            DocumentConverter docConverter = new DocumentConverter();

            // Subscribe to Error event
            docConverter.Error += docConverter_Error;

            // Input Directory
            string inputPath = @"../../../../../03. Sample Files/";

            // Output Directory
            string outputPath = @"../../../../../04. Output/";

            // Output Format
            string outputFormat = "jpg";

            // List of files as input for the document Converter
            List<string> inputFiles = Directory.GetFiles(inputPath).ToList();

            // Single input file
            string inputFile = inputPath + "input.docx";

            // Single output file
            string outputFile = outputPath + "output." + outputFormat;

            #region Simple Conversion

            // Converting sample input file to JPEG format
            docConverter.ConvertToFile(inputFile, outputFile);

            #endregion

            // public List<string> ConvertToFile(
            // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream>
            // string outputFileFormat,  => expected output file format
            // string outputDir, => directory in which the output files are to be stored
            // string baseFileName = "", => name of the output converted file
            // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file
            // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted
            // EncoderSettings encoderSettings = null, => set the information for encoding the document
            // string inputDocPassword = "" => password for the input document
            // );

            #region One to One Conversion

            // Converts all 
            // ConversionMode.ConvertToSeparateFiles=>Many to many conversion
            // Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToJPEG_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles);

            #endregion

            #region Convert to single file

            //ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file
            //Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToJPEG_ManyToOne", ConversionMode.ConvertToSingleFile);

            #endregion

            #region Converting file using ConverterSettings

            // Instantiate ConverterSettings
            ConverterSettings cp = new ConverterSettings();

            //Converter Parameter : PageRange
            // 4 different types of page ranges
            // PageRange.All => Converts all pages in input file 
            // PageRange.Even => Converts Pages with even page number 
            // PageRange.Odd => Converts Pages with odd page number
            // PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange
            // Convert all odd pages in input file
            cp.PageRange = PageRange.Odd;

            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToJPEG_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp);

            // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file
            cp.PageRange = PageRange.Custom;
            cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom

            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToJPEG_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp);
            #endregion

            #region JPEG encoder formats

            JPEGEncoderSettings jpegEncoderFormats = new JPEGEncoderSettings();

            // Page Scaling
            // 2 modes
            // PageScaling.None
            // PageScalling.UseRenderingResolution
            jpegEncoderFormats.PageScalling = PageScalling.None;

            //Quality level in percentage of the quality of the original file
            jpegEncoderFormats.QualityLevel = 10;

            // Rendering Setting level
            // The compositing mode CompositingMode determines whether pixels from a source image overwrite or are combined with background pixels.
            // 2 compositing modes
            // CompositingMode.SourceOver =>  Specifies that when a color is rendered, it is blended with the background color. The blend is determined by the alpha component of the color being rendered.
            // Compositing.SourceCopy => Specifies that when a color is rendered, it overwrites the background color.
            jpegEncoderFormats.RenderingSettings.Image.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;

            // The composition quality CompositingQuality sets the rendering quality of composited images drawn 
            // 6 compositing quality types
            // CompositingQuality.AssumeLinear => Assume linear values
            // CompositingQuality.Default => Default quality
            // CompositingQuality.GammaCorrected => Use Gamma correction
            // CompositingQuality.HighQuality => High quality low speed compositing
            // CompositingQuality.HighSpeed => High speed low quality compositing
            // CompositingQuality.Invalid => Invalid quality
            jpegEncoderFormats.RenderingSettings.Image.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.Default;

            // The Interpolation mode  sets the interpolation mode associated with this jpeg file
            // 9 Interpolation modes
            // InterpolationMode.Bicubic => Specifies bicubic interpolation. No prefiltering is done.  This mode is not suitable for shrinking an image below 25 percent of its original size.
            // InterpolationMode.Bilinear => Specifies bilinear interpolation. No prefiltering is done. This mode is not suitable for shrinking an image below 50 percent of its original size.
            // InterpolationMode.Default => Specifies default mode.
            // InterpolationMode.High => Specifies high quality interpolation.
            // InterpolationMode.HighQualityBicubic => Specifies high-quality, bicubic interpolation. Prefiltering is performed to ensure high-quality shrinking. This mode produces the highest quality transformed images.
            // InterpolationMode.HighQualityBilinear => Specifies high-quality, bilinear interpolation. Prefiltering is performed to ensure high-quality shrinking.
            // InterpolationMode.Invalid => Equivalent to the Invalid element of the QualityMode enumeration.
            // InterpolationMode.Low => Specifies low quality interpolation.
            // InterpolationMode.NearestNeighbor => Specifies nearest-neighbor interpolation
            jpegEncoderFormats.RenderingSettings.Image.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Default;

            // The pixel offset mode  sets a value specifying how pixels are offset during rendering of this jpeg file
            // 6 pixel offset modes
            // PixelOffsetMode.Half => Specifies that pixels are offset by -.5 units, both horizontally and vertically, for high speed antialiasing.
            // PixelOffsetMode.Default => Specifies the default mode
            // PixelOffsetMode.None => Specifies no pixel offset
            // PixelOffsetMode.HighQuality => High quality low speed rendering
            // PixelOffsetMode.HighSpeed => High speed low quality rendenring
            // PixelOffsetMode.Invalid => Specifies an invalid mode
            jpegEncoderFormats.RenderingSettings.Image.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Default;

            // The smoothing mode specifies whether lines, curves, and the edges of filled areas use smoothing (also called antialiasing)
            // 6 Line Smoothening modes for line art
            // SmoothingMode.AntiAlias => Specifies antialiased rendering. 
            // SmoothingMode.Default => Specifies no antialiasing. 
            // SmoothingMode.HighQuality => Specifies antialiased rendering. 
            // SmoothingMode.HighSpeed => Specifies no antialiasing. 
            // SmoothingMode.Invalid => Specifies an invalid mode. 
            // SmoothingMode.None => Specifies no antialiasing.
            jpegEncoderFormats.RenderingSettings.LineArt.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;


            //Text Contarst
            jpegEncoderFormats.RenderingSettings.Text.TextContrast = 5;

            // Text Rendering Hint
            // 6 types of text rendering hints
            // TextRenderingHint.SystemDefault => Each character is drawn using its glyph bitmap, with the system default rendering hint. The text will be drawn using whatever font-smoothing settings the user has selected for the system.
            // TextRenderingHint.AntiAlias => Each character is drawn using its antialiased glyph bitmap without hinting. Better quality due to antialiasing. Stem width differences may be noticeable because hinting is turned off.
            // TextRenderingHint.AntiAliasGridFit =>   Each character is drawn using its antialiased glyph bitmap with hinting. Much better quality due to antialiasing, but at a higher performance cost.
            // TextRenderingHint.ClearTypeGridFit => Each character is drawn using its glyph ClearType bitmap with hinting. The highest quality setting. Used to take advantage of ClearType font features.
            // TextRenderingHint.SingleBitPerPixelPerGridFit => Each character is drawn using its glyph bitmap. Hinting is used to improve character appearance on stems and curvature.
            // TextRenderingHint.SingleBitPerPixel => Each character is drawn using its glyph bitmap. Hinting is not used.
            jpegEncoderFormats.RenderingSettings.Text.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;

            // Rendering Settings resolution
            jpegEncoderFormats.RenderingSettings.Resolution.DPI = 96f;
            jpegEncoderFormats.RenderingSettings.Resolution.DpiX = 96f;
            jpegEncoderFormats.RenderingSettings.Resolution.DpiY = 69f;

            // Resolution Mode
            // 3 types of resolution modes
            // ResolutionMode.UseSource => use source resolution
            // ResolutionMode.UseDevice => use device resolution
            // ResolutionMode.UseSpecifiedDPI => use DPI specified in  pngEncoderFormats.RenderingSettings.Resolution.DPI
            jpegEncoderFormats.RenderingSettings.Resolution.ResolutionMode = ResolutionMode.UseSource;

            // Resolution Settings
            jpegEncoderFormats.ResolutionSettings.DPI = 96f;
            jpegEncoderFormats.ResolutionSettings.DpiX = 96f;
            jpegEncoderFormats.ResolutionSettings.DpiY = 96f;

            // 3 types of resolution modes
            // ResolutionMode.UseSource => use source resolution
            // ResolutionMode.UseDevice => use device resolution
            // ResolutionMode.UseSpecifiedDPI => use DPI specified in  pngEncoderFormats.RenderingSettings.Resolution.DPI
            jpegEncoderFormats.ResolutionSettings.ResolutionMode = ResolutionMode.UseSource;

            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToJPEG_WithEncoderSettings", ConversionMode.ConvertToSingleFile, jpegEncoderFormats);

            #endregion
        }
Exemplo n.º 36
0
        static void Main(string[] args)
        {
            // Activate Gnostice product
            Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369");

            // Instantiate DocumentConverter
            DocumentConverter docConverter = new DocumentConverter();

            // Subscribe to Error event
            docConverter.Error += docConverter_Error;

            // Input Directory
            string inputPath = @"../../../../../03. Sample Files/";

            // Output Directory
            string outputPath = @"../../../../../04. Output/";

            // Output Format
            string outputFormat = "docx";

            // List of files as input for the document Converter
            List<string> inputFiles = Directory.GetFiles(inputPath).ToList();

            // Single input file
            string inputFile = inputPath + "input.pdf";

            // Single output file
            string outputFile = outputPath + "output." + outputFormat;

            #region Simple Conversion

            // Converting sample input file to DOCX format
            docConverter.ConvertToFile(inputFile, outputFile);

            #endregion

            // public List<string> ConvertToFile(
            // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream>
            // string outputFileFormat,  => expected output file format
            // string outputDir, => directory in which the output files are to be stored
            // string baseFileName = "", => name of the output converted file
            // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file
            // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted
            // EncoderSettings encoderSettings = null, => set the information for encoding the document
            // string inputDocPassword = "" => password for the input document
            // );

            #region One to One Conversion
            // Converts all 
            //ConversionMode.ConvertToSeparateFiles=>Many to many conversion
            //Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles
            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToDOCX_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles);
            #endregion

            #region Convert to single file

            //ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file
            //Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToDOCX_ManyToOne", ConversionMode.ConvertToSingleFile);

            #endregion

            #region Converting file using ConverterSettings

            // Instantiate ConverterSettings
            ConverterSettings cp = new ConverterSettings();

            //Converter Parameter : PageRange
            //4 different types of page ranges
            //PageRange.All => Converts all pages in input file  
            //PageRange.Even => Converts Pages with even page number 
            //PageRange.Odd => Converts Pages with odd page number
            //PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange

            // Convert all even pages in input file
            cp.PageRange = PageRange.Even;
            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToDOCX_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp);

            // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file
            cp.PageRange = PageRange.Custom;
            cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom
            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToDOCX_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp);
            #endregion


        }
Exemplo n.º 37
0
        static void Main(string[] args)
        {
            // Activate Gnostice product
            Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369");

            // Instantiate DocumentConverter
            DocumentConverter docConverter = new DocumentConverter();

            // Subscribe to Error event
            docConverter.Error += docConverter_Error;

            // Input Directory
            string inputPath = @"../../../../../03. Sample Files/";

            // Output Directory
            string outputPath = @"../../../../../04. Output/";

            // Output Format
            string outputFormat = "pdf";

            // List of files as input for the document Converter
            List<string> inputFiles = Directory.GetFiles(inputPath).ToList();

            // public List<string> ConvertToFile(
            // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream>
            // string outputFileFormat,  => expected output file format
            // string outputDir, => directory in which the output files are to be stored
            // string baseFileName = "", => name of the output converted file
            // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file
            // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted
            // EncoderSettings encoderSettings = null, => set the information for encoding the document
            // string inputDocPassword = "" => password for the input document
            // );

            #region PDF Encoder Settings

            // For encoding into PDF portfolios files PdfEncoderParams have to be specified
            PDFEncoderSettings pdfEncoderParams = new PDFEncoderSettings();

            // 3 conditions of creating PDF portfolio
            // PortfolioCreationMode.Always => Always creates a portfolio
            // PortfolioCreationMode.Off => Does not create a portfolio
            // PortfolioCreationMode.OnlyWhenAttachmentsExist => Creates a portfolio only when there is more than one document
            // PortfolioCreationMode.WhenInputIsPortfolio => creates a portfolio when the input is a portfolio
            pdfEncoderParams.PDFPortfolioSettings.PortfolioCreationMode = PortfolioCreationMode.Always;

            // 3 views of the PDF portfolio
            // PortfolioLayoutMode.Details => Shows the details of the various files in the portfolio
            // PortfolioLayoutMode.Hide => Hides the details of the  various files in the portfolio
            // PortfolioLayoutMode.Tile => Dispays the  attached documents in the form of tiles
            pdfEncoderParams.PDFPortfolioSettings.PortfolioLayoutMode = PortfolioLayoutMode.Tile;

            #endregion

            #region Covert first file and attach remaining in their original forms

            // ConversionMode.ConvertFirstFileAndAttachRestAsOriginal => Converts first file and attaches remaining as originals
            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_ConvertFirstFileAndAttachRestAsOriginal", ConversionMode.CreateNewFileAndAttachAllAsOriginal, pdfEncoderParams);

            #endregion

            #region Attach all originals

            //ConversionMode.ConverToSingleFile =>creates a new file and attaches all files in their original form without converting any file

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_CreateNewFileAndAttachAllAsOriginal", ConversionMode.CreateNewFileAndAttachAllAsOriginal, pdfEncoderParams);

            #endregion

            #region Converting file using ConverterSettings

            // Instantiate ConverterSettings
            ConverterSettings cp = new ConverterSettings();

            // Converter Parameter : PageRange
            // 4 different types of page ranges
            // PageRange.All => Converts all pages in first input file  
            // PageRange.Even => Converts Pages with even page number in the first input file
            // PageRange.Odd => Converts Pages with odd page number in the first input file
            // PageRange.Custom => Converts set of pages from first input file. ** page range should be specified in CustomPageRange

            // Convert all even pages in first input file
            cp.PageRange = PageRange.Even;

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_WithConverterSettings_Even", ConversionMode.ConvertFirstFileAndAttachRestAsOriginal, pdfEncoderParams, cp);

            // Convert specific pages from input file, say one need to convert 1,3,5,6,7,10 pages from input file
            cp.PageRange = PageRange.Custom;
            cp.CustomPageRange = "1,3,5-7,10"; // **PageRange should be set to PageRange.Custom

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToPDFPortfolio_WithConverterSettings_Custom", ConversionMode.ConvertFirstFileAndAttachRestAsOriginal, pdfEncoderParams, cp);
            #endregion

        }
Exemplo n.º 38
0
        static void Main(string[] args)
        {
            // Activate Gnostice product
            Framework.ActivateLicense("4AF4-263D-70A5-F5C8-57E6-045C-ED92-5369");

            // Instantiate DocumentConverter
            DocumentConverter docConverter = new DocumentConverter();

            // Subscribe to Error event
            docConverter.Error += docConverter_Error;

            // Input Directory
            string inputPath = @"../../../../../03. Sample Files/";

            // Output Directory
            string outputPath = @"../../../../../04. Output/";

            // Output Format
            string outputFormat = "txt";

            // List of files as input for the document Converter
            List<string> inputFiles = Directory.GetFiles(inputPath).ToList();

            // Single input file
            string inputFile = inputPath + "input.docx";

            // Single output file
            string outputFile = outputPath + "output." + outputFormat;

            #region Simple Conversion

            // Converting sample input file to TXT format
            docConverter.ConvertToFile(inputFile, outputFile);

            #endregion

            // public List<string> ConvertToFile(
            // object input, => accepts string (file name) or Stream (file stream) or List<string> or List<Stream>
            // string outputFileFormat,  => expected output file format
            // string outputDir, => directory in which the output files are to be stored
            // string baseFileName = "", => name of the output converted file
            // ConversionMode conversionmode, => ConversionMode.ConvertToSeparateFiles to create a separated file for each converted input file
            // ConverterSettings converterSettings = null, => specifiy the range of pages to be converted
            // EncoderSettings encoderSettings = null, => set the information for encoding the document
            // string inputDocPassword = "" => password for the input document
            // );

            #region One to One Conversion

            // Converts all 
            //ConversionMode.ConvertToSeparateFiles=>Many to many conversion
            //Convert list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSeperateFiles

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTXT_OneToOne_Multiple", ConversionMode.ConvertToSeperateFiles);
            #endregion

            #region Convert to single file

            //ConversionMode.ConverToSingleFile => Convert all the input files and merge it to a single file
            //Converts list of files in inputFiles into a single output file by specifying Conversion mode as ConversionMode.ConvertToSingleFile

            docConverter.ConvertToFile(inputFiles, outputFormat, outputPath, "ConvertToTXT_ManyToOne", ConversionMode.ConvertToSingleFile);

            #endregion

            #region Converting file using ConverterSettings

            // Instantiate ConverterSettings
            ConverterSettings cp = new ConverterSettings();

            // Converter Parameter : PageRange
            // 4 different types of page ranges
            // PageRange.All => Converts all pages in input file  
            // PageRange.Even => Converts Pages with even page number 
            // PageRange.Odd => Converts Pages with odd page number
            // PageRange.Custom => Converts set of pages from input file. ** page range should be specified in CustomPageRange

            // Convert all even pages in input file
            cp.PageRange = PageRange.Even;

            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTXT_WithConverterSettings_Even", ConversionMode.ConvertToSeperateFiles, null, cp);

            // Convert specific pages from input file, say one needs to convert  pages 1,4,8,9,10,11,12 from input file
            cp.PageRange = PageRange.Custom;
            cp.CustomPageRange = "1,4,8-12"; // **PageRange should be set to PageRange.Custom

            docConverter.ConvertToFile(inputFile, outputFormat, outputPath, "ConvertToTXT_WithConverterSettings_Custom", ConversionMode.ConvertToSeperateFiles, null, cp);
            #endregion

            #region TXT Encoder Parameters

            // For encoding file into TXT textEncoderParams have to be specified
            TextEncoderSettings txtEncoderParams = new TextEncoderSettings();

            txtEncoderParams.ByteOrderMarkBytes = new byte[0];

            // Types of file Encoding Files 'FileEncoding'
            // FileEncoding.ISO_8859_1=> encoding files in ISO 8859-1
            // FileEncoding.US_ASCII=>Encoding files in US ASCII
            // FileEncoding.UTF_16BE=> Encoding files in UTF 16BE
            // FileEncoding.UTF_16LE=> Encoding files in UTF 16LE
            // FileEncoding.UTF_8=> Encoding files in UTF 8 (default file encoding)
            txtEncoderParams.FileEncoding = FileEncoding.UTF_8;

            // 6 members of TextFormatter
            // TextFormatter.BreakLines=> break point at every line
            // TextFormatter.BreakPages=>break point at every page
            // TextFormatter.BreakParagraphs=>break point at every paragraph
            // TextFormatter.CustomPageBreak=>to enable  cutom break point
            // TextFormatter.CustomPageBreakText=>set the custom break point
            // TextFormatter.FILE_SEPARATOR_CHAR=>set the file separator character
            // TextFormatter.PageBreakText=>set the page break text
            // For setting break point to every line
            txtEncoderParams.TextFormatter.CustomPageBreak = true;
            txtEncoderParams.TextFormatter.CustomPageBreakText = "<<Page Break>>";

            // txtEncoderParams.UseByteOrderMark=>to use byte order mark
            txtEncoderParams.UseByteOrderMark = true;

            docConverter.ConvertToFile(inputFile, "txt", outputPath, "ConvertToTXT_WithEncoderSettings", ConversionMode.ConvertToSeperateFiles, txtEncoderParams, cp);

            #endregion
        }