private string WithInlineStyles(IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
        {
            var htmlToConvert =
                @"
<!DOCTYPE html>
<html>
<head>
    <title>complex-test</title>
    <style>
        body {
            color: #333;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        h1 {
            background: #ff0000;
        }
    </style>
</head>
<body>
    <h1>Hello World!</h1>
    <p>This PDF has been generated by PhantomJs ;)</p>

    <h2>This is a subtitle</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla dignissim sit amet erat vehicula semper. In lobortis, velit mattis sagittis accumsan, erat nisl tincidunt dui, varius imperdiet elit lacus non metus. Ut iaculis maximus semper. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut ac pharetra augue. Fusce vitae felis auctor, rutrum urna vitae, sagittis nibh. Curabitur in aliquet odio, non varius orci. Aenean sit amet rutrum nibh. Aenean erat urna, efficitur id maximus a, dapibus ut sem.</p>
</body>
</html>
";

            return(ConvertHtml(htmlToConvert, htmlToPdfConverter, targetDirectory));
        }
示例#2
0
 public PdfResult(IHtmlToPdfConverter converter, Stream htmlFile, HtmlToPdfSettings settings, string viewName) : base()
 {
     ViewName        = viewName;
     _converter      = converter;
     _settings       = settings;
     _htmlFileSource = htmlFile;
 }
 public TradeHistoryController(IAccountService accountService, IViewRenderService viewRenderService, IHtmlToPdfConverter htmlToPdfConverter, IWebHostEnvironment environment)
 {
     this.accountService     = accountService;
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.environment        = environment;
 }
示例#4
0
 public PdfCreator(IAppConfiguration appConfiguration, ICommandManager commandManager, IHtmlToPdfConverter htmlToPdfConverter, IHtmlDocument htmlDocument)
 {
     _appConfiguration   = appConfiguration;
     _commandManager     = commandManager;
     _htmlToPdfConverter = htmlToPdfConverter;
     _htmlDocument       = htmlDocument;
 }
        private string ConvertHtml(string htmlToConvert, IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
        {
            var pathOftheGeneratedPdf = htmlToPdfConverter.Convert(htmlToConvert, targetDirectory);

            Console.WriteLine($"Pdf generated at: {pathOftheGeneratedPdf}");
            return(pathOftheGeneratedPdf);
        }
示例#6
0
 public DashboardController(IViewRenderService viewRenderService, IHtmlToPdfConverter htmlToPdfConverter, IHostingEnvironment environment, IResumeService resumeService)
 {
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.environment        = environment;
     this.resumeService      = resumeService;
 }
 public IEnumerable <Func <string> > GetAll(IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
 {
     return(new List <Func <string> >
     {
         () => BasicHtmlTest(htmlToPdfConverter, targetDirectory),
         () => WithInlineStyles(htmlToPdfConverter, targetDirectory),
         () => WithRelativeStyleSheet(htmlToPdfConverter, targetDirectory)
     });
 }
示例#8
0
 public DashboardController(
     IViewRenderService viewRenderService,
     IHtmlToPdfConverter htmlToPdfConverter,
     IInvoicesService invoice)
 {
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.invoice            = invoice;
 }
 public BillingService(IViewRenderService viewRenderService, IHtmlToPdfConverter htmlToPdfConverter, IUploadService uploadService, ICustomerService customerService, IBillsService billsService, IEmailSender emailSender, IWebHostEnvironment enviroment)
 {
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.uploadService      = uploadService;
     this.customerService    = customerService;
     this.billsService       = billsService;
     this.emailSender        = emailSender;
     this.enviroment         = enviroment;
 }
示例#10
0
 public ExportController(
     IViewRenderService viewRenderService,
     IHtmlToPdfConverter htmlToPdfConverter,
     IWebHostEnvironment environment,
     ApplicationDbContext applicationDbContext, IUsersService usersService)
 {
     this.viewRenderService    = viewRenderService;
     this.htmlToPdfConverter   = htmlToPdfConverter;
     this.environment          = environment;
     this.applicationDbContext = applicationDbContext;
     this.usersService         = usersService;
 }
示例#11
0
 public ServicesController(IServiceInfoService serviceInfoService, IServiceService serviceService, ICustomerService customerService, IAddressService addressService, IViewRenderService viewRenderService, IHtmlToPdfConverter htmlToPdfConverter, IWebHostEnvironment webHostEnvironment, IServiceNumberService serviceNumberService, IUploadService uploadService)
 {
     this.serviceInfoService   = serviceInfoService;
     this.serviceService       = serviceService;
     this.customerService      = customerService;
     this.addressService       = addressService;
     this.viewRenderService    = viewRenderService;
     this.htmlToPdfConverter   = htmlToPdfConverter;
     this.webHostEnvironment   = webHostEnvironment;
     this.serviceNumberService = serviceNumberService;
     this.uploadService        = uploadService;
 }
示例#12
0
 public OrdersController(IOrderService orderService, IServiceService serviceService, IServiceNumberService numberService, IServiceInfoService serviceInfoService, IViewRenderService viewRenderService, IHtmlToPdfConverter htmlToPdfConverter, IWebHostEnvironment environment, IAddressService addressService, ITasksService tasksService, IHubContext <TaskHub, ITaskHub> context, ICustomerService customerService, IUploadService uploadService)
 {
     this.orderService       = orderService;
     this.serviceService     = serviceService;
     this.numberService      = numberService;
     this.serviceInfoService = serviceInfoService;
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.environment        = environment;
     this.addressService     = addressService;
     this.tasksService       = tasksService;
     this.context            = context;
     this.customerService    = customerService;
     this.uploadService      = uploadService;
 }
示例#13
0
 public CustomersController(ICustomerService customerService,
                            ICarService carService,
                            IInvoiceService invoiseService,
                            IViewRenderService viewRenderService,
                            IHtmlToPdfConverter htmlToPdfConverter,
                            IHostingEnvironment environment,
                            IDateTimeProvider dateTimeProvider)
 {
     this.customerService    = customerService;
     this.carService         = carService;
     this.invoiseService     = invoiseService;
     this.viewRenderService  = viewRenderService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.environment        = environment;
     this.dateTimeProvider   = dateTimeProvider;
 }
        private string BasicHtmlTest(IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
        {
            var htmlToConvert =
                @"
<!DOCTYPE html>
<html>
<head>

</head>
<body>
    <h1>Hello World!</h1>
    <p>This PDF has been generated by PhantomJs ;)</p>
</body>
</html>
";

            // Generate pdf from html and place in the current folder.
            return(ConvertHtml(htmlToConvert, htmlToPdfConverter, targetDirectory));
        }
示例#15
0
 public OrdersController(
     IOrdersService ordersService,
     UserManager <ApplicationUser> userManager,
     ICustomersService customersService,
     IOrderItemsService orderItemsService,
     IImportOrderServices importServices,
     IShippingService shippingService,
     IHtmlToPdfConverter htmlToPdfConverter,
     IWebHostEnvironment environment,
     IMemoryCache cache)
 {
     this.ordersService      = ordersService;
     this.userManager        = userManager;
     this.customersService   = customersService;
     this.orderItemsService  = orderItemsService;
     this.importServices     = importServices;
     this.shippingService    = shippingService;
     this.htmlToPdfConverter = htmlToPdfConverter;
     this.environment        = environment;
     this.cache = cache;
 }
        private string WithRelativeStyleSheet(IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
        {
            var htmlToConvert =
                @"
<!DOCTYPE html>
<html>
<head>
    <title>complex-test</title>
    <link href=""assets/css/pdf-styles.css"" rel=""stylesheet"" />
</head>
<body>
    <h1>Hello World!</h1>
    <p>This PDF has been generated by PhantomJs ;)</p>
    <p>This PDF loads an external CSS stylesheet.</p>

    <h2>This is a subtitle</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla dignissim sit amet erat vehicula semper. In lobortis, velit mattis sagittis accumsan, erat nisl tincidunt dui, varius imperdiet elit lacus non metus. Ut iaculis maximus semper. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut ac pharetra augue. Fusce vitae felis auctor, rutrum urna vitae, sagittis nibh. Curabitur in aliquet odio, non varius orci. Aenean sit amet rutrum nibh. Aenean erat urna, efficitur id maximus a, dapibus ut sem.</p>
</body>
</html>
";

            return(ConvertHtml(htmlToConvert, htmlToPdfConverter, targetDirectory));
        }
示例#17
0
 public HtmlConverter()
 {
     _htmlToPdfConverter   = new HtmlToPdfConverter();
     _htmlToImageConverter = new HtmlToImageConverter();
 }
示例#18
0
 static ExampleProgram()
 {
     _currentDirectory    = Directory.GetCurrentDirectory();
     _phantomJsRootFolder = Path.Combine(_currentDirectory, "PhantomJsRoot");
     _generator           = new PhantomJsHtmlToPdfConverter(new PdfGeneratorOptions(_phantomJsRootFolder));
 }
示例#19
0
 public HtmlConverter(IHtmlToPdfConverter htmlToPdfConverter, IHtmlToImageConverter htmlToImageConverter)
 {
     this._htmlToPdfConverter   = htmlToPdfConverter;
     this._htmlToImageConverter = htmlToImageConverter;
 }
示例#20
0
 public ConvertController(IHtmlToPdfConverter converter)
 {
     _converter = converter;
 }
 public IEnumerable <TestCaseResult> RunAll(IHtmlToPdfConverter htmlToPdfConverter, string targetDirectory)
 {
     return(GetAll(htmlToPdfConverter, targetDirectory)
            .Select(testCase => RunOne(testCase)));
 }
示例#22
0
 internal HtmlConverter(IProcessService processService)
 {
     _htmlToPdfConverter   = new HtmlToPdfConverter(processService);
     _htmlToImageConverter = new HtmlToImageConverter(processService);
 }