public TabFromSite(TabControl tc) { this.tc = tc; this.pageThis = new TabPage("Пустая вкладка"); this.tst = new ToolStrip(); ToolStripButton Gotstb = new ToolStripButton("GO!>>"); ToolStripButton backtstb = new ToolStripButton("<<"); ToolStripButton nobacktstb = new ToolStripButton(">>"); this.URLtsttb = new ToolStripTextBox(); URLtsttb.Size = new System.Drawing.Size(450, 20); Gotstb.Dock = DockStyle.Right; Gotstb.Click += Gotstb_Click; nobacktstb.Click += Nobacktstb_Click; backtstb.Click += Backtstb_Click; URLtsttb.Dock = DockStyle.Right; tst.Items.Add(backtstb); tst.Items.Add(nobacktstb); tst.Items.Add(URLtsttb); tst.Items.Add(Gotstb); tst.Dock = DockStyle.Top; b = new EO.WebBrowser.WebView(); b.NewWindow += B_NewWindow; box = new PictureBox(); b.Create(box.Handle); b.Url = Properties.Settings.Default.homepage; box.Dock = DockStyle.Fill; pageThis.Controls.Add(tst); pageThis.Controls.Add(box); tc.TabPages.Add(this.pageThis); tc.SelectedIndex = tc.TabPages.Count - 1; b.LoadCompleted += B_LoadCompleted; }
/// <summary> /// Print method. /// </summary> public void Print(string filePath, D3jsLib.PdfStyle style) { EO.WebBrowser.WebView view = this.browser.WebView; if (view != null) { string htmlCode = view.GetHtml(); HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlCode); HtmlNodeCollection nodes = htmlDoc.DocumentNode.SelectNodes("//div[@class='gridster-box']"); foreach (HtmlNode n in nodes) { n.InnerHtml = ""; } // attempt to move *dep file D3jsLib.Utilities.ChartsUtilities.MoveDepFile(); // create converter SelectPdf.HtmlToPdf converter = new SelectPdf.HtmlToPdf(); // set converter options SelectPdf.HtmlToPdfOptions options = converter.Options; options.PdfPageOrientation = style.Orientation; options.PdfPageSize = style.Size; options.JpegCompressionLevel = style.Compression; options.JavaScriptEnabled = true; options.EmbedFonts = true; options.KeepImagesTogether = true; options.KeepTextsTogether = true; options.AutoFitHeight = style.VerticalFit; options.AutoFitWidth = style.HorizontalFit; options.MarginTop = style.MarginTop; options.MarginRight = style.MarginRight; options.MarginBottom = style.MarginBottom; options.MarginLeft = style.MarginLeft; // created unescaped file path removes %20 from path etc. string finalFilePath = filePath; Uri uri = new Uri(filePath); string absoluteFilePath = Uri.UnescapeDataString(uri.AbsoluteUri); if (Uri.IsWellFormedUriString(absoluteFilePath, UriKind.RelativeOrAbsolute)) { Uri newUri = new Uri(absoluteFilePath); finalFilePath = newUri.LocalPath; } // convert html to document object and save SelectPdf.PdfDocument pdfDoc = converter.ConvertHtmlString(htmlDoc.DocumentNode.InnerHtml); pdfDoc.Save(finalFilePath); pdfDoc.Close(); } }