コード例 #1
0
 public HtmlToPdfConverter(PdfGlobalSettings settings = default(PdfGlobalSettings))
 {
     if (Native.Initialize(false))
     {
         _globalSettings = Native.CreateGlobalSettings();
         UpdateSettings(settings);
     }
 }
コード例 #2
0
        private void UpdateSettings(PdfGlobalSettings s)
        {
            var update = new List <Tuple <string, string> > {
                { "size.pageSize", Enum.GetName(typeof(PageSize), s.PageSize) },
                { "orientation", Enum.GetName(typeof(Orientation), s.Orientation) },
                { "colorMode", Enum.GetName(typeof(ColorMode), s.ColorMode) },
                { "useCompression", s.UseCompression.ToString().ToLower() },
                { "margin.top", s.MarginTop },
                { "margin.right", s.MarginRight },
                { "margin.bottom", s.MarginBottom },
                { "margin.left", s.MarginLeft }
            };

            foreach (var setting in update)
            {
                Native.SetGlobalSetting(_globalSettings, setting.Item1, setting.Item2);
            }
        }