Ejemplo n.º 1
0
        public static string GetHTMLString(ShapesDTO shapesDto)
        {
            var sb = new StringBuilder();

            sb.Append(@"<html><head>
                            </head>
                            <body>
                                <div class='header'><h1>  Title : " + shapesDto.Title + @"</h1></div>
<div class='header'><h1>Description : " + shapesDto.Description + @"</h1></div>
<div class='header'><h1>Longitude : " + shapesDto.Longitude + @"</h1></div>
<div class='header'><h1>Latitude : " + shapesDto.Latitude + @"</h1></div>
<div class='header'><h1>Area : " + shapesDto.Area + @"</h1></div>
                               
                            </body>
                        </html>");

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        private void CreatePDFFileWithZip(ShapesDTO shapesDto, string fileName)
        {
            try
            {
                var globalSettings = new GlobalSettings
                {
                    ColorMode   = ColorMode.Color,
                    Orientation = Orientation.Portrait,
                    PaperSize   = PaperKind.A4,
                    Margins     = new MarginSettings {
                        Top = 10
                    },
                    DocumentTitle = "PDF Report",
                    Out           = fileName
                };

                var objectSettings = new ObjectSettings
                {
                    PagesCount     = true,
                    HtmlContent    = TemplateGenerator.GetHTMLString(shapesDto),
                    WebSettings    = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Directory.GetCurrentDirectory(), "assets", "styles.css") },
                    HeaderSettings = { FontName = "Arial", FontSize = 9, Right = "Page [page] of [toPage]", Line = true },
                    FooterSettings = { FontName = "Arial", FontSize = 9, Line = true, Center = "Report Footer" }
                };

                var pdf = new HtmlToPdfDocument()
                {
                    GlobalSettings = globalSettings,
                    Objects        = { objectSettings }
                };


                var file = _converter.Convert(pdf);
                if (file != null)
                {
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
                throw;
            }
        }