public OrderModuleController( ICustomerOrderService customerOrderService , ICustomerOrderSearchService searchService , IStoreService storeService , IUniqueNumberGenerator numberGenerator , IPlatformMemoryCache platformMemoryCache , Func <IOrderRepository> repositoryFactory , ICustomerOrderBuilder customerOrderBuilder , IShoppingCartService cartService , IChangeLogSearchService changeLogSearchService , INotificationTemplateRenderer notificationTemplateRenderer , INotificationSearchService notificationSearchService , ICustomerOrderTotalsCalculator totalsCalculator , IAuthorizationService authorizationService , IConverter converter , IOptions <HtmlToPdfOptions> htmlToPdfOptions , IOptions <MvcNewtonsoftJsonOptions> jsonOptionsAccessor) { _customerOrderService = customerOrderService; _searchService = searchService; _uniqueNumberGenerator = numberGenerator; _storeService = storeService; _platformMemoryCache = platformMemoryCache; _repositoryFactory = repositoryFactory; _customerOrderBuilder = customerOrderBuilder; _cartService = cartService; _changeLogSearchService = changeLogSearchService; _notificationTemplateRenderer = notificationTemplateRenderer; _notificationSearchService = notificationSearchService; _totalsCalculator = totalsCalculator; _authorizationService = authorizationService; _htmlToPdfOptions = htmlToPdfOptions.Value; _converter = converter; _jsonOptions = jsonOptionsAccessor.Value; }
static void Main(string[] args) { RectangleF rectf = new RectangleF(0.5f, 0.5f, 7.5f, 10f); var serialisedRectf = JsonConvert.SerializeObject(rectf); var htmlOptions = new HtmlToPdfOptions { MaxLoadWaitTime = 50000, UserStyleSheet = "table tr td{font-size:14px!important;} p{font-size:16px!important; line-height:26px!important} .action{display:none} #main-nav{display:none} .e-shad{box-shadow:none; border:1px solid lightgray}", VisibleElementIds = "main-content", InvisibleElementIds = "siblings-nav;control-panel", OutputArea = rectf }; PdfDocument ResultDocument = new PdfDocument(); List <string> urls = new List <string>(); //urls.Add(@"https://economy.id.com.au/monash/population"); //urls.Add(@"http://economy-next.id.com.au:9090/monash"); urls.Add(@"https://economy.id.com.au/alpine/population"); //urls.Add(@"https://econext-dev.azurewebsites.net/monash/population?WebID=10"); //urls.Add(@"http://economy.idcommdev.idc.local/monash/population"); //urls.Add(@"https://reportwebah.azurewebsites.net/ReportCoverPage/Get?Product=profile&Title=test%20title&ClientAlias=monash&ClientDisplayName=city%20of%20monash&ClientId=102"); //urls.Add(@"file:///C:/Users/fabrice/Documents/Workspace/IDReportCoverPage/index.html?alias=monash&prettyname=City%20of%20Monash&title=report%20title&product=profile"); foreach (var url in urls) { HtmlToPdf.ConvertUrl(url, ResultDocument, htmlOptions); } ///// Economy space ///// var ehtmlOptions = new HtmlToPdfOptions { MaxLoadWaitTime = 50000 }; List <string> eurls = new List <string>(); //eurls.Add(@"https://economy.local.com.au/monash/gross-product?pdf=1"); //// Add urls here foreach (var url in eurls) { HtmlToPdf.ConvertUrl(url, ResultDocument, ehtmlOptions); } Guid g = Guid.NewGuid(); ResultDocument.Save($"c://temp/{g}.pdf"); }
public PdfConvertor() { this.Document = new PdfDocument(); this.Options = new StandardA4(); EO.Pdf.Runtime.AddLicense( "eJ2X+Aob5HaZyeDZz53dprEh5Kvq7QAZvFusssHNn2i1kZvLn1mXwMAM66Xm" + "+8+4iVmXpLHn7qvb6QP07Z/mpPUM8560psjatmiptMLfoVnt6QMe6KjlwbPg" + "oVmmwp61n1mXpM0e6KDl5QUg8Z61190f6bHD8PPdzaHY+wsC9pPZ2fnu5na0" + "wMAe6KDl5QUg8Z61kZvnrqXg5/YZ8p61kZt14+30EO2s3MKetZ9Zl6TNF+ic" + "3PIEEMidtbjHA7ZqrrbC/tJsrrrK47CBs7P9FOKe5ff29ON3hI6xy59Zs/D6" + "DuSn6un26cKh6e0Ey9Ka7eX4ELto4+30EO2s3OnPuIlZl6Sx5+Cl4/MI6YxD" + "l6Sxy59Zl6TNDOM="); }
/// <summary> /// Initialise the parameters of the conversion, /// using the class parameters and the given parameters /// </summary> /// <param name="options">custom user parameter values</param> /// <returns>An HtmlToPdfOptions object</returns> private static HtmlToPdfOptions InitParameters(string html, HtmlToPdfConverterOptions options) { var parameters = (HtmlToPdfConverterOptions)Options.Clone(); if (options != null) { parameters.BaseUrl = options.BaseUrl ?? parameters.BaseUrl; parameters.ExportControl = string.IsNullOrEmpty(options.ExportControl) ? parameters.ExportControl : options.ExportControl; parameters.ExportClassification = string.IsNullOrEmpty(options.ExportClassification) ? parameters.ExportClassification : options.ExportClassification; parameters.OutputArea = options.OutputArea.IsEmpty ? parameters.OutputArea : options.OutputArea; parameters.PageSize = options.PageSize.IsEmpty ? parameters.PageSize : options.PageSize; parameters.RepeatTableHeaderFooter = options.RepeatTableHeaderFooter ?? parameters.RepeatTableHeaderFooter; parameters.Timeout = options.Timeout ?? parameters.Timeout; parameters.VisibleElementIds = options.VisibleElementIds.Length == 0 ? parameters.VisibleElementIds : options.VisibleElementIds; parameters.InvisibleElementIds = options.InvisibleElementIds.Length == 0 ? parameters.InvisibleElementIds : options.InvisibleElementIds; } // Try to parse the HTML source as XML. XDocument doc = null; try { doc = XDocument.Parse(html); } catch (Exception) { } // Build the HTML header if the source HTML could be parsed as XML. var header = (doc != null) ? BuildHeader(doc) : string.Empty; // Build the HTML footer. var footer = BuildFooter(parameters); // Options that are always set var opts = new HtmlToPdfOptions { PageSize = parameters.PageSize, OutputArea = parameters.OutputArea, NoLink = true, RepeatTableHeaderAndFooter = parameters.RepeatTableHeaderFooter ?? true, FooterHtmlPosition = parameters.PageSize.Height - _regionAfter, FooterHtmlFormat = footer, HeaderHtmlPosition = 0F, HeaderHtmlFormat = header, }; // BaseUrl if (parameters.BaseUrl != null) { opts.BaseUrl = parameters.BaseUrl.AbsoluteUri; } // Handling of the visible ids list if (parameters.VisibleElementIds != null && parameters.VisibleElementIds.Length > 0) { opts.VisibleElementIds = string.Join(";", parameters.VisibleElementIds); } // Handling of the invisible ids list if (parameters.InvisibleElementIds != null && parameters.InvisibleElementIds.Length > 0) { opts.InvisibleElementIds = string.Join(";", parameters.InvisibleElementIds); } return(opts); }