public byte[] ViewAsPngWithLoadOption(string filePath) { var extension = Path.GetExtension(filePath); var fileType = FileType.FromExtension(extension); var loadOptions = new LoadOptions(fileType); var bytes = File.ReadAllBytes(filePath); var stream = new MemoryStream(bytes); using (var viewer = new Viewer(stream, loadOptions)) { var pages = new List <MemoryStream>(); var streamFactory = new ByteArrayPageStreamFactory(); var options = new PngViewOptions(streamFactory); viewer.View(options); var imageByteArray = new List <byte[]>(); long len = 0; foreach (var page in streamFactory.Pages) { imageByteArray.Add(page); len += page.Length; } var byteArray = new byte[len]; long i = 0; foreach (var page in imageByteArray) { page.CopyTo(byteArray, i); i += page.Length; } return(byteArray); } }
public byte[] ViewAsPng(string filePath) { //List<MemoryStream> pages = new List<MemoryStream>(); //var streamFactory = new MemoryPageStreamFactory(pages); //using (Viewer viewer = new Viewer(filePath)) //{ // PngViewOptions options = new PngViewOptions(streamFactory); // viewer.View(options); // long len = 0; // foreach (var page in pages) // { // len += page.Length; // } // var byteArray = new byte[len]; // long i = 0; // foreach (var page in pages) // { // page.ToArray().CopyTo(byteArray, i); // i += page.Length; // } // return byteArray; //} var bytes = File.ReadAllBytes(filePath); var stream = new MemoryStream(bytes); using (var viewer = new Viewer(stream)) { var pages = new List <MemoryStream>(); var streamFactory = new MemoryPageStreamFactory(pages); var options = new PngViewOptions(streamFactory); viewer.View(options); var imageByteArray = new List <byte[]>(); foreach (var page in pages) { imageByteArray.Add(page.ToArray()); } long len = 0; foreach (var page in pages) { len += page.Length; } var byteArray = new byte[len]; long i = 0; foreach (var page in pages) { page.ToArray().CopyTo(byteArray, i); i += page.Length; } return(byteArray); } }
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() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "cmx_result_{0}.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CMX)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); viewer.View(options); // To render 2nd image, just specify //viewer.View(options,2); } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "cmx_result_{0}.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CMX)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); viewer.View(options); // To render 2nd image, just specify //viewer.View(options,2); } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "cmx_result_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CMX)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); viewer.View(options); // To render 2nd image, just specify //viewer.View(options,2); } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "cmx_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CMX)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); viewer.View(options); // By default all images will be rendered in output.pdf, to render only 2nd image in output PDF //viewer.View(options,2); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFileFullPath = Path.Combine(outputDirectory, "Txt_result.html"); // TO MULTI PAGES HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_TXT)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFileFullPath); viewer.View(options); } pageFileFullPath = Path.Combine(outputDirectory, "Txt_result_single_page.html"); // TO SINGLE HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_2_TXT)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFileFullPath); options.RenderToSinglePage = true; viewer.View(options); } // TO JPG pageFileFullPath = Path.Combine(outputDirectory, "Txt_result.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_TXT)) { JpgViewOptions options = new JpgViewOptions(pageFileFullPath); viewer.View(options); } // TO PNG pageFileFullPath = Path.Combine(outputDirectory, "Txt_result.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_TXT)) { PngViewOptions options = new PngViewOptions(pageFileFullPath); viewer.View(options); } // TO PDF pageFileFullPath = Path.Combine(outputDirectory, "Txt_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_TXT)) { PdfViewOptions options = new PdfViewOptions(pageFileFullPath); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "result_page.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); options.VisioRenderingOptions.RenderFiguresOnly = true; options.VisioRenderingOptions.FigureWidth = 250; viewer.View(options); } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); options.VisioRenderingOptions.RenderFiguresOnly = true; options.VisioRenderingOptions.FigureWidth = 250; viewer.View(options); } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); options.VisioRenderingOptions.RenderFiguresOnly = true; options.VisioRenderingOptions.FigureWidth = 250; viewer.View(options); } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "visio_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_VISIO)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); options.VisioRenderingOptions.RenderFiguresOnly = true; options.VisioRenderingOptions.FigureWidth = 250; viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_DOCX)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.html"); /* Because the XML extension is associated with both an XML text document and Excel 2003 XML SpreadSheetML, * please specify the Excel2003XML fileType explicitly to render it as Excel 2003 XML SpreadSheetML. */ LoadOptions loadOptions = new LoadOptions(FileType.Excel2003XML); // TO MULTI PAGES HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFileFullPath); viewer.View(options); } // TO JPG pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions)) { JpgViewOptions options = new JpgViewOptions(pageFileFullPath); viewer.View(options); } // TO PNG pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions)) { PngViewOptions options = new PngViewOptions(pageFileFullPath); viewer.View(options); } // TO PDF pageFileFullPath = Path.Combine(outputDirectory, "Excel_2003_Xml_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XML_SPREADSHEETML, loadOptions)) { PdfViewOptions options = new PdfViewOptions(pageFileFullPath); viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "chm_result_{0}.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); options.RenderToSinglePage = true; // Enable it if you want to convert all CHM content to single page //viewer.View(options,1,2,3); // Convert only 1,2,3 pages viewer.View(options); // Convert all pages } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "chm_result_{0}.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); viewer.View(options, 1, 2, 3); // Convert only 1,2,3 pages //viewer.View(options); // Convert all pages } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "chm_result_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); viewer.View(options, 1, 2, 3); // Convert only 1,2,3 pages //viewer.View(options); // Convert all pages } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "chm_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_CHM)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); viewer.View(options); // Convert all pages } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); options.SpreadsheetOptions.RenderHeadings = true; viewer.View(options, 1, 2, 3); } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); options.SpreadsheetOptions.RenderHeadings = true; viewer.View(options, 1, 2, 3); } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); options.SpreadsheetOptions.RenderHeadings = true; viewer.View(options, 1, 2, 3); } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "output.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_XLSX)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); options.SpreadsheetOptions.RenderHeadings = true; viewer.View(options, 1, 2, 3); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.HIEROGLYPHS_1_PDF)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); options.PdfOptions.EnableFontHinting = true; viewer.View(options, 1); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
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; } }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); viewer.View(options); } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); viewer.View(options); } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result_{0}.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); viewer.View(options); } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "RAR_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_RAR_WITH_FOLDERS)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); viewer.View(options); } GetViewInfoForRar(); RenderSpecificArchiveFolder(); Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
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)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); options.CadOptions = CadOptions.ForRenderingByWidth(800); options.CadOptions.BackgroundColor = System.Drawing.Color.Green; viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static string GetPage(string value) { int PageNumber = Convert.ToInt32(value); string PageFilePathFormat = Path.Combine(OutputPath, "img{0}.png"); using (Viewer viewer = new Viewer(Path.Combine(StorageFolder, DocumentName))) { PngViewOptions options = new PngViewOptions(PageFilePathFormat); options.Width = 750; options.Height = 450; viewer.View(options, PageNumber); } return(Path.Combine(@"output", string.Format("img{0}.png", PageNumber))); }
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}."); }
private PngViewOptions CreatePngViewOptions(int passedPageNumber = -1, int newAngle = 0) { PngViewOptions createdPngViewOptions = new PngViewOptions(pageNumber => { string fileName = $"p{pageNumber}.png"; string cacheFilePath = this.cache.GetCacheFilePath(fileName); return(File.Create(cacheFilePath)); }); if (passedPageNumber >= 0 && newAngle != 0) { Rotation rotationAngle = GetRotationByAngle(newAngle); createdPngViewOptions.RotatePage(passedPageNumber, rotationAngle); } SetWatermarkOptions(createdPngViewOptions); return(createdPngViewOptions); }
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() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "hpg_result.html"); // TO HTML using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HPG)) { HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat); //options.CadOptions = CadOptions.ForRenderingByScaleFactor(0.7f); // Render image and reduce it by 30% //options.CadOptions = CadOptions.ForRenderingByWidthAndHeight(400,400); // Render image and set output size to 400x400 //options.CadOptions = CadOptions.ForRenderingByWidth(500); // Render image, fix width by 500 px and recalculate height //options.CadOptions = CadOptions.ForRenderingByHeight(500); // Render image, fix height by 500 px and recalculate width viewer.View(options); } // TO JPG pageFilePathFormat = Path.Combine(outputDirectory, "hpg_result.jpg"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HPG)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); //options.CadOptions = CadOptions.ForRenderingByScaleFactor(0.7f); // Render image and reduce it by 30% //options.CadOptions = CadOptions.ForRenderingByWidthAndHeight(400,400); // Render image and set output size to 400x400 //options.CadOptions = CadOptions.ForRenderingByWidth(500); // Render image, fix width by 500 px and recalculate height //options.CadOptions = CadOptions.ForRenderingByHeight(500); // Render image, fix height by 500 px and recalculate width viewer.View(options); } // TO PNG pageFilePathFormat = Path.Combine(outputDirectory, "hpg_result.png"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HPG)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); //options.CadOptions = CadOptions.ForRenderingByScaleFactor(0.7f); // Render image and reduce it by 30% //options.CadOptions = CadOptions.ForRenderingByWidthAndHeight(400,400); // Render image and set output size to 400x400 //options.CadOptions = CadOptions.ForRenderingByWidth(500); // Render image, fix width by 500 px and recalculate height //options.CadOptions = CadOptions.ForRenderingByHeight(500); // Render image, fix height by 500 px and recalculate width viewer.View(options); } // TO PDF pageFilePathFormat = Path.Combine(outputDirectory, "hpg_result.pdf"); using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HPG)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); //options.CadOptions = CadOptions.ForRenderingByScaleFactor(0.7f); // Render image and reduce it by 30% //options.CadOptions = CadOptions.ForRenderingByWidthAndHeight(400,400); // Render image and set output size to 400x400 //options.CadOptions = CadOptions.ForRenderingByWidth(500); // Render image, fix width by 500 px and recalculate height //options.CadOptions = CadOptions.ForRenderingByHeight(500); // Render image, fix height by 500 px and recalculate width viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }
public static void Run() { string outputDirectory = Utils.GetOutputDirectoryPath(); string pageFilePathFormat = Path.Combine(outputDirectory, "html_render_margins_page_{0}.jpg"); /* * You can adjust margins (top,bottom,left,right) of final document by setting following properties in * options.WordProcessingOptions: * * LeftMargin * RightMargin * TopMargin * BottomMargin * * Default values in points are: * LeftMargin = RightMargin = 5 * TopMargin = BottomMargin = 72 */ // TO JPG using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HTML)) { JpgViewOptions options = new JpgViewOptions(pageFilePathFormat); options.WordProcessingOptions.LeftMargin = 40; options.WordProcessingOptions.RightMargin = 40; options.WordProcessingOptions.TopMargin = 40; options.WordProcessingOptions.BottomMargin = 40; viewer.View(options); } pageFilePathFormat = Path.Combine(outputDirectory, "html_render_margins_page_{0}.png"); // TO PNG using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HTML)) { PngViewOptions options = new PngViewOptions(pageFilePathFormat); options.WordProcessingOptions.LeftMargin = 40; options.WordProcessingOptions.RightMargin = 40; options.WordProcessingOptions.TopMargin = 40; options.WordProcessingOptions.BottomMargin = 40; viewer.View(options); } pageFilePathFormat = Path.Combine(outputDirectory, "html_render_margins.pdf"); // TO PDF using (Viewer viewer = new Viewer(TestFiles.SAMPLE_HTML)) { PdfViewOptions options = new PdfViewOptions(pageFilePathFormat); options.WordProcessingOptions.LeftMargin = 40; options.WordProcessingOptions.RightMargin = 40; options.WordProcessingOptions.TopMargin = 40; options.WordProcessingOptions.BottomMargin = 40; viewer.View(options); } Console.WriteLine($"\nSource document rendered successfully.\nCheck output in {outputDirectory}."); }