You're right, I forgot I had to make some changes for it. Looking through source control, it looks like I made the following changes:
I added the following code to "Libraries/Nop.Services/Common/PdfService.cs" in the function "PrintPackagingSlipsToPdf(....):
foreach (var shipment in shipments) { var order = shipment.Order;
if (languageId == 0) { lang = _languageService.GetLanguageById(order.CustomerLanguageId); if (lang == null || !lang.Published) lang = _workContext.WorkingLanguage; }
#region Header
//logo var logoPicture = _pictureService.GetPictureById(_pdfSettings.LogoPictureId); var logoExists = logoPicture != null;
//header var headerTable = new PdfPTable(logoExists ? 2 : 1) {WidthPercentage = 100f}; if (logoExists) headerTable.SetWidths(new[] { 50, 50 });
//logo if (logoExists) { var logoFilePath = _pictureService.GetThumbLocalPath(logoPicture, 0, false); var logoFile = Image.GetInstance(logoFilePath); logoFile.ScaleToFit(220, 60); var cellLogo = new PdfPCell(logoFile); cellLogo.Border = Rectangle.NO_BORDER; headerTable.AddCell(cellLogo); } #endregion
I customized some other stuff in there (store specific), but I don't think you'll need anything else. Let me know if you have an y problems.
I want to edit mi PDF invoice, but I dont know where is "Libraries - > Nop.Services - > Common - > PdfService.cs" directory... can you help me please? on my hosting directory I dont have it...
I had to do more than this in order to get it to work for me. The code above in this thread was not enough to get the Logo to show up on the PDF packing slips of mine - I'm using nopCommerce 3.4. Here's what worked for me after several rounds of testing and debugging:
In the PrintPackagingSlipsToPdf method in the PdfService class in Nop.Services.Common, find the code below
foreach (var shipment in shipments) { var order = shipment.Order;
if (languageId == 0) { lang = _languageService.GetLanguageById(order.CustomerLanguageId); if (lang == null || !lang.Published) lang = _workContext.WorkingLanguage; }
And then insert this directly after this code (inside of this foreach):
#region Header
//logo var logoPicture = _pictureService.GetPictureById(_pdfSettings.LogoPictureId); var logoExists = logoPicture != null;
//header var headerTable = new PdfPTable(logoExists ? 2 : 1) { WidthPercentage = 100f }; if (logoExists) headerTable.SetWidths(new[] { 50, 50 });
//logo if (logoExists) { var logoFilePath = _pictureService.GetThumbLocalPath(logoPicture, 0, false); Image logoFile = Image.GetInstance(logoFilePath); logoFile.ScaleToFit(220, 60); var cellLogo = new PdfPCell(logoFile) {Border = Rectangle.NO_BORDER}; headerTable.AddCell(cellLogo); var emptyCell = new PdfPCell {Border = Rectangle.NO_BORDER}; headerTable.AddCell(emptyCell); } doc.Add(headerTable);
#endregion
Two key things were missing from the code in the answer above: doc.Add(headerTable); and the insertion of an empty cell (don't know why this was necessary to get the image to actually show up:
var emptyCell = new PdfPCell {Border = Rectangle.NO_BORDER}; headerTable.AddCell(emptyCell);
Thanks, Jordan
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.