示例#1
0
        /// <summary>
        /// Converts external HTML resource into PDF.
        /// </summary>
        /// <param name="doc">document parameters, <code>ObjectSettings.SetPageUri</code> should be set</param>
        /// <returns>PDF document body</returns>
        public byte[] Convert(ObjectSettings settings)
        {
            var doc = new HtmlToPdfDocument();

            doc.Objects.Add(settings);
            return(this.Convert(doc));
        }
        public static byte[] ConvertToPdf(PDFHelper.DataType type, string data, string documentName)
        {
            var webSettings = new WebSettings
            {
                EnableJavascript = true,
                LoadImages = true,
                EnableIntelligentShrinking = true
            };

            ObjectSettings objSettings = null;

            if (type == DataType.HTML)
                objSettings = new ObjectSettings { HtmlText = data, WebSettings = webSettings };
            else
                objSettings = new ObjectSettings { PageUrl = data, WebSettings = webSettings };

            var document = new HtmlToPdfDocument
            {
                GlobalSettings =
                {
                    ProduceOutline = true,
                    DocumentTitle = documentName,
                    PaperSize = PaperKind.Letter,
                    UseCompression = true,
                    ImageDPI = 600,
                    ImageQuality = 100,


                    //DPI = 1200,
                    Margins =
                    {
                        Top = 1,
                        Right = 0.5,
                        Bottom = 1,
                        Left = 0.5,
                        Unit = Unit.Centimeters
                    }
                },
                Objects = {
                   objSettings
                }
            };

            return converter.Convert(document);
        }
示例#3
0
 public byte[] Convert(ObjectSettings settings)
 {
     return(SynchronizedDispatcher.Invoke(() => this.remoteInstance.Convert(settings)));
 }
示例#4
0
 /// <summary>
 /// Converts external HTML resource into PDF.
 /// </summary>
 /// <param name="doc">document parameters, <code>ObjectSettings.SetPageUri</code> should be set</param>
 /// <returns>PDF document body</returns>
 public byte[] Convert(ObjectSettings settings)
 {
     var doc = new HtmlToPdfDocument();
     doc.Objects.Add(settings);
     return this.Convert(doc);
 }
示例#5
0
 public byte[] Convert(ObjectSettings settings)
 {
     return SynchronizedDispatcher.Invoke(() => this.remoteInstance.Convert(settings));
 }