protected virtual async Task PrintProductsAsync(int vendorId, Language lang, Font titleFont, Document doc, Order order, Font font, Font attributesFont)
{
var productsHeader = new PdfPTable(1)
{
RunDirection = GetDirection(lang),
WidthPercentage = 100f
};
var cellProducts = await GetPdfCellAsync("PDFInvoice.Product(s)", lang, titleFont);
cellProducts.Border = Rectangle.NO_BORDER;
productsHeader.AddCell(cellProducts);
doc.Add(productsHeader);
doc.Add(new Paragraph(" "));
//a vendor should have access only to products
var orderItems = await _orderService.GetOrderItemsAsync(order.Id, vendorId: vendorId);
var count = 5 + (_catalogSettings.ShowSkuOnProductDetailsPage ? 1 : 0)
+ (_vendorSettings.ShowVendorOnOrderDetailsPage ? 1 : 0);
var productsTable = new PdfPTable(count)
{
RunDirection = GetDirection(lang),
WidthPercentage = 100f
};
var widths = new Dictionary<int, int[]>
{
{ 5, new[] { 20, 40, 15, 10, 15 } },
{ 6, new[] { 20, 35, 15, 10, 10, 10 } },
{ 7, new[] { 20, 30, 10, 10, 10, 10, 10 } }
};
productsTable.SetWidths(lang.Rtl ? widths[count].Reverse().ToArray() : widths[count]);
//product image
var cellProductItemPicture = await GetPdfCellAsync("PDFInvoice.ProductImage", lang, font);
cellProductItemPicture.BackgroundColor = BaseColor.LightGray;
cellProductItemPicture.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItemPicture);
//product name
var cellProductItem = await GetPdfCellAsync("PDFInvoice.ProductName", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
//SKU
if (_catalogSettings.ShowSkuOnProductDetailsPage)
{
cellProductItem = await GetPdfCellAsync("PDFInvoice.SKU", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
}
//Vendor name
if (_vendorSettings.ShowVendorOnOrderDetailsPage)
{
cellProductItem = await GetPdfCellAsync("PDFInvoice.VendorName", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
}
//price
cellProductItem = await GetPdfCellAsync("PDFInvoice.ProductPrice", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
//qty
cellProductItem = await GetPdfCellAsync("PDFInvoice.ProductQuantity", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
//total
cellProductItem = await GetPdfCellAsync("PDFInvoice.ProductTotal", lang, font);
cellProductItem.BackgroundColor = BaseColor.LightGray;
cellProductItem.HorizontalAlignment = Element.ALIGN_CENTER;
productsTable.AddCell(cellProductItem);
var vendors = _vendorSettings.ShowVendorOnOrderDetailsPage ?