示例#1
0
        public IActionResult Get()
        {
            var settings = new PdfSettings();
            var doc      = new HtmlToPdfDocument()
            {
                GlobalSettings =
                {
                    ColorMode   = ColorMode.Color,
                    PaperSize   = settings.PaperKind,
                    Orientation = settings.Orientation
                }
            };

            doc.Objects.Add(new ObjectSettings
            {
                HtmlContent    = "<html><body><h1 style='color: #f00;'>Hello worlds!!</h1></body></html>",
                WebSettings    = { DefaultEncoding = "utf-8" },
                HeaderSettings = { FontSize = 9, Right = "Page [page] of [toPage]", Line = true, Spacing = 2.812 },
                PagesCount     = true
            });

            var pdf = _pdfConverter.Convert(doc);

            return(new FileContentResult(pdf, "application/pdf"));
        }
示例#2
0
        static void Main(string[] args)
        {
            var argsResult = new ApplicationArguments();

            argsResult.GetOptionSet().Parse(args);

            var builder = new ConfigurationBuilder()
                          .AddJsonFile($"appsettings.json", true, true)
                          .AddEnvironmentVariables();

            var config      = builder.Build();
            var pdfSettings = new PdfSettings();

            config.GetSection("PdfSettings").Bind(pdfSettings);
            try
            {
                using (var reader = File.OpenText(argsResult.InputFile))
                {
                    var html        = reader.ReadToEnd();
                    var pdfDocument = PdfGenerator.GeneratePdf(html, pdfSettings, null);
                    using (var writeStream = File.OpenWrite(argsResult.OutputFile))
                    {
                        using (var writer = new BinaryWriter(writeStream))
                        {
                            writer.Write(pdfDocument);
                        }
                    }
                }
                Console.WriteLine("Done!");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public GetOrderDetailsHandler(IDateTimeHelper dateTimeHelper, IProductService productService, IProductAttributeParser productAttributeParser,
                               ILocalizationService localizationService,
                               IOrderProcessingService orderProcessingService, IShipmentService shipmentService, IPaymentService paymentService,
                               ICurrencyService currencyService, IPriceFormatter priceFormatter, IGiftCardService giftCardService, IOrderService orderService,
                               IPictureService pictureService, IDownloadService downloadService, IMediator mediator,
                               CatalogSettings catalogSettings, OrderSettings orderSettings, PdfSettings pdfSettings, TaxSettings taxSettings)
 {
     _dateTimeHelper         = dateTimeHelper;
     _productService         = productService;
     _productAttributeParser = productAttributeParser;
     _localizationService    = localizationService;
     _orderProcessingService = orderProcessingService;
     _shipmentService        = shipmentService;
     _paymentService         = paymentService;
     _currencyService        = currencyService;
     _priceFormatter         = priceFormatter;
     _giftCardService        = giftCardService;
     _orderService           = orderService;
     _pictureService         = pictureService;
     _downloadService        = downloadService;
     _mediator        = mediator;
     _orderSettings   = orderSettings;
     _catalogSettings = catalogSettings;
     _pdfSettings     = pdfSettings;
     _taxSettings     = taxSettings;
 }
示例#4
0
 public PrintFormService(IFormService formService,
                         ILocalizationService localizationService,
                         ILanguageService languageService,
                         IWorkContext workContext,
                         IMeasureService measureService,
                         IPictureService pictureService,
                         IStoreService storeService,
                         IStoreContext storeContext,
                         ISettingService settingContext,
                         IWebHelper webHelper,
                         MeasureSettings measureSettings,
                         PdfSettings pdfSettings)
 {
     _formService         = formService;
     _localizationService = localizationService;
     _languageService     = languageService;
     _workContext         = workContext;
     _measureService      = measureService;
     _pictureService      = pictureService;
     _storeService        = storeService;
     _storeContext        = storeContext;
     _settingContext      = settingContext;
     _webHelper           = webHelper;
     _measureSettings     = measureSettings;
     _pdfSettings         = pdfSettings;
 }
示例#5
0
        public static ActionResult Pdf(this Controller controller, string view, Object model, PdfSettings settings = null)
        {
            if (settings == null)
            {
                settings = new PdfSettings();
            }

            var html = Socks.RenderViewToString(controller, view, model, settings);

            //var html = controller.RenderViewToString(view, model, settings);

            if (settings.Action == PdfSettings.PdfAction.Html)
            {
                return(Socks.RenderPdfAsHtml(controller, html));
            }

            Stream pdf = Socks.toPdf(html, settings);

            if (settings.Action == PdfSettings.PdfAction.Download)
            {
                var filename = settings.Filename ?? (Guid.NewGuid().ToString("N") + ".pdf");
                controller.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
            }

            return(controller.File(pdf));
        }
 public OrderModelFactory(AddressSettings addressSettings,
                          CatalogSettings catalogSettings,
                          IAddressModelFactory addressModelFactory,
                          IAddressService addressService,
                          ICountryService countryService,
                          ICurrencyService currencyService,
                          ICustomerService customerService,
                          IDateTimeHelper dateTimeHelper,
                          IGiftCardService giftCardService,
                          ILocalizationService localizationService,
                          IOrderProcessingService orderProcessingService,
                          IOrderService orderService,
                          IOrderTotalCalculationService orderTotalCalculationService,
                          IPaymentPluginManager paymentPluginManager,
                          IPaymentService paymentService,
                          IPriceFormatter priceFormatter,
                          IProductService productService,
                          IRewardPointService rewardPointService,
                          IShipmentService shipmentService,
                          IStoreContext storeContext,
                          IUrlRecordService urlRecordService,
                          IVendorService vendorService,
                          IWorkContext workContext,
                          OrderSettings orderSettings,
                          PdfSettings pdfSettings,
                          RewardPointsSettings rewardPointsSettings,
                          ShippingSettings shippingSettings,
                          TaxSettings taxSettings,
                          VendorSettings vendorSettings)
 {
     _addressSettings              = addressSettings;
     _catalogSettings              = catalogSettings;
     _addressModelFactory          = addressModelFactory;
     _addressService               = addressService;
     _countryService               = countryService;
     _currencyService              = currencyService;
     _customerService              = customerService;
     _dateTimeHelper               = dateTimeHelper;
     _giftCardService              = giftCardService;
     _localizationService          = localizationService;
     _orderProcessingService       = orderProcessingService;
     _orderService                 = orderService;
     _orderTotalCalculationService = orderTotalCalculationService;
     _paymentPluginManager         = paymentPluginManager;
     _paymentService               = paymentService;
     _priceFormatter               = priceFormatter;
     _productService               = productService;
     _rewardPointService           = rewardPointService;
     _shipmentService              = shipmentService;
     _storeContext                 = storeContext;
     _urlRecordService             = urlRecordService;
     _vendorService                = vendorService;
     _workContext          = workContext;
     _orderSettings        = orderSettings;
     _pdfSettings          = pdfSettings;
     _rewardPointsSettings = rewardPointsSettings;
     _shippingSettings     = shippingSettings;
     _taxSettings          = taxSettings;
     _vendorSettings       = vendorSettings;
 }
示例#7
0
        public OrderController(IOrderService orderService, IWorkContext workContext,
                               ICurrencyService currencyService, IPriceFormatter priceFormatter,
                               IOrderProcessingService orderProcessingService,
                               IDateTimeHelper dateTimeHelper, IMeasureService measureService,
                               IPaymentService paymentService, ILocalizationService localizationService,
                               IPdfService pdfService, ICustomerService customerService,
                               IWorkflowMessageService workflowMessageService,
                               LocalizationSettings localizationSettings,
                               MeasureSettings measureSettings, CatalogSettings catalogSettings,
                               OrderSettings orderSettings, TaxSettings taxSettings, PdfSettings pdfSettings,
                               IPictureService pictureSevice, MediaSettings mediaSettings, IProductAttributeFormatter productAttributeFormatter)
        {
            this._orderService              = orderService;
            this._workContext               = workContext;
            this._currencyService           = currencyService;
            this._priceFormatter            = priceFormatter;
            this._orderProcessingService    = orderProcessingService;
            this._dateTimeHelper            = dateTimeHelper;
            this._measureService            = measureService;
            this._paymentService            = paymentService;
            this._localizationService       = localizationService;
            this._pdfService                = pdfService;
            this._customerService           = customerService;
            this._workflowMessageService    = workflowMessageService;
            this._productAttributeFormatter = productAttributeFormatter;

            this._localizationSettings = localizationSettings;
            this._measureSettings      = measureSettings;
            this._catalogSettings      = catalogSettings;
            this._orderSettings        = orderSettings;
            this._taxSettings          = taxSettings;
            this._pdfSettings          = pdfSettings;
            this._pictureService       = pictureSevice;
            this._mediaSettings        = mediaSettings;
        }
        public async Task HandleEventAsync(MessageQueuingEvent message, PdfSettings pdfSettings, IUrlHelper urlHelper)
        {
            var qe    = message.QueuedEmail;
            var ctx   = message.MessageContext;
            var model = message.MessageModel;

            var handledTemplates = new Dictionary <string, bool>(StringComparer.OrdinalIgnoreCase)
            {
                { "OrderPlaced.CustomerNotification", pdfSettings.AttachOrderPdfToOrderPlacedEmail },
                { "OrderCompleted.CustomerNotification", pdfSettings.AttachOrderPdfToOrderCompletedEmail }
            };

            if (handledTemplates.TryGetValue(ctx.MessageTemplate.Name, out var shouldHandle) && shouldHandle)
            {
                if (model.Get("Order") is IDictionary <string, object> order && order.Get("ID") is int orderId)
                {
                    try
                    {
                        var qea = await CreatePdfInvoiceAttachmentAsync(orderId, urlHelper);

                        qe.Attachments.Add(qea);
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex, T("Admin.System.QueuedEmails.ErrorCreatingAttachment"));
                    }
                }
            }
        }
示例#9
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            var pdfSettings = new PdfSettings
            {
                DefaultFileName = txtDefaultFileName.Text,
                Metadata        =
                {
                    Title    = txtTitle.Text,
                    Author   = txtAuthor.Text,
                    Subject  = txtSubject.Text,
                    Keywords = txtKeywords.Text
                },
                Encryption =
                {
                    EncryptPdf    = cbEncryptPdf.Checked,
                    OwnerPassword = txtOwnerPassword.Text,
                    UserPassword  = txtUserPassword.Text,
                    AllowContentCopyingForAccessibility = cbAllowContentCopyingForAccessibility.Checked,
                    AllowAnnotations          = cbAllowAnnotations.Checked,
                    AllowDocumentAssembly     = cbAllowDocumentAssembly.Checked,
                    AllowContentCopying       = cbAllowContentCopying.Checked,
                    AllowFormFilling          = cbAllowFormFilling.Checked,
                    AllowFullQualityPrinting  = cbAllowFullQualityPrinting.Checked,
                    AllowDocumentModification = cbAllowDocumentModification.Checked,
                    AllowPrinting             = cbAllowPrinting.Checked
                }
            };

            pdfSettingsContainer.PdfSettings     = pdfSettings;
            userConfigManager.Config.PdfSettings = cbRememberSettings.Checked ? pdfSettings : null;
            userConfigManager.Save();

            Close();
        }
        public OrderController(IOrderService orderService,
                               IShipmentService shipmentService, IWorkContext workContext,
                               ICurrencyService currencyService, IPriceFormatter priceFormatter,
                               IOrderProcessingService orderProcessingService, IDateTimeHelper dateTimeHelper,
                               IPaymentService paymentService, ILocalizationService localizationService,
                               IPdfService pdfService, IShippingService shippingService,
                               ICountryService countryService, IProductAttributeParser productAttributeParser,
                               IWebHelper webHelper,
                               CatalogSettings catalogSettings, OrderSettings orderSettings,
                               TaxSettings taxSettings, PdfSettings pdfSettings,
                               ShippingSettings shippingSettings, AddressSettings addressSettings)
        {
            this._orderService           = orderService;
            this._shipmentService        = shipmentService;
            this._workContext            = workContext;
            this._currencyService        = currencyService;
            this._priceFormatter         = priceFormatter;
            this._orderProcessingService = orderProcessingService;
            this._dateTimeHelper         = dateTimeHelper;
            this._paymentService         = paymentService;
            this._localizationService    = localizationService;
            this._pdfService             = pdfService;
            this._shippingService        = shippingService;
            this._countryService         = countryService;
            this._productAttributeParser = productAttributeParser;
            this._webHelper = webHelper;

            this._catalogSettings  = catalogSettings;
            this._orderSettings    = orderSettings;
            this._taxSettings      = taxSettings;
            this._pdfSettings      = pdfSettings;
            this._shippingSettings = shippingSettings;
            this._addressSettings  = addressSettings;
        }
示例#11
0
        public Naps2ScanJob PdfSettings(PdfSettings settings)
        {
            if (settings is null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            // Metadata
            var customMeta = settings.UsesSavedMetadata;

            AddBooleanOption(PdfFlags.UseSavedMetadata, customMeta);
            AddStringOption(PdfFlags.Title, settings.Title, !customMeta);
            AddStringOption(PdfFlags.Author, settings.Author, !customMeta);
            AddStringOption(PdfFlags.Subject, settings.Subject, !customMeta);
            AddStringOption(PdfFlags.Keywords, settings.Keywords, !customMeta);

            // Encryption
            AddBooleanOption(PdfFlags.UseSavedEncryptConfig, settings.UseSavedEncryptConfig);
            AddStringOption(
                PdfFlags.EncryptConfig,
                settings.EncryptConfig,
                enabled: !string.IsNullOrWhiteSpace(settings.EncryptConfig));

            return(this);
        }
示例#12
0
 public virtual void SetUp()
 {
     pdfExporter = GetPdfExporter();
     settings    = new PdfSettings
     {
         Metadata =
         {
             Author   = "Test Author",
             Creator  = "Test Creator",
             Keywords = "Test Keywords",
             Subject  = "Test Subject",
             Title    = "Test Title"
         }
     };
     images = new List <Bitmap> {
         ColorBitmap(100, 100, Color.Red),
         ColorBitmap(100, 100, Color.Yellow),
         ColorBitmap(200, 100, Color.Green),
     }.Select(bitmap =>
     {
         using (bitmap)
         {
             return(new ScannedImage(bitmap, ScanBitDepth.C24Bit, false, -1));
         }
     }).ToList();
     if (!Directory.Exists("test"))
     {
         Directory.CreateDirectory("test");
     }
     if (File.Exists(PDF_PATH))
     {
         File.Delete(PDF_PATH);
     }
 }
示例#13
0
        private void UpdateValues(PdfSettings pdfSettings)
        {
            txtDefaultFilePath.Text  = pdfSettings.DefaultFileName;
            cbSkipSavePrompt.Checked = pdfSettings.SkipSavePrompt;
            cbSinglePagePdf.Checked  = pdfSettings.SinglePagePdf;
            cbShowFolder.Checked     = pdfSettings.ShowFolder;
            txtTitle.Text            = pdfSettings.Metadata.Title;
            txtAuthor.Text           = pdfSettings.Metadata.Author;
            txtSubject.Text          = pdfSettings.Metadata.Subject;
            txtKeywords.Text         = pdfSettings.Metadata.Keywords;
            cbEncryptPdf.Checked     = pdfSettings.Encryption.EncryptPdf;
            txtOwnerPassword.Text    = pdfSettings.Encryption.OwnerPassword;
            txtUserPassword.Text     = pdfSettings.Encryption.UserPassword;
            clbPerms.SetItemChecked(0, pdfSettings.Encryption.AllowPrinting);
            clbPerms.SetItemChecked(1, pdfSettings.Encryption.AllowFullQualityPrinting);
            clbPerms.SetItemChecked(2, pdfSettings.Encryption.AllowDocumentModification);
            clbPerms.SetItemChecked(3, pdfSettings.Encryption.AllowDocumentAssembly);
            clbPerms.SetItemChecked(4, pdfSettings.Encryption.AllowContentCopying);
            clbPerms.SetItemChecked(5, pdfSettings.Encryption.AllowContentCopyingForAccessibility);
            clbPerms.SetItemChecked(6, pdfSettings.Encryption.AllowAnnotations);
            clbPerms.SetItemChecked(7, pdfSettings.Encryption.AllowFormFilling);
            var forced = appConfigManager.Config.ForcePdfCompat;

            cmbCompat.SelectedIndex = (int)(forced == PdfCompat.Default ? pdfSettings.Compat : forced);
        }
 public PdfService(ILocalizationService localizationService, IOrderService orderService,
                   IPaymentService paymentService,
                   IDateTimeHelper dateTimeHelper, IPriceFormatter priceFormatter,
                   ICurrencyService currencyService, IMeasureService measureService,
                   IPictureService pictureService, IProductService productService,
                   IWebHelper webHelper,
                   CatalogSettings catalogSettings, CurrencySettings currencySettings,
                   MeasureSettings measureSettings, PdfSettings pdfSettings, TaxSettings taxSettings,
                   StoreInformationSettings storeInformationSettings)
 {
     this._localizationService      = localizationService;
     this._orderService             = orderService;
     this._paymentService           = paymentService;
     this._dateTimeHelper           = dateTimeHelper;
     this._priceFormatter           = priceFormatter;
     this._currencyService          = currencyService;
     this._measureService           = measureService;
     this._pictureService           = pictureService;
     this._productService           = productService;
     this._webHelper                = webHelper;
     this._currencySettings         = currencySettings;
     this._catalogSettings          = catalogSettings;
     this._measureSettings          = measureSettings;
     this._pdfSettings              = pdfSettings;
     this._taxSettings              = taxSettings;
     this._storeInformationSettings = storeInformationSettings;
 }
示例#15
0
        public void CreatePDF(Stream stream)
        {
            using (var ds = new DataSet())
            {
                // Fetch data:
                ds.ReadXml(Path.Combine("Resources", "data", "GcNWind.xml"));

                DataTable dtProds = ds.Tables["Products"];
                DataTable dtSupps = ds.Tables["Suppliers"];

                var products =
                    from prod in dtProds.Select()
                    join supp in dtSupps.Select()
                    on prod["SupplierID"] equals supp["SupplierID"]
                    orderby prod["ProductName"]
                    select new
                {
                    ProductID       = prod["ProductID"],
                    ProductName     = prod["ProductName"],
                    Supplier        = supp["CompanyName"],
                    QuantityPerUnit = prod["QuantityPerUnit"],
                    UnitPrice       = $"{prod["UnitPrice"]:C}"
                };

                // Load the template - HTML file with {{mustache}} data references:
                var template = File.ReadAllText(Path.Combine("Resources", "Misc", "ProductListTemplate.html"));
                // Bind the template to data:
                var builder       = new Stubble.Core.Builders.StubbleBuilder();
                var boundTemplate = builder.Build().Render(template, new { Query = products });
                var tmp           = Path.GetTempFileName();
                // Render the bound HTML:
                using (var re = new GcHtmlRenderer(boundTemplate))
                {
                    // PdfSettings allow to provide options for HTML to PDF conversion:
                    var pdfSettings = new PdfSettings()
                    {
                        Margins             = new Margins(0.2f, 1, 0.2f, 1),
                        IgnoreCSSPageSize   = true,
                        DisplayHeaderFooter = true,
                        HeaderTemplate      = "<div style='color:#1a5276; font-size:12px; width:1000px; margin-left:0.2in; margin-right:0.2in'>" +
                                              "<span style='float:left;'>Product Price List</span>" +
                                              "<span style='float:right'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></span>" +
                                              "</div>",
                        FooterTemplate = "<div style='color: #1a5276; font-size:12em; width:1000px; margin-left:0.2in; margin-right:0.2in;'>" +
                                         "<span>(c) GrapeCity, Inc. All Rights Reserved.</span>" +
                                         "<span style='float:right'>Generated on <span class='date'></span></span></div>"
                    };
                    // Render the generated HTML to the temporary file:
                    re.RenderToPdf(tmp, pdfSettings);
                }
                // Copy the created PDF from the temp file to target stream:
                using (var ts = File.OpenRead(tmp))
                    ts.CopyTo(stream);
                // Clean up:
                File.Delete(tmp);
            }
            // Done.
        }
示例#16
0
        /// <summary>
        /// Converts the given html file to a pdf file using the settings
        /// </summary>
        /// <param name="htmlFile">File path to the generated html file</param>
        /// <param name="outputFile">Name of the pdf tile to be generated</param>
        /// <param name="settings"></param>
        /// <param name="baseDirectory">Directory of the addin</param>
        /// <param name="log"></param>
        /// <returns></returns>
        public int ConvertToPdf(string htmlFile, string outputFile, PdfSettings settings, string baseDirectory, ICakeLog log)
        {
            var sb = new StringBuilder();

            sb.Append($"--image-dpi {settings.ImageDpi} ");
            sb.Append($"--image-quality {settings.ImageQuality} ");
            sb.Append($"--page-size {settings.PageSize} ");
            sb.Append($"--orientation {settings.Orientation} ");
            sb.Append("--print-media-type ");

            if (settings.Margins.Left > 0)
            {
                sb.Append($"--margin-left {settings.Margins.Left}mm ");
            }
            if (settings.Margins.Right > 0)
            {
                sb.Append($"--margin-right {settings.Margins.Right}mm ");
            }
            if (settings.Margins.Top > 0)
            {
                sb.Append($"--margin-top {settings.Margins.Top}mm ");
            }
            if (settings.Margins.Bottom > 0)
            {
                sb.Append($"--margin-bottom {settings.Margins.Bottom}mm ");
            }

            // don' use --disable-smart-shrinking
            // this zooms/fits the content "correct" to the page but the font kerning is a mess
            // use --zom 1.3 instead
            sb.Append("--zoom 1.3 ");
            sb.Append("--dpi 300 ");

            if (settings.AdditionalGlobalOptions != null)
            {
                sb.Append($"{settings.AdditionalGlobalOptions} ");
            }

            // in file
            sb.Append($"page \"{htmlFile}\" ");

            if (settings.AdditionalPageOptions != null)
            {
                sb.Append($"{settings.AdditionalPageOptions} ");
            }

            // out files
            sb.Append($"\"{outputFile}\" ");

            var outDir = Path.GetDirectoryName(outputFile);

            if (!Directory.Exists(outDir))
            {
                Directory.CreateDirectory(outDir);
            }

            return(Convert(settings.PathToWkhtmltopdf, sb.ToString(), baseDirectory, log));
        }
示例#17
0
 public OrderController(IOrderService orderService,
                        IProductService productService,
                        IShipmentService shipmentService,
                        IWorkContext workContext,
                        ICurrencyService currencyService,
                        IPriceFormatter priceFormatter,
                        IOrderProcessingService orderProcessingService,
                        IDateTimeHelper dateTimeHelper,
                        IPaymentService paymentService,
                        ILocalizationService localizationService,
                        IPdfService pdfService,
                        IShippingService shippingService,
                        ICountryService countryService,
                        IProductAttributeParser productAttributeParser,
                        IWebHelper webHelper,
                        IDownloadService downloadService,
                        IAddressAttributeFormatter addressAttributeFormatter,
                        IStoreContext storeContext,
                        IOrderTotalCalculationService orderTotalCalculationService,
                        IRewardPointsService rewardPointsService,
                        IGiftCardService giftCardService,
                        CatalogSettings catalogSettings,
                        OrderSettings orderSettings,
                        TaxSettings taxSettings,
                        ShippingSettings shippingSettings,
                        AddressSettings addressSettings,
                        RewardPointsSettings rewardPointsSettings,
                        PdfSettings pdfSettings)
 {
     this._orderService           = orderService;
     this._productService         = productService;
     this._shipmentService        = shipmentService;
     this._workContext            = workContext;
     this._currencyService        = currencyService;
     this._priceFormatter         = priceFormatter;
     this._orderProcessingService = orderProcessingService;
     this._dateTimeHelper         = dateTimeHelper;
     this._paymentService         = paymentService;
     this._localizationService    = localizationService;
     this._pdfService             = pdfService;
     this._shippingService        = shippingService;
     this._countryService         = countryService;
     this._productAttributeParser = productAttributeParser;
     this._webHelper                    = webHelper;
     this._downloadService              = downloadService;
     this._addressAttributeFormatter    = addressAttributeFormatter;
     this._storeContext                 = storeContext;
     this._rewardPointsService          = rewardPointsService;
     this._giftCardService              = giftCardService;
     this._orderTotalCalculationService = orderTotalCalculationService;
     this._catalogSettings              = catalogSettings;
     this._orderSettings                = orderSettings;
     this._taxSettings                  = taxSettings;
     this._shippingSettings             = shippingSettings;
     this._addressSettings              = addressSettings;
     this._rewardPointsSettings         = rewardPointsSettings;
     this._pdfSettings                  = pdfSettings;
 }
示例#18
0
 public OrderModelFactory(AddressSettings addressSettings,
                          CatalogSettings catalogSettings,
                          IAddressModelFactory addressModelFactory,
                          IPictureService pictureService,
                          IProductModelFactory productModelFactory,
                          ICountryService countryService,
                          ICurrencyService currencyService,
                          IDateTimeHelper dateTimeHelper,
                          IDownloadService downloadService,
                          ILocalizationService localizationService,
                          IOrderProcessingService orderProcessingService,
                          IOrderService orderService,
                          IOrderTotalCalculationService orderTotalCalculationService,
                          IPaymentService paymentService,
                          IPriceFormatter priceFormatter,
                          IProductService productService,
                          IRewardPointService rewardPointService,
                          IShipmentService shipmentService,
                          IStoreContext storeContext,
                          IUrlRecordService urlRecordService,
                          IVendorService vendorService,
                          IWorkContext workContext,
                          OrderSettings orderSettings,
                          PdfSettings pdfSettings,
                          RewardPointsSettings rewardPointsSettings,
                          ShippingSettings shippingSettings,
                          TaxSettings taxSettings,
                          VendorSettings vendorSettings)
 {
     this._pictureService               = pictureService;
     this._addressSettings              = addressSettings;
     this._catalogSettings              = catalogSettings;
     this._addressModelFactory          = addressModelFactory;
     this._productModelFactory          = productModelFactory;
     this._countryService               = countryService;
     this._currencyService              = currencyService;
     this._dateTimeHelper               = dateTimeHelper;
     this._downloadService              = downloadService;
     this._localizationService          = localizationService;
     this._orderProcessingService       = orderProcessingService;
     this._orderService                 = orderService;
     this._orderTotalCalculationService = orderTotalCalculationService;
     this._paymentService               = paymentService;
     this._priceFormatter               = priceFormatter;
     this._productService               = productService;
     this._rewardPointService           = rewardPointService;
     this._shipmentService              = shipmentService;
     this._storeContext                 = storeContext;
     this._urlRecordService             = urlRecordService;
     this._vendorService                = vendorService;
     this._workContext          = workContext;
     this._orderSettings        = orderSettings;
     this._pdfSettings          = pdfSettings;
     this._rewardPointsSettings = rewardPointsSettings;
     this._shippingSettings     = shippingSettings;
     this._taxSettings          = taxSettings;
     this._vendorSettings       = vendorSettings;
 }
示例#19
0
 public PdfService(ILocalizationService localizationService,
                   ILanguageService languageService,
                   IWorkContext workContext,
                   INhaXeService nhaxeService,
                   IDiaChiService diachiService,
                   IHanhTrinhService hanhtrinhService,
                   IOrderService orderService,
                   IXeInfoService xeinfoService,
                   IPaymentService paymentService,
                   IDateTimeHelper dateTimeHelper,
                   IPriceFormatter priceFormatter,
                   ICurrencyService currencyService,
                   IMeasureService measureService,
                   IPictureService pictureService,
                   IProductService productService,
                   IProductAttributeParser productAttributeParser,
                   IStoreService storeService,
                   IStoreContext storeContext,
                   ISettingService settingContext,
                   IWebHelper webHelper,
                   IAddressAttributeFormatter addressAttributeFormatter,
                   CatalogSettings catalogSettings,
                   CurrencySettings currencySettings,
                   MeasureSettings measureSettings,
                   PdfSettings pdfSettings,
                   TaxSettings taxSettings,
                   AddressSettings addressSettings)
 {
     this._localizationService    = localizationService;
     this._languageService        = languageService;
     this._nhaxeService           = nhaxeService;
     this._xeinfoService          = xeinfoService;
     this._diachiService          = diachiService;
     this._workContext            = workContext;
     this._hanhtrinhService       = hanhtrinhService;
     this._orderService           = orderService;
     this._paymentService         = paymentService;
     this._dateTimeHelper         = dateTimeHelper;
     this._priceFormatter         = priceFormatter;
     this._currencyService        = currencyService;
     this._measureService         = measureService;
     this._pictureService         = pictureService;
     this._productService         = productService;
     this._productAttributeParser = productAttributeParser;
     this._storeService           = storeService;
     this._storeContext           = storeContext;
     this._settingContext         = settingContext;
     this._webHelper = webHelper;
     this._addressAttributeFormatter = addressAttributeFormatter;
     this._currencySettings          = currencySettings;
     this._catalogSettings           = catalogSettings;
     this._measureSettings           = measureSettings;
     this._pdfSettings     = pdfSettings;
     this._taxSettings     = taxSettings;
     this._addressSettings = addressSettings;
 }
示例#20
0
        /// <summary>
        ///     Determine PDF-Version according to settings in conversion profile.
        /// </summary>
        /// <param name="settings">ConversionProfile</param>
        /// <returns>PDF Version as string, i.e. 1.6</returns>
        public string DeterminePdfVersion(PdfSettings settings)
        {
            var pdfVersion = "1.4";

            if (settings.Security.Enabled && (settings.Security.EncryptionLevel == EncryptionLevel.Aes128Bit))
            {
                pdfVersion = "1.6";
            }
            return(pdfVersion);
        }
示例#21
0
 public void TearDown()
 {
     pdfExporter = null;
     settings    = null;
     foreach (ScannedImage img in images)
     {
         img.Dispose();
     }
     images = null;
 }
示例#22
0
 public PdfService(ILocalizationService localizationService,
                   IWorkContext workContext,
                   IWebHelper webHelper,
                   PdfSettings pdfSettings)
 {
     this._localizationService = localizationService;
     this._workContext         = workContext;
     this._webHelper           = webHelper;
     this._pdfSettings         = pdfSettings;
 }
示例#23
0
 public OrderViewModelService(
     IOrderService orderService,
     IStoreContext storeContext,
     IWorkContext workContext,
     IDateTimeHelper dateTimeHelper,
     ILocalizationService localizationService,
     ICurrencyService currencyService,
     IOrderProcessingService orderProcessingService,
     IPriceFormatter priceFormatter,
     IDownloadService downloadService,
     IProductAttributeParser productAttributeParser,
     IProductService productService,
     ICountryService countryService,
     IAddressViewModelService addressViewModelService,
     IShipmentService shipmentService,
     IPaymentService paymentService,
     IGiftCardService giftCardService,
     IShippingService shippingService,
     IRewardPointsService rewardPointsService,
     IOrderTotalCalculationService orderTotalCalculationService,
     IServiceProvider serviceProvider,
     OrderSettings orderSettings,
     PdfSettings pdfSettings,
     TaxSettings taxSettings,
     CatalogSettings catalogSettings,
     ShippingSettings shippingSettings,
     RewardPointsSettings rewardPointsSettings)
 {
     _orderService                 = orderService;
     _storeContext                 = storeContext;
     _workContext                  = workContext;
     _dateTimeHelper               = dateTimeHelper;
     _localizationService          = localizationService;
     _currencyService              = currencyService;
     _orderProcessingService       = orderProcessingService;
     _priceFormatter               = priceFormatter;
     _downloadService              = downloadService;
     _productAttributeParser       = productAttributeParser;
     _productService               = productService;
     _countryService               = countryService;
     _addressViewModelService      = addressViewModelService;
     _shipmentService              = shipmentService;
     _paymentService               = paymentService;
     _giftCardService              = giftCardService;
     _shippingService              = shippingService;
     _rewardPointsService          = rewardPointsService;
     _orderTotalCalculationService = orderTotalCalculationService;
     _serviceProvider              = serviceProvider;
     _orderSettings                = orderSettings;
     _pdfSettings                  = pdfSettings;
     _taxSettings                  = taxSettings;
     _catalogSettings              = catalogSettings;
     _shippingSettings             = shippingSettings;
     _rewardPointsSettings         = rewardPointsSettings;
 }
示例#24
0
        private bool DoExportToPdf(string path)
        {
            var metadata = options.UseSavedMetadata ? pdfSettingsContainer.PdfSettings.Metadata : new PdfMetadata();

            metadata.Creator = ConsoleResources.NAPS2;
            if (options.PdfTitle != null)
            {
                metadata.Title = options.PdfTitle;
            }
            if (options.PdfAuthor != null)
            {
                metadata.Author = options.PdfAuthor;
            }
            if (options.PdfSubject != null)
            {
                metadata.Subject = options.PdfSubject;
            }
            if (options.PdfKeywords != null)
            {
                metadata.Keywords = options.PdfKeywords;
            }

            var encryption = options.UseSavedEncryptConfig ? pdfSettingsContainer.PdfSettings.Encryption : new PdfEncryption();

            if (options.EncryptConfig != null)
            {
                try
                {
                    using (Stream configFileStream = File.OpenRead(options.EncryptConfig))
                    {
                        var serializer = new XmlSerializer(typeof(PdfEncryption));
                        encryption = (PdfEncryption)serializer.Deserialize(configFileStream);
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorException(ConsoleResources.CouldntLoadEncryptionConfig, ex);
                    errorOutput.DisplayError(ConsoleResources.CouldntLoadEncryptionConfig);
                }
            }

            var pdfSettings = new PdfSettings {
                Metadata = metadata, Encryption = encryption
            };

            bool   useOcr          = !options.DisableOcr && (options.EnableOcr || options.OcrLang != null || userConfigManager.Config.EnableOcr);
            string ocrLanguageCode = useOcr ? (options.OcrLang ?? userConfigManager.Config.OcrLanguageCode) : null;

            return(pdfSaver.SavePdf(path, startTime, scannedImages, pdfSettings, ocrLanguageCode, i =>
            {
                OutputVerbose(ConsoleResources.ExportingPage, i, scannedImages.Count);
                return true;
            }));
        }
示例#25
0
        public QueuingEmailEventConsumer(
            PdfSettings pdfSettings,
            HttpRequestBase httpRequest,
            Lazy <FileDownloadManager> fileDownloadManager)
        {
            this._pdfSettings         = pdfSettings;
            this._httpRequest         = httpRequest;
            this._fileDownloadManager = fileDownloadManager;

            Logger = NullLogger.Instance;
            T      = NullLocalizer.Instance;
        }
示例#26
0
        public CreateAttachmentsConsumer(
            PdfSettings pdfSettings,
            HttpRequestBase httpRequest,
            Lazy <FileDownloadManager> fileDownloadManager)
        {
            this._pdfSettings         = pdfSettings;
            this._httpRequest         = httpRequest;
            this._fileDownloadManager = fileDownloadManager;

            Logger = NullLogger.Instance;
            T      = NullLocalizer.Instance;
        }
示例#27
0
 public PdfService(
     ILanguageService languageService,
     IWorkContext workContext,
     IDownloadService downloadService,
     IMediator mediator,
     PdfSettings pdfSettings)
 {
     _languageService = languageService;
     _workContext     = workContext;
     _downloadService = downloadService;
     _mediator        = mediator;
     _pdfSettings     = pdfSettings;
 }
示例#28
0
        public void CreatePDF(Stream stream)
        {
            // Get a temporary file where the web page will be rendered:
            var tmp = Path.GetTempFileName();
            // The Uri of the web page to render:
            var uri = new Uri(@"https://www.grapecity.com/documents-api-pdf/demos/view-source-cs/WordIndex/");
            // Image used in the footer template:
            var image = @"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAF8WlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphY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OhJg9aaShqiCNAxYV0S5G4FRiGrnud0JKxB2VZk8CFyEqBBSV4CcBkTFtbkFyskbdpfpfBdhOUvIzXI0RM2/GuBtE/qVNewm8DieQCypnsii7TOAD/i1if3JGgOFQIAwwhLHAU8isj89vf/qEMRNAm5AVJQbEPgfbZlv3OD+pJUAAAAASUVORK5CYII=";

            // Create a GcHtmlRenderer with the source Uri
            // (note that GcHtmlRenderer ctor and other HTML rendering methods accept either a Uri
            // specifying the HTML page to render, or a string which represents the actual HTML):
            using (var re = new GcHtmlRenderer(uri))
            {
                // PdfSettings allow to provide options for HTML to PDF conversion:
                // - PageRanges allows to skip the first page which is empty in this case.
                // - PageWidth/PageHeight allow to customize page size (defaults are used here for demo).
                // - Margins specify page margins (the default is no margins).
                // - IgnoreCSSPageSize makes sure page size specified here is used.
                // - Landscape allows to change page orientation.
                // - Scale allows to enlarge or reduce the render size (default is 1).
                // - To add custom headers, DisplayHeaderFooter needs to be set to true.
                // - HeaderTemplate/FooterTemplate allow to specify custom page headers.
                var pdfSettings = new PdfSettings()
                {
                    PageRanges          = "2-100",
                    PageWidth           = 8.5f,
                    PageHeight          = 11f,
                    Margins             = new Margins(0.2f, 1, 0.2f, 1),
                    IgnoreCSSPageSize   = true,
                    Landscape           = true,
                    DisplayHeaderFooter = true,
                    HeaderTemplate      = "<div style='-webkit-print-color-adjust:exact;background-color:#395daa;color:white;" +
                                          "padding:0.1in;font-size:12em;width:1000px;margin-left:0.2in;margin-right:0.2in'>" +
                                          "<span style='float:left'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></span>" +
                                          "<span style='float:right'>Document created on <span class='date'></span>" +
                                          "</div>",
                    FooterTemplate = "<div style='font-size:12em;width:1000px;margin-left:0.2in;margin-right:0.2in'>" +
                                     $"<span>Document location: <span class='url'></span><img style='float:right;' width='40' height='40' src='{image}'></img></div>"
                };
                // Render the source Web page to the temporary file:
                re.RenderToPdf(tmp, pdfSettings);
            }
            // Copy the created PDF from the temp file to target stream:
            using (var ts = File.OpenRead(tmp))
                ts.CopyTo(stream);
            // Clean up:
            File.Delete(tmp);
            // Done.
        }
示例#29
0
        public OrderController(IOrderService orderService,
                               IShipmentService shipmentService, IWorkContext workContext,
                               ICurrencyService currencyService, IPriceFormatter priceFormatter,
                               IOrderProcessingService orderProcessingService, IDateTimeHelper dateTimeHelper,
                               IPaymentService paymentService, ILocalizationService localizationService,
                               IPdfService pdfService, IShippingService shippingService,
                               ICountryService countryService, IProductAttributeParser productAttributeParser,
                               IWebHelper webHelper,
                               CatalogSettings catalogSettings, OrderSettings orderSettings,
                               TaxSettings taxSettings, PdfSettings pdfSettings,
                               ShippingSettings shippingSettings, AddressSettings addressSettings,
                               CustomerSettings customerSettings,
                               RewardPointsSettings rewardPointsSettings,
                               ForumSettings forumSettings,
                               IStoreContext storeContext,
                               MediaSettings mediaSettings,
                               ICacheManager cacheManager,
                               IPictureService pictureService,
                               IDiscountService discountService)
        {
            this._orderService           = orderService;
            this._shipmentService        = shipmentService;
            this._workContext            = workContext;
            this._currencyService        = currencyService;
            this._priceFormatter         = priceFormatter;
            this._orderProcessingService = orderProcessingService;
            this._dateTimeHelper         = dateTimeHelper;
            this._paymentService         = paymentService;
            this._localizationService    = localizationService;
            this._pdfService             = pdfService;
            this._shippingService        = shippingService;
            this._countryService         = countryService;
            this._productAttributeParser = productAttributeParser;
            this._webHelper = webHelper;

            this._catalogSettings      = catalogSettings;
            this._orderSettings        = orderSettings;
            this._taxSettings          = taxSettings;
            this._pdfSettings          = pdfSettings;
            this._shippingSettings     = shippingSettings;
            this._addressSettings      = addressSettings;
            this._customerSettings     = customerSettings;
            this._rewardPointsSettings = rewardPointsSettings;
            this._forumSettings        = forumSettings;
            this._storeContext         = storeContext;
            this._mediaSettings        = mediaSettings;
            this._cacheManager         = cacheManager;
            this._pictureService       = pictureService;
            this._discountService      = discountService;
        }
示例#30
0
        public OrderModelFactory(IAddressModelFactory addressModelFactory,
                                 IOrderService orderService,
                                 IWorkContext workContext,
                                 ICurrencyService currencyService,
                                 IPriceFormatter priceFormatter,
                                 IOrderProcessingService orderProcessingService,
                                 IDateTimeHelper dateTimeHelper,
                                 IPaymentService paymentService,
                                 ILocalizationService localizationService,

                                 ICountryService countryService,
                                 IProductAttributeParser productAttributeParser,
                                 IDownloadService downloadService,
                                 IStoreContext storeContext,
                                 IOrderTotalCalculationService orderTotalCalculationService,
                                 IRewardPointService rewardPointService,
                                 CatalogSettings catalogSettings,
                                 OrderSettings orderSettings,
                                 TaxSettings taxSettings,

                                 AddressSettings addressSettings,
                                 RewardPointsSettings rewardPointsSettings,
                                 PdfSettings pdfSettings)
        {
            this._addressModelFactory    = addressModelFactory;
            this._orderService           = orderService;
            this._workContext            = workContext;
            this._currencyService        = currencyService;
            this._priceFormatter         = priceFormatter;
            this._orderProcessingService = orderProcessingService;
            this._dateTimeHelper         = dateTimeHelper;
            this._paymentService         = paymentService;
            this._localizationService    = localizationService;

            this._countryService               = countryService;
            this._productAttributeParser       = productAttributeParser;
            this._downloadService              = downloadService;
            this._storeContext                 = storeContext;
            this._orderTotalCalculationService = orderTotalCalculationService;
            this._rewardPointService           = rewardPointService;

            this._catalogSettings = catalogSettings;
            this._orderSettings   = orderSettings;
            this._taxSettings     = taxSettings;

            this._addressSettings      = addressSettings;
            this._rewardPointsSettings = rewardPointsSettings;
            this._pdfSettings          = pdfSettings;
        }