XDoc.Converter SDK Developer Guide
User Manual: Pdf
Open the PDF directly: View PDF .
Page Count: 28
Download | |
Open PDF In Browser | View PDF |
XDoc.Converter SDK Developer Guide Table of Contents XDoc.Converter SDK Developer Guide ............................................................................................ 1 Convert a file to a PDF file ............................................................................................................... 3 Convert Microsoft Word (.docx) to PDF .................................................................................. 3 Convert Microsoft Excel (.xlsx) to PDF..................................................................................... 3 Convert Microsoft PowerPoint (.pptx) to PDF......................................................................... 4 Convert Tiff to PDF .................................................................................................................. 5 Convert Dicom to PDF ............................................................................................................. 5 Convert JPEG to PDF ................................................................................................................ 6 Create PDF file with the specified PDF page size .................................................................... 7 Convert a PDF file to Word file ........................................................................................................ 8 Convert a PDF file to .docx file ................................................................................................ 8 Convert a file to a TIFF file ............................................................................................................... 9 Convert PDF to Tiff .................................................................................................................. 9 Convert Microsoft Word (.docx) to Tiff ................................................................................... 9 Convert Microsoft Excel (.xlsx) to Tiff.................................................................................... 10 Convert Microsoft PowerPoint (.pptx) to Tiff........................................................................ 10 Convert Dicom to Tiff ............................................................................................................ 11 Convert JPEG to Tiff ............................................................................................................... 11 Create Tiff file with the specified Tiff page size .................................................................... 12 Create Tiff file with the specified Tiff compression method ................................................. 13 Convert a file to a JPEG file............................................................................................................ 14 Convert PDF to JPEG .............................................................................................................. 14 Convert Microsoft Word (.docx) to JPEG............................................................................... 14 Convert Microsoft Excel (.xlsx) to JPEG ................................................................................. 15 Convert Microsoft PowerPoint (.pptx) to JPEG ..................................................................... 15 Convert Tiff to JPEG ............................................................................................................... 16 Convert Dicom to JPEG .......................................................................................................... 16 Create JPEG with the specified JPEG resolution .................................................................... 17 Create JPEG with different horizontal, vertical resolutions .................................................. 17 Convert a file to SVG file................................................................................................................ 18 Convert PDF to SVG .............................................................................................................. 18 Convert Microsoft Word (.docx) to SVG ................................................................................ 18 Convert Microsoft Excel (.xlsx) to SVG .................................................................................. 19 Convert Microsoft PowerPoint (.pptx) to SVG ...................................................................... 19 Convert Tiff to SVG ............................................................................................................... 20 Convert Dicom to SVG ........................................................................................................... 20 Convert JPEG to SVG.............................................................................................................. 21 Convert a file to HTML file ............................................................................................................ 22 Convert PDF to HTML ........................................................................................................... 22 Convert Microsoft Word (.docx) to HTML ............................................................................. 22 Convert Microsoft Excel (.xlsx) to HTML ............................................................................... 22 Convert Microsoft PowerPoint (.pptx) to HTML ................................................................... 23 Convert Tiff to HTML ............................................................................................................ 23 Convert Dicom to HTML ........................................................................................................ 23 Convert JPEG to HTML .......................................................................................................... 24 Scan and Extract Text Content from a file, Output to TEXT File.................................................... 25 Extract Text Content from Tiff, Output to TXT File................................................................ 25 Extract Text Content from Scanned PDF, Output to TXT File ................................................ 25 Extract Text Content from Scanned Word, Output to TEXT File ........................................... 26 Print a document file ..................................................................................................................... 27 Select an available printer to print ........................................................................................ 27 Print all pages in a file............................................................................................................ 27 Print a range of pages in a file ............................................................................................... 28 Convert a file to a PDF file Convert Microsoft Word (.docx) to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFilePath = Program.ROOT_PATH + "\\output.docx.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Microsoft Excel (.xlsx) to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFilePath = Program.ROOT_PATH + "\\output.xlsx.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Use conversion flags C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFilePath = Program.ROOT_PATH + "\\output.xlsx.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); // to define page size ops.UseDefaultPageSize = false; ops.PageWidth = 8F; ops.PageHeight = 5F; // divide into several pages with defined width and height ops.ShowExcelDivideSheet = true; // show the empty sheets ops.ShowExcelEmptySheet = true; DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Microsoft PowerPoint (.pptx) to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.pptx"; String outputFilePath = Program.ROOT_PATH + "\\output.pptx.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Tiff to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFilePath = Program.ROOT_PATH + "\\output.tif.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Dicom to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.dcm"; String outputFilePath = Program.ROOT_PATH + "\\output.dcm.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert JPEG to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.jpg"; String outputFilePath = Program.ROOT_PATH + "\\output.jpg.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); ConvertResult result = ImageConverter.ToDocument(inStream, outStream, ops); } } switch (result) { case ConvertResult.NO_ERROR: Console.WriteLine("Success"); break; case ConvertResult.FILE_TYPE_UNSUPPORT: Console.WriteLine("Fail: can not convert to PDF, file type unsupport"); break; case ConvertResult.FILE_TYPE_UNMATCH: Console.WriteLine("Fail: input file is not a document"); break; default: Console.WriteLine("Fail: unknown error"); break; } Create PDF file with the specified PDF page size From Image to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.jpg"; String outputFilePath = Program.ROOT_PATH + "\\output.jpg.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); // use given page size, 20 inches in width and 20 inches in height ops.UseDefaultPageSize = false; ops.PageWidth = 20F; ops.PageHeight = 20F; ConvertResult result = ImageConverter.ToDocument(inStream, outStream, ops); } } From Document (.tif, .docx, .xlsx, .pptx) to PDF C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFilePath = Program.ROOT_PATH + "\\output.tif.pdf"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_PDF); // use given page size, 20 inches in width and 20 inches in height ops.UseDefaultPageSize = false; ops.PageWidth = 20F; ops.PageHeight = 20F; DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert a PDF file to Word file Convert a PDF file to .docx file C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.docx"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_MSDOCX); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert a file to a TIFF file Convert PDF to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Microsoft Word (.docx) to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFilePath = Program.ROOT_PATH + "\\output.docx.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Microsoft Excel (.xlsx) to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFilePath = Program.ROOT_PATH + "\\output.xlsx.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); ConvertResult result = DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Microsoft PowerPoint (.pptx) to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.pptx"; String outputFilePath = Program.ROOT_PATH + "\\output.pptx.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert Dicom to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.dcm"; String outputFilePath = Program.ROOT_PATH + "\\output.dcm.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); ConvertResult result = DocumentConverter.ToDocument(inStream, outStream, ops); } } Convert JPEG to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.jpg"; String outputFilePath = Program.ROOT_PATH + "\\output.jpg.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); ConvertResult result = ImageConverter.ToDocument(inStream, outStream, ops); Console.WriteLine("Result: " + result.ToString()); } } Create Tiff file with the specified Tiff page size Convert Image to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.jpg"; String outputFilePath = Program.ROOT_PATH + "\\output.jpg.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); // use given page size, 20 inches in width and 20 inches in height ops.UseDefaultPageSize = false; ops.PageWidth = 20F; ops.PageHeight = 20F; ConvertResult result = ImageConverter.ToDocument(inStream, outStream, ops); } } Convert Document (.pdf, .docx, .xlsx, .pptx) to Tiff C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); // use given page size, 20 inches in width and 20 inches in height ops.UseDefaultPageSize = false; ops.PageWidth = 20F; ops.PageHeight = 20F; DocumentConverter.ToDocument(inStream, outStream, ops); } } Create Tiff file with the specified Tiff compression method C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TIFF); ops.CompressionMode = ImageCompress.CCITT1D; DocumentConverter.ToDocument(inStream, outStream, ops); } } ImageCompress available to TIFF ImageCompress CCITT1D Group3Fax Group4Fax PackBits JPEG Uncompressed Description CCITT 1D RLE CCITT Group 3 Fax Encoding CCITT Group 4 Fax Encoding PackBits JPEG (Default) Do not compress data Convert a file to a JPEG file Convert PDF to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Convert Microsoft Word (.docx) to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFilePath = Program.ROOT_PATH + "\\output.docx.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Convert Microsoft Excel (.xlsx) to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFilePath = Program.ROOT_PATH + "\\output.xlsx.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Convert Microsoft PowerPoint (.pptx) to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.pptx"; String outputFilePath = Program.ROOT_PATH + "\\output.pptx.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Convert Tiff to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFilePath = Program.ROOT_PATH + "\\output.tif.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Convert Dicom to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.dcm"; String outputFilePath = Program.ROOT_PATH + "\\output.dcm.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); DocumentConverter.ToImage(inStream, outStream, ops); } } Create JPEG with the specified JPEG resolution Convert Document (.pdf, .docx, .xlsx, .pptx, .tif) to JPEG C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); // render document page with resolution 300 dpi (for both horizontal and vertical) ops.UseDefaultResolution = false; ops.ResolutionX = 300F; ops.ResolutionY = 300F; DocumentConverter.ToImage(inStream, outStream, ops); } } Create JPEG with different horizontal, vertical resolutions C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.jpg"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { ImageSaveOption ops = new ImageSaveOption(FileType.IMG_JPEG); // render document page with 300 dpi in horizontal and 600 dpi in vertical ops.UseDefaultResolution = false; ops.ResolutionX = 300F; ops.ResolutionY = 600F; DocumentConverter.ToImage(inStream, outStream, ops); } } Convert a file to SVG file Convert PDF to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf "; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert Microsoft Word (.docx) to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert Microsoft Excel (.xlsx) to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert Microsoft PowerPoint (.pptx) to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.pptx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert Tiff to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert Dicom to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.dcm"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert JPEG to SVG C# String inputFilePath = Program.ROOT_PATH + "\\1.jpeg"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToSVG(inStream, outputFolder, RelativeType.SVG); } RelativeType SVG SVGEMBED SVGEMBEDFONT SVGEMBEDIMG Description SVG file without embed font and image SVG file with embed font and image SVG file with embed font SVG file with embed image Convert a file to HTML file Convert PDF to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf "; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Convert Microsoft Word (.docx) to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML } Convert Microsoft Excel (.xlsx) to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.xlsx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Convert Microsoft PowerPoint (.pptx) to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.pptx"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Convert Tiff to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Convert Dicom to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.dcm"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Convert JPEG to HTML C# String inputFilePath = Program.ROOT_PATH + "\\1.jpeg"; String outputFolder = Program.ROOT_PATH + "\\"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentConverter.ToHTML(inStream, outputFolder, RelativeType.HTML); } Scan and Extract Text Content from a file, Output to TEXT File Extract Text Content from Tiff, Output to TXT File C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; String outputFilePath = Program.ROOT_PATH + "\\output.tif.txt"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TXT); // set OCR source folder that required by OCR process ops.OcrSourcePath = Program.OCR_SOURCE_FOLDER; DocumentConverter.ToDocument(inStream, outStream, ops); } } Extract Text Content from Scanned PDF, Output to TXT File C# String inputFilePath = Program.ROOT_PATH + "\\1.pdf"; String outputFilePath = Program.ROOT_PATH + "\\output.pdf.txt"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TXT); // set OCR source folder that required by OCR process ops.OcrSourcePath = Program.OCR_SOURCE_FOLDER; DocumentConverter.ToDocument(inStream, outStream, ops); } } Extract Text Content from Scanned Word, Output to TEXT File C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; String outputFilePath = Program.ROOT_PATH + "\\output.docx.txt"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { using (FileStream outStream = File.Open(outputFilePath, FileMode.Create, FileAccess.ReadWrite)) { DocumentSaveOption ops = new DocumentSaveOption(FileType.DOC_TXT); // set OCR source folder that required by OCR process ops.OcrSourcePath = Program.OCR_SOURCE_FOLDER; DocumentConverter.ToDocument(inStream, outStream, ops); } } Print a document file Select an available printer to print C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentPrinterOption ops = new DocumentPrinterOption(); } // Get names of all available printers ListprinterNames = ops.GetAllPrinterNames(); if (printerNames == null || printerNames.Count == 0) throw new Exception("no printer is available"); // select the 1st printer in the list ops.PrinterName = printerNames[0]; DocumentPrinter.Print(inStream, ops); Print all pages in a file C# String inputFilePath = Program.ROOT_PATH + "\\1.tif"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { DocumentPrinter.Print(inStream, new DocumentPrinterOption()); } Print a range of pages in a file C# String inputFilePath = Program.ROOT_PATH + "\\1.docx"; using (Stream inStream = File.Open(inputFilePath, FileMode.Open, FileAccess.Read)) { // print the document from the 2nd page int startPageIndex = 1; // print totally 3 pages (page 2, 3 and 4) int pageCount = 3; DocumentPrinter.Print(inStream, startPageIndex, pageCount); }
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.5 Linearized : Yes Author : WANGQI Comments : Company : Create Date : 2017:04:10 23:42:47+08:00 Modify Date : 2017:04:10 23:42:54+08:00 Source Modified : D:20170410154238 Subject : Tagged PDF : Yes XMP Toolkit : Adobe XMP Core 5.6-c015 81.157285, 2014/12/12-00:43:15 Metadata Date : 2017:04:10 23:42:54+08:00 Creator Tool : Acrobat PDFMaker 15 for Word Document ID : uuid:516e00b0-bf82-4481-8e37-1fa5a5fa53b7 Instance ID : uuid:64006593-55cb-4608-ae05-fb9245d173a9 Format : application/pdf Title : Description : Creator : WANGQI Producer : Adobe PDF Library 15.0 Keywords : Page Layout : OneColumn Page Count : 28EXIF Metadata provided by EXIF.tools