public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX))
            {
                ViewInfoOptions options  = ViewInfoOptions.ForPngView(true);
                ViewInfo        viewInfo = viewer.GetViewInfo(options);

                foreach (Page page in viewInfo.Pages)
                {
                    Console.WriteLine($"Page: {page.Number}");
                    Console.WriteLine("Text lines/words/characters:");

                    foreach (Line line in page.Lines)
                    {
                        Console.WriteLine(line);
                        foreach (Word word in line.Words)
                        {
                            Console.WriteLine("\t" + word);
                            foreach (Character character in word.Characters)
                            {
                                Console.WriteLine("\t\t" + character);
                            }
                        }
                    }
                }
            }

            Console.WriteLine("\nDocument text extracted successfully.\n");
        }
Exemplo n.º 2
0
 public PngViewer(string filePath, IViewerCache cache, LoadOptions loadOptions, int pageNumber = -1, int newAngle = 0)
 {
     this.cache           = cache;
     this.filePath        = filePath;
     this.viewer          = new GroupDocs.Viewer.Viewer(filePath, loadOptions);
     this.pngViewOptions  = this.CreatePngViewOptions(pageNumber, newAngle);
     this.viewInfoOptions = ViewInfoOptions.FromPngViewOptions(this.pngViewOptions);
 }
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_PDF))
            {
                ViewInfo info = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView());

                Console.WriteLine(info);
            }

            Console.WriteLine("\nView info retrieved successfully.");
        }
        private PageDescriptionEntity GetPageDescritpionEntity(ICustomViewer customViewer, string documentGuid, int pageNumber, string fileCacheSubFolder)
        {
            PageDescriptionEntity page;

            customViewer.CreateCache();

            var viewInfo = customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());

            page = GetPageInfo(viewInfo.Pages[pageNumber - 1], Path.Combine(fileCacheSubFolder, "PagesInfo.xml"));
            page.SetData(GetPageContent(pageNumber, documentGuid, cachePath, false));

            return(page);
        }
Exemplo n.º 5
0
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_PDF))
            {
                ViewInfoOptions options = ViewInfoOptions.ForHtmlView();
                PdfViewInfo     info    = viewer.GetViewInfo(options) as PdfViewInfo;

                Console.WriteLine("Document type is: " + info.FileType);
                Console.WriteLine("Pages count: " + info.Pages.Count);
                Console.WriteLine("Printing allowed: " + info.PrintingAllowed);
            }

            Console.WriteLine("\nView info retrieved successfully.");
        }
Exemplo n.º 6
0
 private void GetDocumentInfo()
 {
     try
     {
         using (Viewer viewer = new Viewer(Path.Combine(StorageFolder, DocumentName), settings))
         {
             ViewInfo info = viewer.GetViewInfo(ViewInfoOptions.ForPngView(false));
             lblTotalPages.Text = info.Pages.Count.ToString();
         }
     }
     catch
     {
         // Do something
     }
 }
        private static void ReadFolders(Viewer viewer, string folder)
        {
            ViewInfoOptions options = ViewInfoOptions.ForHtmlView();

            options.ArchiveOptions.Folder = folder;

            ArchiveViewInfo viewInfo = viewer.GetViewInfo(options) as ArchiveViewInfo;

            foreach (string subFolder in viewInfo.Folders)
            {
                Console.WriteLine($" - {subFolder}");

                ReadFolders(viewer, subFolder);
            }
        }
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_MPP))
            {
                ProjectManagementViewInfo info = viewer.GetViewInfo(
                    ViewInfoOptions.ForHtmlView()) as ProjectManagementViewInfo;

                Console.WriteLine("Document type is: " + info.FileType);
                Console.WriteLine("Pages count: " + info.Pages.Count);
                Console.WriteLine("Project start date: {0}", info.StartDate);
                Console.WriteLine("Project end date: {0}", info.EndDate);
            }

            Console.WriteLine("\nView info retrieved successfully.");
        }
Exemplo n.º 9
0
        private List <string> GetDocumentPages(string file, string folderName, string userEmail, int currentPage)
        {
            List <string> lstOutput   = new List <string>();
            string        outfileName = "page_{0}";
            string        outPath     = AppSettings.OutputDirectory + folderName + "/" + outfileName;

            outPath = Path.GetFullPath(outPath).Replace('\\', '/');

            //currentPage = currentPage - 1;

            string imagePath = string.Format(outPath, currentPage) + ".png";

            if (!Directory.Exists(AppSettings.OutputDirectory + folderName))
            {
                Directory.CreateDirectory(AppSettings.OutputDirectory + folderName);
            }

            if (System.IO.File.Exists(imagePath) && currentPage > 1)
            {
                lstOutput.Add(imagePath);
                return(lstOutput);
            }

            int i = currentPage;

            // check Words product family
            try
            {
                //GroupDocs.Apps.API.Models.License.SetGroupDocsViewerLicense();

                PngViewOptions          options = new PngViewOptions(outPath + ".png");
                GroupDocs.Viewer.Viewer viewer  = new GroupDocs.Viewer.Viewer(AppSettings.WorkingDirectory + folderName + "/" + file);

                if (currentPage <= 1)
                {
                    lstOutput.Add(viewer.GetViewInfo(ViewInfoOptions.ForPngView(false)).Pages.Count.ToString());
                }

                viewer.View(options, new int[] { currentPage });
                lstOutput.Add(imagePath);

                return(lstOutput);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.THREE_SHEETS))
            {
                ViewInfoOptions viewInfoOptions = ViewInfoOptions.ForHtmlView();
                viewInfoOptions.SpreadsheetOptions = SpreadsheetOptions.ForOnePagePerSheet();

                ViewInfo viewInfo = viewer.GetViewInfo(viewInfoOptions);

                Console.WriteLine("Worksheets:");
                foreach (Page page in viewInfo.Pages)
                {
                    Console.WriteLine($" - Worksheet {page.Number} name '{page.Name}'");
                }
            }
        }
Exemplo n.º 11
0
        public static void Run()
        {
            string outputDirectory    = Utils.GetOutputDirectoryPath();
            string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.png");

            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DWG_WITH_LAYOUTS_AND_LAYERS))
            {
                ViewInfoOptions infoOptions = ViewInfoOptions.ForPngView(false);
                var             viewInfo    = viewer.GetViewInfo(infoOptions);

                // Get width and height
                int width  = viewInfo.Pages[0].Width;
                int height = viewInfo.Pages[0].Height;

                // Set tile width and height as a half of image total width
                int tileWidth  = width / 2;
                int tileHeight = height / 2;

                int pointX = 0;
                int pointY = 0;

                //Create image options and add four tiles, one for each quarter
                PngViewOptions options = new PngViewOptions(pageFilePathFormat);

                Tile tile = new Tile(pointX, pointY, tileWidth, tileHeight);
                options.CadOptions.Tiles.Add(tile);

                pointX += tileWidth;
                tile    = new Tile(pointX, pointY, tileWidth, tileHeight);
                options.CadOptions.Tiles.Add(tile);

                pointX  = 0;
                pointY += tileHeight;
                tile    = new Tile(pointX, pointY, tileWidth, tileHeight);
                options.CadOptions.Tiles.Add(tile);

                pointX += tileWidth;
                tile    = new Tile(pointX, pointY, tileWidth, tileHeight);
                options.CadOptions.Tiles.Add(tile);

                viewer.View(options);
            }

            Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
        }
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_ZIP_WITH_FOLDERS))
            {
                ViewInfo info = viewer.GetViewInfo(ViewInfoOptions.ForHtmlView());

                Console.WriteLine("File type: " + info.FileType);
                Console.WriteLine("Pages count: " + info.Pages.Count);

                Console.WriteLine("Folders: ");
                Console.WriteLine(" - /");

                string rootFolder = string.Empty;
                ReadFolders(viewer, rootFolder);
            }

            Console.WriteLine("\nView info retrieved successfully.");
        }
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_OST_SUBFOLDERS))
            {
                ViewInfoOptions options        = ViewInfoOptions.ForHtmlView();
                OutlookViewInfo rootFolderInfo = viewer.GetViewInfo(options)
                                                 as OutlookViewInfo;

                Console.WriteLine("File type is: " + rootFolderInfo.FileType);
                Console.WriteLine("Pages count: " + rootFolderInfo.Pages.Count);

                foreach (string folder in rootFolderInfo.Folders)
                {
                    Console.WriteLine(folder);
                }
            }

            Console.WriteLine("\nView info retrieved successfully.");
        }
        public static void Run()
        {
            string outputDirectory    = Utils.GetOutputDirectoryPath();
            string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");

            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_MPP))
            {
                HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);

                ProjectManagementViewInfo viewInfo =
                    viewer.GetViewInfo(ViewInfoOptions.FromHtmlViewOptions(options)) as ProjectManagementViewInfo;

                options.ProjectManagementOptions.StartDate = viewInfo.StartDate;
                options.ProjectManagementOptions.EndDate   = viewInfo.StartDate.AddDays(7);

                viewer.View(options);
            }

            Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}.");
        }
        public IActionResult OnPost(string FileName)
        {
            int    pageCount        = 0;
            string imageFilesFolder = Path.Combine(outputPath, Path.GetFileName(FileName).Replace(".", "_"));

            if (!Directory.Exists(imageFilesFolder))
            {
                Directory.CreateDirectory(imageFilesFolder);
            }
            string imageFilesPath = Path.Combine(imageFilesFolder, "page-{0}.png");

            using (Viewer viewer = new Viewer(Path.Combine(storagePath, FileName)))
            {
                ViewInfo info = viewer.GetViewInfo(ViewInfoOptions.ForPngView(false));
                pageCount = info.Pages.Count;

                PngViewOptions options = new PngViewOptions(imageFilesPath);
                viewer.View(options);
            }
            return(new JsonResult(pageCount));
        }
        public static void Run()
        {
            using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DWG_WITH_LAYOUTS_AND_LAYERS))
            {
                CadViewInfo info = viewer.GetViewInfo(
                    ViewInfoOptions.ForHtmlView()) as CadViewInfo;

                Console.WriteLine("Document type is: " + info.FileType);
                Console.WriteLine("Pages count: " + info.Pages.Count);

                foreach (Layout layout in info.Layouts)
                {
                    Console.WriteLine(layout);
                }

                foreach (Layer layer in info.Layers)
                {
                    Console.WriteLine(layer);
                }
            }

            Console.WriteLine("\nCAD info obtained successfully.");
        }
        private static LoadDocumentEntity GetLoadDocumentEntity(bool loadAllPages, string documentGuid, string fileCacheSubFolder, ICustomViewer customViewer, bool printVersion)
        {
            if (loadAllPages)
            {
                customViewer.CreateCache();
            }

            dynamic            viewInfo           = customViewer.GetViewer().GetViewInfo(ViewInfoOptions.ForHtmlView());
            LoadDocumentEntity loadDocumentEntity = new LoadDocumentEntity();

            if (!Directory.Exists(cachePath))
            {
                Directory.CreateDirectory(cachePath);
            }

            string pagesInfoPath;

            TryCreatePagesInfoXml(fileCacheSubFolder, viewInfo, out pagesInfoPath);

            foreach (Page page in viewInfo.Pages)
            {
                PageDescriptionEntity pageData = GetPageInfo(page, pagesInfoPath);
                if (loadAllPages)
                {
                    pageData.SetData(GetPageContent(page.Number, documentGuid, cachePath, printVersion));
                }

                loadDocumentEntity.SetPages(pageData);
            }

            loadDocumentEntity.SetGuid(documentGuid);
            return(loadDocumentEntity);
        }