GeckoWebBrowser实现自定义打印

阅读更多

 

 

nsIWebBrowserPrint print = Xpcom.QueryInterface(geckoWebBrowser.Window.DomWindow);
            var service = Xpcom.GetService("@mozilla.org/gfx/printsettings-service;1");
            var ps = service.GetNewPrintSettingsAttribute();


            ps.SetTitleAttribute(SystemSetting.GetInstance().SystemName);

            ps.SetEdgeBottomAttribute(0);
            ps.SetEdgeTopAttribute(0);
            ps.SetEdgeLeftAttribute(0);
            ps.SetEdgeRightAttribute(0);

            ps.SetMarginBottomAttribute(0);
            ps.SetMarginTopAttribute(0);
            ps.SetMarginLeftAttribute(0);
            ps.SetMarginRightAttribute(0);


            ps.SetShrinkToFitAttribute(true);
            ps.SetPrintSilentAttribute(true);//是否发声
            ps.SetPrintReversedAttribute(true);

            ps.SetOrientationAttribute(1);//横向打印

            try
            {
                print.Print(ps, new WebProgressListener());
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印失败"+ex.Message);
            }

 

 

 

你可能感兴趣的:(GeckoWebBrowser实现自定义打印)