Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
Use scryber.core pdf engine (#353)
Krzysztof Pajak92b785cff119
diff --git a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj b/src/Business/Grand.Business.Common/Grand.Business.Common.csprojindex 8b935383c..c5d595137 100644--- a/src/Business/Grand.Business.Common/Grand.Business.Common.csproj+++ b/src/Business/Grand.Business.Common/Grand.Business.Common.csproj@@ -1,9 +1,10 @@<Project Sdk="Microsoft.NET.Sdk"><Import Project="..\..\Build\Grand.Common.props" /><ItemGroup>- <PackageReference Include="HtmlRendererCore.PdfSharp" Version="1.0.5" /><PackageReference Include="ExcelMapper" Version="5.2.472" /><PackageReference Include="NPOI" Version="2.6.0" />+ <PackageReference Include="Scryber.Core.Mvc" Version="6.0.0.14-beta" />+ <PackageReference Include="Scryber.Core.OpenType" Version="6.0.0.5-beta" /></ItemGroup><ItemGroup><ProjectReference Include="..\..\Core\Grand.Domain\Grand.Domain.csproj" />diff --git a/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs b/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.csindex 13f047ac5..2bae5b43e 100644--- a/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs+++ b/src/Business/Grand.Business.Common/Services/Pdf/HtmlToPdfService.cs@@ -5,7 +5,6 @@ using Grand.Domain.Media;using Grand.Domain.Orders;using Grand.Domain.Shipping;using Grand.SharedKernel.Extensions;-using HtmlRendererCore.PdfSharp;namespace Grand.Business.Common.Services.Pdf{@@ -31,17 +30,8 @@ namespace Grand.Business.Common.Services.Pdf_storeFilesContext = storeFilesContext;}- private PdfGenerateConfig PdfConfig()- {- var config = new PdfGenerateConfig {- PageSize = PdfSharpCore.PageSize.A4- };- config.SetMargins(20);- config.PageOrientation = PdfSharpCore.PageOrientation.Portrait;- return config;- }-- public async Task PrintOrdersToPdf(Stream stream, IList<Order> orders, string languageId = "", string vendorId = "")+ public async Task PrintOrdersToPdf(Stream stream, IList<Order> orders, string languageId = "",+ string vendorId = ""){if (stream == null)throw new ArgumentNullException(nameof(stream));@@ -49,9 +39,11 @@ namespace Grand.Business.Common.Services.Pdfif (orders == null)throw new ArgumentNullException(nameof(orders));- var html = await _viewRenderService.RenderToStringAsync<(IList<Order>, string)>(OrderTemplate, new(orders, vendorId));- var pdf = PdfGenerator.GeneratePdf(html, PdfConfig());- pdf.Save(stream);+ var html = await _viewRenderService.RenderToStringAsync<(IList<Order>, string)>(OrderTemplate,+ new(orders, vendorId));+ TextReader sr = new StringReader(html);+ using var doc = Scryber.Components.Document.ParseDocument(sr, Scryber.ParseSourceType.DynamicContent);+ doc.SaveAsPDF(stream);}public async Task<string> PrintOrderToPdf(Order order, string languageId, string vendorId = "")@@ -64,15 +56,15 @@ namespace Grand.Business.Common.Services.Pdfvar dir = CommonPath.WebMapPath("assets/files/exportimport");if (dir == null)throw new ArgumentNullException(nameof(dir));-+if (!System.IO.Directory.Exists(dir)){System.IO.Directory.CreateDirectory(dir);}+var filePath = Path.Combine(dir, fileName);await using var fileStream = new FileStream(filePath, FileMode.Create);- var orders = new List<Order>- {+ var orders = new List<Order> {order};await PrintOrdersToPdf(fileStream, orders, languageId, vendorId);@@ -92,8 +84,9 @@ namespace Grand.Business.Common.Services.Pdfthrow new ArgumentException($"Cannot load language. ID={languageId}");var html = await _viewRenderService.RenderToStringAsync<IList<Shipment>>(ShipmentsTemplate, shipments);- var pdf = PdfGenerator.GeneratePdf(html, PdfConfig());- pdf.Save(stream);+ TextReader sr = new StringReader(html);+ using var doc = Scryber.Components.Document.ParseDocument(sr, Scryber.ParseSourceType.DynamicContent);+ doc.SaveAsPDF(stream);}public async Task<string> SaveOrderToBinary(Order order, string languageId, string vendorId = "")@@ -103,8 +96,7 @@ namespace Grand.Business.Common.Services.Pdfvar fileName = $"order_{order.OrderGuid}_{CommonHelper.GenerateRandomDigitCode(4)}";using MemoryStream ms = new MemoryStream();- var orders = new List<Order>- {+ var orders = new List<Order> {order};await PrintOrdersToPdf(ms, orders, languageId, vendorId);@@ -121,5 +113,4 @@ namespace Grand.Business.Common.Services.Pdfreturn download.Id;}}--}+}\ No newline at end of filediff --git a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtmlindex 18edf84c0..8fd278421 100644--- a/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml+++ b/src/Web/Grand.Web/Views/PdfTemplates/OrderPdfTemplate.cshtml@@ -1,4 +1,4 @@-@using Grand.Business.Core.Interfaces.Catalog.Products+@using Grand.Business.Core.Interfaces.Catalog.Products@using Grand.Business.Core.Interfaces.Checkout.GiftVouchers@using Grand.Business.Core.Interfaces.Checkout.Payments@using Grand.Business.Core.Interfaces.Common.Directory@@ -24,27 +24,8 @@<head><title></title><style>-- .orderItems {- width: 100%;- border: 1px solid black;- }-- .orderItems tr th {- background-color: #f5f5f5;- text-align: left;- padding: 0 5px 0 5px;- }-- .orderItems tr,- .orderItems tr td,- .orderItems tr th {- border: 1px solid black;- padding: 0 5px 0 5px;- }-.summary {- margin-top: 20px;+ padding-top:20px;}.footer {@@ -52,9 +33,84 @@bottom: 0;width: 100%;}+++ /* https://www.w3schools.com/html/html_table_borders.asp */+ table.CodeTable {+ width: 100%;+ }+ .CodeTable .line {border-bottom:1px solid #EEE; border-top: 1px solid #EEE; border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF;}+ table.CodeTable th,+ table.CodeTable td {+ /* width: 100%; */+ /*border: 0px solid black;*/+ border: none;+ border-collapse: collapse;+ }+ .Header {+ background-color: grey;+ color: white;+ padding: 5px;+ }++ table.Table {+ width: 100%;+ }+ table.Table,+ table.Table th,+ table.Table td {+ /*white-space: nowrap;*/+ text-align: left;+ /* border: 1px solid black; */+ border-collapse: collapse;+ }+ table.Table th,+ table.Table td {+ padding: 12px 8px 3px;+ text-align: right;+ }+ table.Table th.leftalign,+ table.Table td.leftalign {+ text-align: left;+ }+ table.Table th {+ padding-top: 5px;+ padding-bottom: 5px;+ border-bottom: 1px solid black;+ }+ table.Table th.first,+ table.Table td.first {+ text-align: left;+ width: 30px;+ }+ table.Table th.autoWidth,+ table.Table td.autoWidth {+ width: 400px;+ }+ table.Table th.detailText,+ table.Table td.detailText {+ font-size: 10px;+ padding-top: 3px;+ padding-bottom: 2px;+ }+ .bold {+ font-weight: bold;+ }+ table.Table tfoot {+ padding-top: 4px;+ border-top: 1px solid black;+ border-bottom: 1px solid black;+ }+ table.Table tfoot tr,+ table.Table tfoot td {+ padding-top: 4px;+ padding-bottom: 4px;+ }+</style></head><body>+<main style="padding:10pt; font-size:14px">@{var i = 0;}@@ -64,130 +120,187 @@var store = await _storeService.GetStoreById(order.StoreId);if (!string.IsNullOrEmpty(_pdfSettings.InvoiceHeaderText)){- <div> @Html.Raw(_pdfSettings.InvoiceHeaderText)</div>+ <div>@Html.Raw(_pdfSettings.InvoiceHeaderText)</div>}- <h2>@store.CompanyName</h2>+ <h4>@store.CompanyName</h4>if (logoExists){- var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.Url);- <div><img src="@url" alt="logo" title="logo" /></div>+ var url = await _pictureService.GetPictureUrl(logoPicture, 0, false, store.SslEnabled ? store.SecureUrl : store.Url);+ <div style="float: right; top:10px;">+ <img src="@url" title="logo" alt="logo"/>+ </div>}- <h3>@(string.Format(_translationService.GetResource("PDFInvoice.Order#", order.CustomerLanguageId), order.OrderNumber))</h3>- <table>+ <h6>@(string.Format(_translationService.GetResource("PDFInvoice.Order#", order.CustomerLanguageId), order.OrderNumber)) (@order.CreatedOnUtc)</h6>+ <table class="CodeTable"><tr>- <td style="border-style: none; width:50%;">+ <td class="line">@if (order.BillingAddress != null){- <ul style="list-style-type:none">- <li><b>@(_translationService.GetResource("PDFInvoice.BillingInformation", order.CustomerLanguageId))</b></li>- @if (!string.IsNullOrEmpty(order.BillingAddress.Company))- {- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Company", order.CustomerLanguageId), order.BillingAddress.Company))</li>- }- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Name", order.CustomerLanguageId), order.BillingAddress.FirstName + " " + order.BillingAddress.LastName))</li>- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Phone", order.CustomerLanguageId), order.BillingAddress.PhoneNumber))</li>- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Address", order.CustomerLanguageId), order.BillingAddress.Address1))</li>- <li>@(order.BillingAddress.City + ", " + order.BillingAddress.ZipPostalCode)</li>- <li>@((await _countryService.GetCountryById(order.BillingAddress.CountryId))?.Name)</li>- @{- var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);- var paymentMethodStr = paymentMethod != null ? paymentMethod.FriendlyName : order.PaymentMethodSystemName;- }- <li>@(string.Format(_translationService.GetResource("PDFInvoice.PaymentMethod", order.CustomerLanguageId), paymentMethodStr))</li>- @await Component.InvokeAsync("Widget", new { widgetZone = "pdf_payment_method_below", additionalData = order.Id })- </ul>+ <b>@(_translationService.GetResource("PDFInvoice.BillingInformation", order.CustomerLanguageId))</b>+ <br/>+ @if (!string.IsNullOrEmpty(order.BillingAddress.Company))+ {+ @(string.Format(_translationService.GetResource("PDFInvoice.Company", order.CustomerLanguageId), order.BillingAddress.Company))<br/>+ }+ @(string.Format(_translationService.GetResource("PDFInvoice.Name", order.CustomerLanguageId), order.BillingAddress.FirstName + " " + order.BillingAddress.LastName))<br/>+ @(string.Format(_translationService.GetResource("PDFInvoice.Phone", order.CustomerLanguageId), order.BillingAddress.PhoneNumber))<br/>+ @(string.Format(_translationService.GetResource("PDFInvoice.Address", order.CustomerLanguageId), order.BillingAddress.Address1))<br/>+ @(order.BillingAddress.City + ", " + order.BillingAddress.ZipPostalCode)<br/>+ @((await _countryService.GetCountryById(order.BillingAddress.CountryId))?.Name)<br/>+ <br/>+ var paymentMethod = _paymentService.LoadPaymentMethodBySystemName(order.PaymentMethodSystemName);+ var paymentMethodStr = paymentMethod != null ? paymentMethod.FriendlyName : order.PaymentMethodSystemName;+ <b>@(string.Format(_translationService.GetResource("PDFInvoice.PaymentMethod", order.CustomerLanguageId), paymentMethodStr))</b><br/>+ @await Component.InvokeAsync("Widget", new { widgetZone = "pdf_payment_method_below", additionalData = order.Id })+}</td>- <td style="border-style: none; width:50%;">+ <td class="line">@if (order.ShippingAddress != null){- <ul style="list-style-type:none">- <li><b>@(_translationService.GetResource("PDFInvoice.ShippingInformation", order.CustomerLanguageId))</b></li>- @if (!string.IsNullOrEmpty(order.ShippingAddress.Company))- {- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Company", order.CustomerLanguageId), order.ShippingAddress.Company))</li>- }- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Name", order.CustomerLanguageId), order.ShippingAddress.FirstName + " " + order.ShippingAddress.LastName))</li>- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Phone", order.CustomerLanguageId), order.ShippingAddress.PhoneNumber))</li>- <li>@(string.Format(_translationService.GetResource("PDFInvoice.Address", order.CustomerLanguageId), order.ShippingAddress.Address1))</li>- <li>@(order.ShippingAddress.City + ", " + order.ShippingAddress.ZipPostalCode)</li>- <li>@((await _countryService.GetCountryById(order.ShippingAddress.CountryId))?.Name)</li>- <li>@(string.Format(_translationService.GetResource("PDFInvoice.ShippingMethod", order.CustomerLanguageId), order.ShippingMethod))</li>- </ul>+ <b>@(_translationService.GetResource("PDFInvoice.ShippingInformation", order.CustomerLanguageId))</b>+ <br/>+ @if (!string.IsNullOrEmpty(order.ShippingAddress.Company))+ {+ @(string.Format(_translationService.GetResource("PDFInvoice.Company", order.CustomerLanguageId), order.ShippingAddress.Company))<br/>+ }+ @(string.Format(_translationService.GetResource("PDFInvoice.Name", order.CustomerLanguageId), order.ShippingAddress.FirstName + " " + order.ShippingAddress.LastName))<br/>+ @(string.Format(_translationService.GetResource("PDFInvoice.Phone", order.CustomerLanguageId), order.ShippingAddress.PhoneNumber))<br/>+ @(string.Format(_translationService.GetResource("PDFInvoice.Address", order.CustomerLanguageId), order.ShippingAddress.Address1))<br/>+ @(order.ShippingAddress.City + ", " + order.ShippingAddress.ZipPostalCode)<br/>+ @((await _countryService.GetCountryById(order.ShippingAddress.CountryId))?.Name)<br/>+ <br/>+ <b>@(string.Format(_translationService.GetResource("PDFInvoice.ShippingMethod", order.CustomerLanguageId), order.ShippingMethod))</b><br/>}</td></tr></table>- <div style="display:block; clear:both;"></div><div class="summary">- <h3>@(_translationService.GetResource("PDFInvoice.Product(s)", order.CustomerLanguageId))</h3>+ @(_translationService.GetResource("PDFInvoice.Product(s)", order.CustomerLanguageId))</div>- <table class="orderItems">+ <table class="Table"><tr>- <th>@(_translationService.GetResource("PDFInvoice.ProductName", order.CustomerLanguageId))</th>- <th>@(_translationService.GetResource("PDFInvoice.ProductPrice", order.CustomerLanguageId))</th>- <th>@(_translationService.GetResource("PDFInvoice.ProductQuantity", order.CustomerLanguageId))</th>- <th>@(_translationService.GetResource("PDFInvoice.ProductTotal", order.CustomerLanguageId))</th>+ <td class="Header leftalign" colspan="2">@(_translationService.GetResource("PDFInvoice.ProductName", order.CustomerLanguageId))</td>+ <td class="Header">@(_translationService.GetResource("PDFInvoice.ProductPrice", order.CustomerLanguageId))</td>+ <td class="Header">@(_translationService.GetResource("PDFInvoice.ProductQuantity", order.CustomerLanguageId))</td>+ <td class="Header">@(_translationService.GetResource("PDFInvoice.ProductTotal", order.CustomerLanguageId))</td></tr>@foreach (var item in order.OrderItems.Where(x => x.VendorId == Model.Item2 || !limitbyVendor).ToList()){<tr>- <td>+ <td class="autoWidth leftalign" colspan="2">@((await _productService.GetProductByIdIncludeArch(item.ProductId)).Name)@if (!string.IsNullOrEmpty(item.AttributeDescription)){- <br />+ <br/><small>@(Html.Raw(item.AttributeDescription))</small>}</td>- <td>@if(priceIncludesTax){@item.UnitPriceInclTax}else{@item.UnitPriceExclTax}</td>- <td>@item.Quantity</td>- <td>@if(priceIncludesTax){@item.PriceInclTax}else{@item.PriceExclTax}</td>- </tr>- }- </table>- @if (!limitbyVendor)- {- <div class="summary">- <hr />- <div class="right">- <ul style="list-style-type:none">- <li>@(_translationService.GetResource("PDFInvoice.Sub-Total", order.CustomerLanguageId))@if(priceIncludesTax){ @order.OrderSubtotalInclTax}else{ @order.OrderSubtotalExclTax} @order.CustomerCurrencyCode</li>- @if (order.OrderSubTotalDiscountInclTax > 0||order.OrderSubTotalDiscountExclTax > 0)+ <td>+ @if (priceIncludesTax){- <li>@(_translationService.GetResource("PDFInvoice.Discount", order.CustomerLanguageId)) @if(priceIncludesTax){ @order.OrderSubTotalDiscountInclTax}else{ @order.OrderSubTotalDiscountExclTax} @order.CustomerCurrencyCode</li>+ @item.UnitPriceInclTax.ToString("N2")}- @if (order.PaymentMethodAdditionalFeeInclTax > 0 ||order.PaymentMethodAdditionalFeeExclTax > 0)+ else{- <li>@(_translationService.GetResource("PDFInvoice.PaymentmethodAdditionalFee", order.CustomerLanguageId)) @if(priceIncludesTax){@order.PaymentMethodAdditionalFeeInclTax}else{ @order.PaymentMethodAdditionalFeeExclTax} @order.CustomerCurrencyCode</li>+ @item.UnitPriceExclTax.ToString("N2")}- <li>@(_translationService.GetResource("PDFInvoice.Shipping", order.CustomerLanguageId)) @if(priceIncludesTax){@order.OrderShippingInclTax}else{ @order.PaymentMethodAdditionalFeeExclTax} @order.OrderShippingExclTax @order.CustomerCurrencyCode</li>- @if (order.OrderDiscount > 0)+ </td>+ <td>@item.Quantity</td>+ <td class="bold">+ @if (priceIncludesTax){- <li>@(_translationService.GetResource("PDFInvoice.Discount", order.CustomerLanguageId)) @order.OrderDiscount @order.CustomerCurrencyCode</li>+ @item.PriceInclTax.ToString("N2")}- @foreach (var gcuh in await _giftVoucherService.GetAllGiftVoucherUsageHistory(order.Id))+ else{- if (gcuh.UsedValue > 0)- {- var giftvoucher = await _giftVoucherService.GetGiftVoucherById(gcuh.GiftVoucherId);- <li>@(string.Format(_translationService.GetResource("PDFInvoice.GiftVoucherInfo", order.CustomerLanguageId), giftvoucher.Code)) @gcuh.UsedValue</li>- }+ @item.PriceExclTax.ToString("N2")}- @if (order.OrderTax > 0)+ </td>+ </tr>+ }+ </table>+ @if (!limitbyVendor)+ {+ <div class="summary">++ <div style="float: right">++ @(_translationService.GetResource("PDFInvoice.Sub-Total", order.CustomerLanguageId))+ @if (priceIncludesTax)+ {+ @order.OrderSubtotalInclTax.ToString("N2")+ }+ else+ {+ @order.OrderSubtotalExclTax.ToString("N2")+ }+ @order.CustomerCurrencyCode <br/>+ @if (order.OrderSubTotalDiscountInclTax > 0 || order.OrderSubTotalDiscountExclTax > 0)+ {+ @(_translationService.GetResource("PDFInvoice.Discount", order.CustomerLanguageId)) @if (priceIncludesTax)+ {+ @order.OrderSubTotalDiscountInclTax.ToString("N2")+ }+ else+ {+ @order.OrderSubTotalDiscountExclTax.ToString("N2")+ }+ @order.CustomerCurrencyCode+ }+ @if (order.PaymentMethodAdditionalFeeInclTax > 0 || order.PaymentMethodAdditionalFeeExclTax > 0)+ {+ @(_translationService.GetResource("PDFInvoice.PaymentmethodAdditionalFee", order.CustomerLanguageId)) @if (priceIncludesTax)+ {+ @order.PaymentMethodAdditionalFeeInclTax.ToString("N2")+ }+ else+ {+ @order.PaymentMethodAdditionalFeeExclTax.ToString("N2")+ }+ @order.CustomerCurrencyCode<br/>+ }+ @(_translationService.GetResource("PDFInvoice.Shipping", order.CustomerLanguageId))+ @if (priceIncludesTax)+ {+ @order.OrderShippingInclTax.ToString("N2")+ }+ else+ {+ @order.OrderShippingExclTax.ToString("N2")+ }+ @order.CustomerCurrencyCode<br/>+ @if (order.OrderDiscount > 0)+ {+ @(_translationService.GetResource("PDFInvoice.Discount", order.CustomerLanguageId))+ @order.OrderDiscount.ToString("N2")+ @order.CustomerCurrencyCode<br/>+ }+ @foreach (var gcuh in await _giftVoucherService.GetAllGiftVoucherUsageHistory(order.Id))+ {+ if (gcuh.UsedValue > 0){- <li>@(_translationService.GetResource("PDFInvoice.Tax", order.CustomerLanguageId)) @order.OrderTax @order.CustomerCurrencyCode</li>+ var giftvoucher = await _giftVoucherService.GetGiftVoucherById(gcuh.GiftVoucherId);+ @(string.Format(_translationService.GetResource("PDFInvoice.GiftVoucherInfo", order.CustomerLanguageId), giftvoucher.Code))+ @gcuh.UsedValue<br/>}- <li>@(_translationService.GetResource("PDFInvoice.OrderTotal", order.CustomerLanguageId)) @order.OrderTotal @order.CustomerCurrencyCode</li>- </ul>+ }+ @if (order.OrderTax > 0)+ {+ @(_translationService.GetResource("PDFInvoice.Tax", order.CustomerLanguageId))+ @order.OrderTax.ToString("N2")+ @order.CustomerCurrencyCode<br/>+ }+ <b>@(_translationService.GetResource("PDFInvoice.OrderTotal", order.CustomerLanguageId)) @order.OrderTotal.ToString("N2") @order.CustomerCurrencyCode<br/></b>+</div></div>}if (!string.IsNullOrEmpty(_pdfSettings.InvoiceFooterText)){<footer class="footer">- @Html.Raw(_pdfSettings.InvoiceFooterText)+ @Html.Raw(_pdfSettings.InvoiceFooterText)</footer>}if (Model.Item1.Count - 1 > i)@@ -196,6 +309,6 @@}i++;}-+</main></body>-</html>\ No newline at end of file+</html>diff --git a/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml b/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtmlindex f673ce178..26a5c4ebe 100644--- a/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml+++ b/src/Web/Grand.Web/Views/PdfTemplates/ShipmentPdfTemplate.cshtml@@ -1,113 +1,124 @@-@using Grand.Business.Core.Interfaces.Checkout.Orders-@using Grand.Business.Core.Interfaces.Checkout.Payments-@using Grand.Business.Core.Interfaces.Checkout.Shipping-@using Grand.Business.Core.Interfaces.Common.Configuration+@using Grand.Business.Core.Interfaces.Checkout.Orders@using Grand.Business.Core.Interfaces.Common.Directory@using Grand.Business.Core.Interfaces.Common.Localization-@using Grand.Business.Core.Interfaces.Common.Stores-@using Grand.Business.Core.Interfaces.Storage@using Grand.Business.Core.Interfaces.Catalog.Products-@using Grand.Business.Core.Interfaces.Checkout.GiftVouchers@model IList<Grand.Domain.Shipping.Shipment>@inject IOrderService _orderService-@inject IShipmentService _shipmentService-@inject ICountryService _cournyService@inject IProductService _productService@inject ICountryService _countryService-@inject ISettingService _settingService-@inject IStoreService _storeService@inject IWorkContext _workContext-@inject IPictureService _pictureService-@inject PdfSettings _pdfSettings@inject ITranslationService _translationService-@inject IPaymentService _paymentService-@inject ICurrencyService _currencyService-@inject IGiftVoucherService _giftVoucherService@{var companyName = _workContext.CurrentStore.CompanyName;var limitbyVendor = _workContext.CurrentVendor != null;}---<html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><style>-- .orderItems {- width: 100%;- border: 1px solid black;- }-- .orderItems tr th {- background-color: #f5f5f5;- text-align: left;- padding: 0 5px 0 5px;- }-- .orderItems tr,- .orderItems tr td,- .orderItems tr th {- border: 1px solid black;- padding: 0 5px 0 5px;- }-.summary {- margin-top: 20px;- }+ padding-top:20px;+ }++ table.CodeTable th,+ table.CodeTable td {+ /* width: 100%; */+ width: 400px;+ margin-right: 0px;+ margin-left: auto;+ white-space: nowrap;+ /* border: 1px solid black; */+ border: none;+ border-collapse: collapse;+ }+ .Header {+ background-color: grey;+ color: white;+ padding: 5px;+ }++ table.Table {+ width: 100%;+ }+ table.Table,+ table.Table th,+ table.Table td {+ white-space: nowrap;+ text-align: left;+ /* border: 1px solid black; */+ border-collapse: collapse;+ }+ table.Table th,+ table.Table td {+ padding-top: 12px;+ padding-bottom: 3px;+ padding-left: 8px;+ padding-right: 8px;+ text-align: right;+ }+ table.Table th {+ padding-top: 5px;+ padding-bottom: 5px;+ border-bottom: 1px solid black; ;+ }- .right {- float: right;- }- </style>+ table.Table tfoot {+ padding-top: 4px;+ border-top: 1px solid black;+ border-bottom: 1px solid black;+ }+ table.Table tfoot tr,+ table.Table tfoot td {+ padding-top: 4px;+ padding-bottom: 4px;+ }++ </style></head><body>+ <main style="padding:10pt; font-size:12px">@for (var i = 0; i < Model.Count; i++){var order = await _orderService.GetOrderById(Model[i].OrderId);var shipment = Model[i];<div>- <h2>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Shipment", order.CustomerLanguageId), shipment.ShipmentNumber))</h2>+ <h4>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Shipment", order.CustomerLanguageId), shipment.ShipmentNumber))</h4><div>@companyName</div></div>@if (order.ShippingAddress != null){<div>- <h3>@(_translationService.GetResource("PDFInvoice.ShippingInformation", order.CustomerLanguageId))</h3>- <ul style="list-style-type:none">+ <h6>@(_translationService.GetResource("PDFInvoice.ShippingInformation", order.CustomerLanguageId))</h6>@if (!string.IsNullOrEmpty(order.ShippingAddress.Company)){- <li>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Company", order.CustomerLanguageId), order.ShippingAddress.Company))</li>+ @(string.Format(_translationService.GetResource("PDFPackagingSlip.Company", order.CustomerLanguageId), order.ShippingAddress.Company))<br/>}- <li>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Name", order.CustomerLanguageId), order.ShippingAddress.FirstName + " " + order.ShippingAddress.LastName))</li>- <li>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Phone", order.CustomerLanguageId), order.ShippingAddress.PhoneNumber))</li>- <li>@(string.Format(_translationService.GetResource("PDFPackagingSlip.Address", order.CustomerLanguageId), order.ShippingAddress.Address1))</li>- <li>@(order.ShippingAddress.City + ", " + order.ShippingAddress.ZipPostalCode)</li>- <li>@((await _countryService.GetCountryById(order.ShippingAddress.CountryId))?.Name)</li>- </ul>+ @(string.Format(_translationService.GetResource("PDFPackagingSlip.Name", order.CustomerLanguageId), order.ShippingAddress.FirstName + " " + order.ShippingAddress.LastName))<br/>+ @(string.Format(_translationService.GetResource("PDFPackagingSlip.Phone", order.CustomerLanguageId), order.ShippingAddress.PhoneNumber))<br/>+ @(string.Format(_translationService.GetResource("PDFPackagingSlip.Address", order.CustomerLanguageId), order.ShippingAddress.Address1))<br/>+ @(order.ShippingAddress.City + ", " + order.ShippingAddress.ZipPostalCode)<br/>+ @((await _countryService.GetCountryById(order.ShippingAddress.CountryId))?.Name)<br/></div>}- <div style="display:block; clear:both;"></div>- <h5>@(string.Format(_translationService.GetResource("PDFPackagingSlip.ShippingMethod", order.CustomerLanguageId), order.ShippingMethod))</h5>+ <div><strong>@(string.Format(_translationService.GetResource("PDFPackagingSlip.ShippingMethod", order.CustomerLanguageId), order.ShippingMethod))</strong></div><div class="summary">- <h3>@(_translationService.GetResource("PDFInvoice.Product(s)", order.CustomerLanguageId))</h3>+ @(_translationService.GetResource("PDFInvoice.Product(s)", order.CustomerLanguageId))</div>- <table class="orderItems">+ <table class="Table"><tr>- <th>@(_translationService.GetResource("PDFPackagingSlip.ProductName", order.CustomerLanguageId))</th>- <th>@(_translationService.GetResource("PDFPackagingSlip.SKU", order.CustomerLanguageId))</th>- <th>@(_translationService.GetResource("PDFPackagingSlip.QTY", order.CustomerLanguageId))</th>+ <td class="Header" colspan="2">@(_translationService.GetResource("PDFPackagingSlip.ProductName", order.CustomerLanguageId))</td>+ <td class="Header">@(_translationService.GetResource("PDFPackagingSlip.SKU", order.CustomerLanguageId))</td>+ <td class="Header">@(_translationService.GetResource("PDFPackagingSlip.QTY", order.CustomerLanguageId))</td></tr>@foreach (var item in shipment.ShipmentItems){- var orderItem = order.OrderItems.Where(x => x.Id == item.OrderItemId).FirstOrDefault();+ var orderItem = order.OrderItems.FirstOrDefault(x => x.Id == item.OrderItemId);if (orderItem != null && (orderItem.VendorId == _workContext.CurrentVendor?.Id || !limitbyVendor)){<tr>- <td>+ <td colspan="2">@((await _productService.GetProductByIdIncludeArch(item.ProductId)).Name)@if (!string.IsNullOrEmpty(orderItem.AttributeDescription)){@@ -122,12 +133,7 @@}}</table>-- if (Model.Count - 1 > i)- {-- <div style="display:block; clear:both; page-break-after:always;"></div>- }}+ </main></body></html>\ No newline at end of file