/// <summary> /// Add Watermark to Html page representation /// </summary> public static void Add_Watermark_For_Html() { Console.WriteLine("***** {0} *****", "Add Watermark to Html page representation"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; HtmlOptions options = new HtmlOptions(); // Set watermark properties Watermark watermark = new Watermark("This is watermark text"); watermark.Color = System.Drawing.Color.Blue; watermark.Position = WatermarkPosition.Diagonal; watermark.Width = 100; options.Watermark = watermark; // Get document pages html representation with watermark List<PageHtml> pages = htmlHandler.GetPages(guid, options); }
/// <summary> /// Render simple document in image representation /// </summary> /// <param name="DocumentName">File name</param> /// <param name="DocumentPassword">Optional</param> public static void RenderDocumentAsImages(String DocumentName, String DocumentPassword = null) { //ExStart:RenderAsImage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImage }
/// <summary> /// Render simple document in html representation /// </summary> /// <param name="DocumentName">File name</param> /// <param name="DocumentPassword">Optional</param> public static void RenderDocumentAsHtml(String DocumentName, String DocumentPassword = null) { //ExStart:RenderAsHtml //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); // Guid implies that unique document name string guid = DocumentName; //Instantiate the HtmlOptions object HtmlOptions options = new HtmlOptions(); //to get html representations of pages with embedded resources options.IsResourcesEmbedded = true; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // options.PageNumbersToConvert = Enumerable.Range(1, 3).ToList(); //Get document pages in html form List <PageHtml> pages = htmlHandler.GetPages(guid, options); foreach (PageHtml page in pages) { //Save each page at disk Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent); } //ExEnd:RenderAsHtml }
public KeyPresserPanel(KeyPresser plugin) { InitializeComponent(); mPlugin = plugin; mConfig = plugin.Config as ViewerConfig; mPlugin.Started += () => { if (InvokeRequired) { Invoke(new Action(() => startButton.Text = "Stop")); } else { startButton.Text = "Stop"; } }; mPlugin.Stopped += () => { if (InvokeRequired) { Invoke(new Action(() => startButton.Text = "Start")); } else { startButton.Text = "Start"; } }; intervalS.Value = new Decimal(mConfig.IntervalMS / 1000); stopM.Value = new Decimal(mConfig.StopM); shutdownBox.Checked = mConfig.AutoShutdown; key.Text = mConfig.Key; }
/// <summary> /// Get document html representation /// </summary> public static void Get_Html_With_Resources() { Console.WriteLine("***** {0} *****", "Get document html representation"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; List<PageHtml> pages = htmlHandler.GetPages(guid); foreach (PageHtml page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); Console.WriteLine("Resources count: {0}", page.HtmlResources.Count); Console.WriteLine("Html content: {0}", page.HtmlContent); // Html resources descriptions foreach (HtmlResource resource in page.HtmlResources) { Console.WriteLine(resource.ResourceName, resource.ResourceType); // Get html page resource stream Stream resourceStream = htmlHandler.GetResource(guid, resource); } } }
/// <summary> /// Render document in html representation with watermark /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="WatermarkText">watermark text</param> /// <param name="WatermarkColor"> System.Drawing.Color</param> /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param> /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsHtml(String DocumentName, String WatermarkText, Color WatermarkColor, WatermarkPosition position = WatermarkPosition.Diagonal, int WatermarkWidth = 100, String DocumentPassword = null) { //ExStart:RenderAsHtmlWithWaterMark //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); // Guid implies that unique document name string guid = DocumentName; //Instantiate the HtmlOptions object HtmlOptions options = new HtmlOptions(); options.IsResourcesEmbedded = false; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // Call AddWatermark and pass the reference of HtmlOptions object as 1st parameter Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, position, WatermarkWidth); //Get document pages in html form List <PageHtml> pages = htmlHandler.GetPages(guid, options); foreach (PageHtml page in pages) { //Save each page at disk Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent); } //ExEnd:RenderAsHtmlWithWaterMark }
/// <summary> /// Render a document in html representation whom located at web/remote location. /// </summary> /// <param name="DocumentURL">URL of the document</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsHtml(Uri DocumentURL, String DocumentPassword = null) { //ExStart:RenderRemoteDocAsHtml //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); //Instantiate the HtmlOptions object HtmlOptions options = new HtmlOptions(); if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Get document pages in html form List <PageHtml> pages = htmlHandler.GetPages(DocumentURL, options); foreach (PageHtml page in pages) { //Save each page at disk Utilities.SaveAsHtml(page.PageNumber + "_" + Path.GetFileName(DocumentURL.LocalPath), page.HtmlContent); } //ExEnd:RenderRemoteDocAsHtml }
public override async void Execute() { if (path.Filename == null) // set proposed filename from equations { path.InitFromEquations(models); } var ofd = new OpenFileDialog { Filter = "ICFG (*.icfg)|*.icfg", InitialDirectory = path.Directory, FileName = path.Filename }; if (ofd.ShowDialog(models.Window.TopmostWindow) != true) { return; } path.UpdateFromFilename(ofd.FileName); try { var cfg = ViewerConfig.LoadFromFile(ofd.FileName); await cfg.ApplyToModels(models); } catch (Exception e) { models.Window.ShowErrorDialog(e, "Could not load config"); } }
/// <summary> /// How to use custom input data handler /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "How to use custom input data handler"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // File guid string guid = @"word.doc"; // Use custom IInputDataHandler implementation IInputDataHandler inputDataHandler = new FtpInputDataHandler(); // Get file HTML representation ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config, inputDataHandler); List<PageHtml> pages = htmlHandler.GetPages(guid); Console.WriteLine("Pages count: {0}", pages.Count); // Get list of entities for ftp root folder FileTreeOptions options = new FileTreeOptions(@"ftp://localhost"); FileTreeContainer container = htmlHandler.LoadFileTree(options); }
private async void DxHostOnDrop(object sender, DragEventArgs e) { if (!e.Data.GetDataPresent(DataFormats.FileDrop)) { return; } string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (files == null) { return; } foreach (var file in files) { if (file.EndsWith(".icfg")) { var cfg = ViewerConfig.LoadFromFile(file); await cfg.ApplyToModels(models); } else { await import.ImportImageAsync(file); } } }
/// <summary> /// Get attached file's image representation /// </summary> /// <param name="DocumentName">Input document name</param> public static void GetEmailAttachmentImageRepresentation(String DocumentName) { try { //ExStart:GetEmailAttachmentImageRepresentation // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Init viewer image handler ViewerImageHandler handler = new ViewerImageHandler(config); DocumentInfoContainer info = handler.GetDocumentInfo(DocumentName); // Iterate over the attachments collection foreach (AttachmentBase attachment in info.Attachments) { Console.WriteLine("Attach name: {0}, size: {1}", attachment.Name, attachment.FileType); // Get attachment document image representation List <PageImage> pages = handler.GetPages(attachment); foreach (PageImage page in pages) { Console.WriteLine(" Page: {0}, size: {1}", page.PageNumber, page.Stream.Length); } } //ExEnd:GetEmailAttachmentImageRepresentation } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
public void Init(Core core) { mCore = core; mMainController = mCore.GetPlugin <OpenSimController>(); mMainController.ClientLoginComplete += new EventHandler(mMainController_CLientLoginComplete); mCore.ControlMode = mConfig.Mode; if (mCore.HasPlugin <ClientRecorderPlugin>()) { mRecorder = mCore.GetPlugin <ClientRecorderPlugin>(); } if (!mConfig.SettingsLoaderEnabled || !mCore.HasPlugin <SettingLoaderPlugin>()) { Logger.Info("Setting Settings file: " + mConfig.SettingsFile + "."); } Logger.Info("Setting Region: " + mConfig.Region + "."); foreach (var frame in core.Frames) { ViewerConfig config = (frame.Output as OpenSimController).Config as ViewerConfig; if (!mConfig.SettingsLoaderEnabled || !mCore.HasPlugin <SettingLoaderPlugin>()) { SettingLoaderPlugin.ReplaceSettingsFile(config, mConfig.SettingsFile, mConfig, Logger); } config.ViewerArguments += " --set LoginLocation \"" + mConfig.Region + "\""; } LoadTargets(); }
public static void InImageRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set image options to show grid lines ImageOptions options = new ImageOptions(); options.CellsOptions.ShowHiddenSheets = true; DocumentInfoContainer container = imageHandler.GetDocumentInfo(new DocumentInfoOptions(guid)); foreach (PageData page in container.Pages) Console.WriteLine("Page number: {0}, Page Name: {1}, IsVisible: {2}", page.Number, page.Name, page.IsVisible); List<PageImage> pages = imageHandler.GetPages(guid, options); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
public void OpenDocument(Uri documentUri, string password, ViewerConfig config, FragmentManager manager) { base.SetDocumentUri(documentUri); base.SetPassword(password); base.SetViewerConfig(config); base.SetSupportFragmentManager(manager); }
/// <summary> /// Render a document in image representation whom located at web/remote location. /// </summary> /// <param name="DocumentURL">URL of the document</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsImages(Uri DocumentURL, String DocumentPassword = null) { //ExStart:RenderRemoteDocAsImages //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(DocumentURL, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + Path.GetFileName(DocumentURL.LocalPath), image.Stream); } //ExEnd:RenderRemoteDocAsImages }
public KeyPresserPanel(KeyPresser plugin) { InitializeComponent(); mPlugin = plugin; mConfig = plugin.Config as ViewerConfig; mPlugin.Started += () => { if (InvokeRequired) Invoke(new Action(() => startButton.Text = "Stop")); else startButton.Text = "Stop"; }; mPlugin.Stopped += () => { if (InvokeRequired) Invoke(new Action(() => startButton.Text = "Start")); else startButton.Text = "Start"; }; intervalS.Value = new Decimal(mConfig.IntervalMS / 1000); stopM.Value = new Decimal(mConfig.StopM); shutdownBox.Checked = mConfig.AutoShutdown; key.Text = mConfig.Key; }
/// <summary> /// Render document in image representation with watermark /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="WatermarkText">watermark text</param> /// <param name="WatermarkColor"> System.Drawing.Color</param> /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param> /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static void RenderDocumentAsImages(String DocumentName, String WatermarkText, Color WatermarkColor, WatermarkPosition position = WatermarkPosition.Diagonal, int WatermarkWidth = 100, String DocumentPassword = null) { //ExStart:RenderAsImageWithWaterMark //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // Call AddWatermark and pass the reference of ImageOptions object as 1st parameter Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, position, WatermarkWidth); //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); foreach (PageImage image in Images) { //Save each image at disk Utilities.SaveAsImage(image.PageNumber + "_" + DocumentName, image.Stream); } //ExEnd:RenderAsImageWithWaterMark }
/// <summary> /// Get document html representation with embedded resources /// </summary> public static void Get_Html_EmbeddedResources() { Console.WriteLine("***** {0} *****", "Get document html representation with embedded resources"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; HtmlOptions options = new HtmlOptions(); options.IsResourcesEmbedded = true; List<PageHtml> pages = htmlHandler.GetPages(guid, options); foreach (PageHtml page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); Console.WriteLine("Html content: {0}", page.HtmlContent); } }
protected void Page_Load(object sender, EventArgs e) { var htmlConfig = new ViewerConfig { StoragePath = _storagePath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); var imageConfig = new ViewerConfig { StoragePath = _storagePath, UseCache = true, UsePdf = true }; _imageHandler = new ViewerImageHandler(imageConfig); HttpContext.Current.Session["imageHandler"] = _imageHandler; HttpContext.Current.Session["htmlHandler"] = _htmlHandler; // _streams.Add("Stream1.pdf", HttpWebRequest.Create("http://unfccc.int/resource/docs/convkp/kpeng.pdf").GetResponse().GetResponseStream()); //_streams.Add("StreamExample_2.doc", HttpWebRequest.Create("http://www.acm.org/sigs/publications/pubform.doc").GetResponse().GetResponseStream()); }
public static void InHtmlRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "document.xlsx"; // Set html options to show grid lines HtmlOptions options = new HtmlOptions(); options.CellsOptions.ShowHiddenSheets = true; DocumentInfoContainer container = htmlHandler.GetDocumentInfo(new DocumentInfoOptions(guid)); foreach (PageData page in container.Pages) Console.WriteLine("Page number: {0}, Page Name: {1}, IsVisible: {2}", page.Number, page.Name, page.IsVisible); List<PageHtml> pages = htmlHandler.GetPages(guid, options); foreach (PageHtml page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); //Console.WriteLine("Html content: {0}", page.HtmlContent); } }
/// <summary> /// Get Document Information /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get Document Information"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string documentName = "word.doc"; // Get document information DocumentInfoOptions options = new DocumentInfoOptions(documentName); DocumentInfoContainer documentInfo = htmlHandler.GetDocumentInfo(options); Console.WriteLine("DateCreated: {0}", documentInfo.DateCreated); Console.WriteLine("DocumentType: {0}", documentInfo.DocumentType); Console.WriteLine("Extension: {0}", documentInfo.Extension); Console.WriteLine("FileType: {0}", documentInfo.FileType); Console.WriteLine("Guid: {0}", documentInfo.Guid); Console.WriteLine("LastModificationDate: {0}", documentInfo.LastModificationDate); Console.WriteLine("Name: {0}", documentInfo.Name); Console.WriteLine("PageCount: {0}", documentInfo.Pages.Count); Console.WriteLine("Size: {0}", documentInfo.Size); foreach (PageData pageData in documentInfo.Pages) { Console.WriteLine("Page number: {0}", pageData.Number); Console.WriteLine("Page name: {0}", pageData.Name); } }
/// <summary> /// Set custom fonts directory path /// </summary> /// <param name="DocumentName">Input document name</param> public static void SetCustomFontDirectory(String DocumentName) { try { //ExStart:SetCustomFontDirectory // Setup GroupDocs.Viewer config ViewerConfig config = Utilities.GetConfigurations(); // Add custom fonts directories to FontDirectories list config.FontDirectories.Add(@"/usr/admin/Fonts"); config.FontDirectories.Add(@"/home/admin/Fonts"); ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); // File guid string guid = DocumentName; List <PageHtml> pages = htmlHandler.GetPages(guid); foreach (PageHtml page in pages) { //Save each page at disk Utilities.SaveAsHtml(page.PageNumber + "_" + DocumentName, page.HtmlContent); } //ExEnd:SetCustomFontDirectory } catch (System.Exception exp) { Console.WriteLine(exp.Message); } }
private ViewerConfig LoadConfig(string configFile) { if (string.IsNullOrWhiteSpace(configFile) || !File.Exists(configFile)) { string userFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); userFolder = Path.Combine(userFolder, "Mzinga"); if (!Directory.Exists(userFolder)) { Directory.CreateDirectory(userFolder); } configFile = Path.Combine(userFolder, "Mzinga.Viewer.xml"); } using (FileStream inputStream = new FileStream(configFile, FileMode.OpenOrCreate)) { ViewerConfig viewerConfig = new ViewerConfig(); try { viewerConfig.LoadConfig(inputStream); } catch (Exception) { } _configFile = configFile; return(viewerConfig); } }
public HttpResponseMessage loadFileTree(PostedDataWrapper postedData) { String relDirPath = ""; // get posted data if (postedData != null) { relDirPath = postedData.path; } // get file list from storage path FileListOptions fileListOptions = new FileListOptions(relDirPath); // get temp directory name String tempDirectoryName = new ViewerConfig().CacheFolderName; try { FileListContainer fileListContainer = viewerHtmlHandler.GetFileList(fileListOptions); List <FileDescriptionWrapper> fileList = new List <FileDescriptionWrapper>(); // parse files/folders list foreach (FileDescription fd in fileListContainer.Files) { FileDescriptionWrapper fileDescription = new FileDescriptionWrapper(); fileDescription.guid = fd.Guid; // check if current file/folder is temp directory or is hidden if (tempDirectoryName.Equals(fd.Name) || new FileInfo(fileDescription.guid).Attributes.HasFlag(FileAttributes.Hidden)) { // ignore current file and skip to next one continue; } else { // set file/folder name fileDescription.name = fd.Name; } // set file type fileDescription.docType = fd.DocumentType; // set is directory true/false fileDescription.isDirectory = fd.IsDirectory; // set file size fileDescription.size = fd.Size; // add object to array list fileList.Add(fileDescription); } return(Request.CreateResponse(HttpStatusCode.OK, fileList)); } catch (Exception ex) { // set exception message ErrorMsgWrapper errorMsgWrapper = new ErrorMsgWrapper(); errorMsgWrapper.message = ex.Message; errorMsgWrapper.exception = ex; return(Request.CreateResponse(HttpStatusCode.OK, errorMsgWrapper)); } }
static void Main(string[] args) { SetLicense(); string executionDirectory = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location); ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.StoragePath = executionDirectory; viewerConfig.UsePdf = true; ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig); string guid = "Resources\\sample.pdf"; DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(guid); DocumentInfoContainer documentInfoContainer = viewerImageHandler.GetDocumentInfo(documentInfoOptions); foreach (PageData pageData in documentInfoContainer.Pages) { Console.WriteLine("Page number: " + pageData.Number); for (int i = 0; i < pageData.Rows.Count; i++) { RowData rowData = pageData.Rows[i]; Console.WriteLine("Row: " + (i + 1)); Console.WriteLine("Text: " + rowData.Text); Console.WriteLine("Text width: " + rowData.LineWidth); Console.WriteLine("Text height: " + rowData.LineHeight); Console.WriteLine("Distance from left: " + rowData.LineLeft); Console.WriteLine("Distance from top: " + rowData.LineTop); string[] words = rowData.Text.Split(' '); for (int j = 0; j < words.Length; j++) { int coordinateIndex = j == 0 ? 0 : j + 1; Console.WriteLine(string.Empty); Console.WriteLine("Word: '" + words[j] + "'"); Console.WriteLine("Word distance from left: " + rowData.TextCoordinates[coordinateIndex]); Console.WriteLine("Word width: " + rowData.TextCoordinates[coordinateIndex + 1]); Console.WriteLine(string.Empty); } } Console.WriteLine(string.Empty); } Console.ReadKey(); }
public static void Run() { // Setup viewer config ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.StoragePath = @"c:\\storage"; viewerConfig.LocalesPath = @"c:\\locales"; // Create html handler CultureInfo cultureInfo = new CultureInfo("fr-FR"); ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(viewerConfig, cultureInfo); }
public static ViewerConfig CreateViewerConfig() { ViewerConfig cfg = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = false }; return(cfg); }
public override void Execute() { // show export dialog var dia = new ExportConfigDialog(viewModel); if (models.Window.ShowDialog(dia) != true) { return; } Debug.Assert(viewModel.IsValid); if (path.Filename == null) // set proposed filename from equations { path.InitFromEquations(models); } // make sure that the directory exists path.CreateDirectory(); var sfd = new SaveFileDialog { Filter = "ICFG (*.icfg)|*.icfg", InitialDirectory = path.Directory, FileName = path.Filename }; if (sfd.ShowDialog(models.Window.TopmostWindow) != true) { return; } try { var cfg = ViewerConfig.LoadFromModels(models, viewModel.UsedComponents); if (cfg.Images != null) { cfg.Images.ImportMode = viewModel.ImageImportMode; } if (cfg.Filter != null) { cfg.Filter.ImportMode = viewModel.FilterImportMode; } path.UpdateFromFilename(sfd.FileName); cfg.WriteToFile(path.FullPath); } catch (Exception e) { models.Window.ShowErrorDialog(e, "Could not save config"); } }
public ViewerController() { _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); _imageHandler = new ViewerImageHandler(_config); }
/// <summary> /// Initialize, populate and return the ViewerConfig object /// </summary> /// <param name="DefaultFontName">Font Name</param> /// <returns>Populated ViewerConfig Object</returns> public static ViewerConfig GetConfigurations(string DefaultFontName) { //ExStart:ConfigurationsWithDefaultFontName ViewerConfig config = new ViewerConfig(); //set the storage path config.StoragePath = STORAGE_PATH; //Uncomment the below line for cache purpose //config.UseCache = true; return(config); //ExEnd:ConfigurationsWithDefaultFontName }
/// <summary> /// Initialize, populate and return the ViewerConfig object /// </summary> /// <returns>Populated ViewerConfig Object</returns> public static ViewerConfig GetConfigurations() { //ExStart:Configurations ViewerConfig config = new ViewerConfig(); //set the storage path config.StoragePath = StoragePath; //Uncomment the below line for cache purpose config.UseCache = true; return(config); //ExEnd:Configurations }
/// <summary> /// Initialize, populate and return the ViewerConfig object /// </summary> /// <returns>Populated ViewerConfig Object</returns> public static ViewerConfig GetConfigurations() { //ExStart:Configurations ViewerConfig config = new ViewerConfig(); //set the storage path config.StoragePath = StoragePath; //Uncomment the below line for cache purpose config.EnableCaching = true; config.CacheFolderName = "cachefolder"; return(config); //ExEnd:Configurations }
/// <summary> /// document in image representation and reorder a page /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="CurrentPageNumber">Page existing order number</param> /// <param name="NewPageNumber">Page new order number</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static List <ImageInfo> RenderDocumentAsImages(String DocumentName, int CurrentPageNumber, int NewPageNumber, String DocumentPassword = null) { //ExStart:RenderAsImageAndReorderPage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Cast ViewerHtmlHandler class object to its base class(ViewerHandler). ViewerHandler <PageImage> handler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object and setting Reorder Transformation ImageOptions options = new ImageOptions { Transformations = Transformation.Reorder }; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call ReorderPage and pass the reference of ViewerHandler's class parameter by reference. Utilities.PageTransformations.ReorderPage(ref handler, guid, CurrentPageNumber, NewPageNumber); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerImageHandler imageHandler = (ViewerImageHandler)handler; //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); List <ImageInfo> contents = new List <ImageInfo>(); foreach (PageImage image in Images) { string imgname = image.PageNumber + "_" + Path.GetFileNameWithoutExtension(DocumentName); imgname = Regex.Replace(imgname, @"\s+", "_"); Utilities.SaveAsImage(Path.GetDirectoryName(DocumentName), imgname, image.Stream); ImageInfo imageInfo = new ImageInfo(); imageInfo.ImageUrl = @"/Uploads/images/" + imgname + ".jpg?" + Guid.NewGuid().ToString(); imageInfo.PageNmber = image.PageNumber; imageInfo.HtmlContent = @"<div class='image_page'><img src='" + imageInfo.ImageUrl + "' /></div>"; contents.Add(imageInfo); } return(contents); //ExEnd:RenderAsImageAndReorderPage }
public HomeController() { LicenseHelper.SetGroupDocsViewerLicense(); _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); //_imageHandler = new ViewerImageHandler(_config); }
public static void Reorder_Pages_In_Html_Mode() { Console.WriteLine("***** {0} *****", "Reorder pages in Html mode"); /* ********************* SAMPLE ********************* */ /* ******************** Reorder 1st and 2nd pages *********************** */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; int pageNumber = 1; int newPosition = 2; // Perform page reorder ReorderPageOptions options = new ReorderPageOptions(guid, pageNumber, newPosition); htmlHandler.ReorderPage(options); /* ******************** Retrieve all document pages including transformation *********************** */ // Set html options to include reorder transformations HtmlOptions htmlOptions = new HtmlOptions { Transformations = Transformation.Reorder }; // Get html representation of all document pages, including reorder transformations List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions); /* ******************** Retrieve all document pages excluding transformation *********************** */ // Set html options NOT to include ANY transformations HtmlOptions noTransformationsOptions = new HtmlOptions { Transformations = Transformation.None // This is by default }; // Get html representation of all document pages, without transformations List<PageHtml> pagesWithoutTransformations = htmlHandler.GetPages(guid, noTransformationsOptions); // Get html representation of all document pages, without transformations List<PageHtml> pagesWithoutTransformations2 = htmlHandler.GetPages(guid); }
private ViewerConfig LoadConfig() { using (FileStream inputStream = new FileStream(ViewerConfigPath, FileMode.OpenOrCreate)) { ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.InternalGameEngineConfig = InternalGameEngineConfig.GetOptionsClone(); // Create clone to store user values try { viewerConfig.LoadConfig(inputStream); } catch (Exception) { } return(viewerConfig); } }
/// <summary> /// document in html representation and reorder a page /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="CurrentPageNumber">Page existing order number</param> /// <param name="NewPageNumber">Page new order number</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static List <HtmlInfo> RenderDocumentAsHtml(String DocumentName, int CurrentPageNumber, int NewPageNumber, String DocumentPassword = null) { //ExStart:RenderAsHtmlAndReorderPage //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Cast ViewerHtmlHandler class object to its base class(ViewerHandler). ViewerHandler <PageHtml> handler = new ViewerHtmlHandler(config); // Guid implies that unique document name string guid = DocumentName; //Instantiate the HtmlOptions object with setting of Reorder Transformation HtmlOptions options = new HtmlOptions { Transformations = Transformation.Reorder }; //to get html representations of pages with embedded resources options.IsResourcesEmbedded = true; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call ReorderPage and pass the reference of ViewerHandler's class parameter by reference. Utilities.PageTransformations.ReorderPage(ref handler, guid, CurrentPageNumber, NewPageNumber); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerHtmlHandler htmlHandler = (ViewerHtmlHandler)handler; //Get document pages in html form List <PageHtml> pages = htmlHandler.GetPages(guid, options); List <HtmlInfo> contents = new List <HtmlInfo>(); foreach (PageHtml page in pages) { HtmlInfo htmlInfo = new HtmlInfo(); htmlInfo.HtmlContent = page.HtmlContent; htmlInfo.PageNmber = page.PageNumber; contents.Add(htmlInfo); } return(contents); //ExEnd:RenderAsHtmlAndReorderPage }
/// <summary> /// Render document in image representation with watermark /// </summary> /// <param name="DocumentName">file/document name</param> /// <param name="WatermarkText">watermark text</param> /// <param name="WatermarkColor"> System.Drawing.Color</param> /// <param name="position">Watermark Position is optional parameter. Default value is WatermarkPosition.Diagonal</param> /// <param name="WatermarkWidth"> width of watermark as integer. it is optional Parameter default value is 100</param> /// <param name="DocumentPassword">Password Parameter is optional</param> public static List <ImageInfo> RenderDocumentAsImages(String DocumentName, String WatermarkText, Color WatermarkColor, int WatermarkWidth = 100, String DocumentPassword = null) { //ExStart:RenderAsImageWithWaterMark //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object ImageOptions options = new ImageOptions(); // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } // Call AddWatermark and pass the reference of ImageOptions object as 1st parameter Utilities.PageTransformations.AddWatermark(ref options, WatermarkText, WatermarkColor, WatermarkPosition.Diagonal, WatermarkWidth); //Get document pages in image form List <PageImage> Images = imageHandler.GetPages(guid, options); List <ImageInfo> contents = new List <ImageInfo>(); foreach (PageImage image in Images) { string imgname = image.PageNumber + "_" + Path.GetFileNameWithoutExtension(DocumentName); imgname = Regex.Replace(imgname, @"\s+", "_"); Utilities.SaveAsImage(Path.GetDirectoryName(DocumentName), imgname, image.Stream); ImageInfo imageInfo = new ImageInfo(); imageInfo.ImageUrl = @"/Uploads/images/" + imgname + ".jpg?" + Guid.NewGuid().ToString(); imageInfo.PageNmber = image.PageNumber; imageInfo.HtmlContent = @"<div class='image_page'><img src='" + imageInfo.ImageUrl + "' /></div>"; contents.Add(imageInfo); } return(contents); //ExEnd:RenderAsImageWithWaterMark }
public static void Run() { //Initialize viewer config ViewerConfig viewerConfig = new ViewerConfig(); viewerConfig.StoragePath = "c:\\storage"; //Initialize viewer handler ViewerImageHandler viewerImageHandler = new ViewerImageHandler(viewerConfig); //Set encoding Encoding encoding = Encoding.GetEncoding("shift-jis"); //Set image options ImageOptions imageOptions = new ImageOptions(); imageOptions.WordsOptions.Encoding = encoding; imageOptions.CellsOptions.Encoding = encoding; imageOptions.EmailOptions.Encoding = encoding; //Get words document pages with encoding string wordsDocumentGuid = "document.txt"; List<PageImage> wordsDocumentPages = viewerImageHandler.GetPages(wordsDocumentGuid, imageOptions); //Get cells document pages with encoding string cellsDocumentGuid = "document.csv"; List<PageImage> cellsDocumentPages = viewerImageHandler.GetPages(cellsDocumentGuid, imageOptions); //Get email document pages with encoding string emailDocumentGuid = "document.msg"; List<PageImage> emailDocumentPages = viewerImageHandler.GetPages(emailDocumentGuid, imageOptions); //Get words document info with encoding DocumentInfoOptions wordsDocumentInfoOptions = new DocumentInfoOptions(wordsDocumentGuid); wordsDocumentInfoOptions.WordsDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer wordsDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(wordsDocumentInfoOptions); //Get cells document info with encoding DocumentInfoOptions cellsDocumentInfoOptions = new DocumentInfoOptions(cellsDocumentGuid); cellsDocumentInfoOptions.CellsDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer cellsDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(cellsDocumentInfoOptions); //Get email document info with encoding DocumentInfoOptions emailDocumentInfoOptions = new DocumentInfoOptions(emailDocumentGuid); emailDocumentInfoOptions.EmailDocumentInfoOptions.Encoding = encoding; DocumentInfoContainer emailDocumentInfoContainer = viewerImageHandler.GetDocumentInfo(emailDocumentInfoOptions); }
public static List <HtmlInfo> RotateDocumentAsHtml(String DocumentName, int pageNumber, int RotationAngle, String DocumentPassword = null) { //ExStart:RenderAsImageWithRotationTransformation //Get Configurations ViewerConfig config = Utilities.GetConfigurations(); // Create image handler ViewerHandler <PageHtml> handler = new ViewerHtmlHandler(config); // Guid implies that unique document name string guid = DocumentName; //Initialize ImageOptions Object and setting Rotate Transformation HtmlOptions options = new HtmlOptions { Transformations = Transformation.Rotate }; // Set password if document is password protected. if (!String.IsNullOrEmpty(DocumentPassword)) { options.Password = DocumentPassword; } //Call RotatePages to apply rotate transformation to a page Utilities.PageTransformations.RotatePages(ref handler, guid, pageNumber, RotationAngle); //down cast the handler(ViewerHandler) to viewerHtmlHandler ViewerHtmlHandler htmlHandler = (ViewerHtmlHandler)handler; //Get document pages in image form List <PageHtml> pages = htmlHandler.GetPages(guid, options); List <HtmlInfo> contents = new List <HtmlInfo>(); foreach (PageHtml page in pages) { HtmlInfo htmlInfo = new HtmlInfo(); htmlInfo.HtmlContent = page.HtmlContent; htmlInfo.PageNmber = page.PageNumber; contents.Add(htmlInfo); } return(contents); //ExEnd:RenderAsImageWithRotationTransformation }
public static void Run() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Get supported document formats DocumentFormatsContainer documentFormatsContainer = imageHandler.GetSupportedDocumentFormats(); Dictionary<string, string> supportedDocumentFormats = documentFormatsContainer.SupportedDocumentFormats; foreach (KeyValuePair<string, string> supportedDocumentFormat in supportedDocumentFormats) { Console.WriteLine(string.Format("Extension: '{0}'; Document format: '{1}'", supportedDocumentFormat.Key, supportedDocumentFormat.Value)); } }
/// <summary> /// Get document representation from Uri /// </summary> public static void Get_pages_from_Uri() { Console.WriteLine("***** {0} *****", "Get document representation from Uri"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); Uri uri = new Uri("http://groupdocs.com/images/banner/carousel2/signature.png"); // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(uri); Console.WriteLine("Page count: {0}", pages.Count); }
protected void Page_Load(object sender, EventArgs e) { License lic = new License(); lic.SetLicense("E:/GroupDocs.Total.lic"); _config = new ViewerConfig { StoragePath = _storagePath, TempPath = _tempPath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(_config); _imageHandler = new ViewerImageHandler(_config); HttpContext.Current.Session["imageHandler"] = _imageHandler; HttpContext.Current.Session["htmlHandler"] = _htmlHandler; }
/// <summary> /// Get original file /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get original file"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Get original file FileContainer container = imageHandler.GetFile(guid); Console.WriteLine("Stream lenght: {0}", container.Stream.Length); }
/// <summary> /// Get document html for print with watermark /// </summary> public static void Get_PrintableHtml_WithWatermark() { Console.WriteLine("***** {0} *****", "Get document html for print with watermark"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Get document html for print with watermark var options = new PrintableHtmlOptions(guid, new Watermark("Watermark text")); var container = imageHandler.GetPrintableHtml(options); Console.WriteLine("Html content: {0}", container.HtmlContent); }
/// <summary> /// Get document representation from relative path /// </summary> public static void Get_pages_relative_path() { Console.WriteLine("***** {0} *****", "Get document representation from relative path"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Set relative path. So that full path will be C:\storage\word.doc string guid = "word.doc"; // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(guid); Console.WriteLine("Page count: {0}", pages.Count); }
/// <summary> /// Get original file in Pdf format /// </summary> public static void Run() { Console.WriteLine("***** {0} *****", "Get original file in Pdf format"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); PdfFileOptions options = new PdfFileOptions(); options.Guid = "word.doc"; // Get file as pdf FileContainer container = imageHandler.GetPdfFile(options); Console.WriteLine("Stream lenght: {0}", container.Stream.Length); }
public static void InHtmlRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "document.xlsx"; // Set html options to show grid lines HtmlOptions options = new HtmlOptions(); options.CellsOptions.ShowGridLines = true; List<PageHtml> pages = htmlHandler.GetPages(guid, options); foreach (PageHtml page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); Console.WriteLine("Html content: {0}", page.HtmlContent); } }
public ViewerController() { var htmlConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true }; _htmlHandler = new ViewerHtmlHandler(htmlConfig); var imageConfig = new ViewerConfig { StoragePath = _storagePath, CachePath = _cachePath, UseCache = true, UsePdf = UsePdfInImageEngine }; _imageHandler = new ViewerImageHandler(imageConfig); }
/// <summary> /// Get document html for print with custom css /// </summary> public static void Get_PrintableHtml_WithCss() { Console.WriteLine("***** {0} *****", "Get document html for print with custom css"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; string css = "a { color: hotpink; }"; // Some style // Get document html for print with custom css var options = new PrintableHtmlOptions(guid, css); var container = imageHandler.GetPrintableHtml(options); Console.WriteLine("Html content: {0}", container.HtmlContent); }
public static void Run() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image or html handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set pdf file one page per sheet option to false, default value of this option is true PdfFileOptions pdfFileOptions = new PdfFileOptions(); pdfFileOptions.Guid = guid; pdfFileOptions.CellsOptions.OnePagePerSheet = false; //Get pdf file FileContainer fileContainer = imageHandler.GetPdfFile(pdfFileOptions); //The pdf file stream Stream pdfStream = fileContainer.Stream; }
/// <summary> /// Perform multiple transformations in Html mode /// </summary> public static void Multiple_Transformations_For_Html() { Console.WriteLine("***** {0} *****", "Perform multiple transformations in Html mode"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; // Rotate first page 90 degrees htmlHandler.RotatePage(new RotatePageOptions(guid, 1, 90)); // Rotate second page 180 degrees htmlHandler.RotatePage(new RotatePageOptions(guid, 2, 180)); // Reorder first and second pages htmlHandler.ReorderPage(new ReorderPageOptions(guid, 1, 2)); // Set options to include rotate and reorder transformations HtmlOptions options = new HtmlOptions { Transformations = Transformation.Rotate | Transformation.Reorder }; // Set watermark properties Watermark watermark = new Watermark("This is watermark text") { Color = System.Drawing.Color.Blue, Position = WatermarkPosition.Diagonal, Width = 100 }; options.Watermark = watermark; // Get document pages html representation with multiple transformations List<PageHtml> pages = htmlHandler.GetPages(guid, options); }
/// <summary> /// Load file tree list for custom path /// </summary> public static void LoadFileTree_CustomPath() { Console.WriteLine("***** {0} *****", "Load file tree list for custom path"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); // Load file tree list for custom path var options = new FileTreeOptions(@"D:\"); FileTreeContainer container = imageHandler.LoadFileTree(options); foreach (var node in container.FileTree) { if (node.IsDirectory) { Console.WriteLine("Guid: {0} | Name: {1} | LastModificationDate: {2}", node.Guid, node.Name, node.LastModificationDate); } else Console.WriteLine("Guid: {0} | Name: {1} | Document type: {2} | File type: {3} | Extension: {4} | Size: {5} | LastModificationDate: {6}", node.Guid, node.Name, node.DocumentType, node.FileType, node.Extension, node.Size, node.LastModificationDate); } }
/// <summary> /// Get document Image representation /// </summary> public static void Get_document_Image_representation() { Console.WriteLine("***** {0} *****", "Get document image representation"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; List<PageImage> pages = imageHandler.GetPages(guid); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
public static void InImageRepresentation() { // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "document.xlsx"; // Set image options to show grid lines ImageOptions options = new ImageOptions(); options.CellsOptions.ShowGridLines = true; List<PageImage> pages = imageHandler.GetPages(guid, options); foreach (PageImage page in pages) { Console.WriteLine("Page number: {0}", page.PageNumber); // Page image stream Stream imageContent = page.Stream; } }
/// <summary> /// Rotate page in Html mode /// </summary> public static void Rotate_Page_In_Html_Mode() { Console.WriteLine("***** {0} *****", "Rotate page in Html mode"); /* ********************* SAMPLE ********************* */ string licensePath = @"D:\GroupDocs.Viewer.lic"; // Setup license GroupDocs.Viewer.License lic = new GroupDocs.Viewer.License(); lic.SetLicense(licensePath); /* ******************** SAMPLE BEGIN ************************ */ /* ******************** Rotate 1st page of the document by 90 deg *********************** */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create html handler ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config); string guid = "word.doc"; // Set rotation angle 90 for page number 1 RotatePageOptions rotateOptions = new RotatePageOptions(guid, 1, 90); // Perform page rotation htmlHandler.RotatePage(rotateOptions); /* ******************** Retrieve all document pages including transformation *********************** */ // Set html options to include rotate transformations HtmlOptions htmlOptions = new HtmlOptions { Transformations = Transformation.Rotate }; // Get html representation of all document pages, including rotate transformations List<PageHtml> pages = htmlHandler.GetPages(guid, htmlOptions); /* ******************** Retrieve all document pages excluding transformation *********************** */ // Set html options NOT to include ANY transformations HtmlOptions noTransformationsOptions = new HtmlOptions { Transformations = Transformation.None // This is by default }; // Get html representation of all document pages, without transformations List<PageHtml> pagesWithoutTransformations = htmlHandler.GetPages(guid, noTransformationsOptions); // Get html representation of all document pages, without transformations List<PageHtml> pagesWithoutTransformations2 = htmlHandler.GetPages(guid); /********************* SAMPLE END *************************/ //foreach (PageHtml page in pages) //{ // // Page number // Console.WriteLine("Page number: {0}", page.PageNumber); //} }
/// <summary> /// Get document representation from Stream /// </summary> public static void Get_pages_from_stream() { Console.WriteLine("***** {0} *****", "Get document representation from Stream"); /* ********************* SAMPLE ********************* */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); using (FileStream fileStream = new FileStream(@"C:\storage\word.doc", FileMode.Open, FileAccess.Read)) { // Get pages by absolute path List<PageImage> pages = imageHandler.GetPages(fileStream, "word.doc"); Console.WriteLine("Page count: {0}", pages.Count); } }
/// <summary> /// Rotate page in Image mode /// </summary> public static void Rotate_page_in_Image_mode() { Console.WriteLine("***** {0} *****", "Rotate page in Image mode"); /* ********************* SAMPLE ********************* */ string licensePath = @"D:\GroupDocs.Viewer.lic"; // Setup license GroupDocs.Viewer.License lic = new GroupDocs.Viewer.License(); lic.SetLicense(licensePath); /* ******************** SAMPLE BEGIN *********************** */ /* ******************** Rotate 1st page of the document by 90 deg *********************** */ // Setup GroupDocs.Viewer config ViewerConfig config = new ViewerConfig(); config.StoragePath = @"C:\storage"; // Create image handler ViewerImageHandler imageHandler = new ViewerImageHandler(config); string guid = "word.doc"; // Set rotation angle 90 for page number 1 RotatePageOptions rotateOptions = new RotatePageOptions(guid, 1, 90); // Perform page rotation imageHandler.RotatePage(rotateOptions); /* ******************** Retrieve all document pages including transformation *********************** */ // Set image options to include rotate transformations ImageOptions imageOptions = new ImageOptions { Transformations = Transformation.Rotate }; // Get image representation of all document pages, including rotate transformations List<PageImage> pages = imageHandler.GetPages(guid, imageOptions); /* ******************** Retrieve all document pages excluding transformation *********************** */ // Set image options NOT to include ANY transformations ImageOptions noTransformationsOptions = new ImageOptions { Transformations = Transformation.None // This is by default }; // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations = imageHandler.GetPages(guid, noTransformationsOptions); // Get image representation of all document pages, without transformations List<PageImage> pagesWithoutTransformations2 = imageHandler.GetPages(guid); /********************* SAMPLE END *************************/ //foreach (PageImage page in pages) //{ // // Page number // Console.WriteLine("Page number: {0}", page.PageNumber); // // Page image stream // Stream imageContent = page.Stream; // using ( // FileStream file = new FileStream(string.Format(@"C:\{0}.png", page.PageNumber), // FileMode.Create, FileAccess.ReadWrite)) // { // MemoryStream xxx = new MemoryStream(); // page.Stream.CopyTo(xxx); // var arr = xxx.ToArray(); // file.Write(arr, 0, arr.Length); // } //} }