Kennedy5020 Posted June 26, 2013 Share Posted June 26, 2013 Hi, I have to print the cart content in a pdf file and download. I have try some code using pdfinvoicecontroller.php 1. I have created new controller - controllers/front/CartprintController.php class CartprintControllerCore extends FrontController { protected $display_header = false; protected $display_footer = false; public $content_only = true; protected $template; public $filename; public function postProcess() { if (!$this->context->customer->isLogged() && !Tools::getValue('secure_key')) Tools::redirect('index.php?controller=authentication&back=cartprint'); } public function display() { $displayproducts = $this->context->cart->getProducts(); $pdf = new PDF($displayproducts, PDF::TEMPLATE_INVOICE_CART, $this->context->smarty, $this->context->language->id); $pdf->render(); } public function getTemplate() { $template = _PS_THEME_PDF_DIR_.'/cartprint.tpl'; return $template; } } 2. Added const TEMPLATE_INVOICE_CART = 'Cartprint'; line in classes/pdf/PDF.php 3.then created a HTML template file in pdf/cartprint.tpl <table id="cart_summary" class="std"> <thead> <tr> <th class="cart_product first_item">{l s='Product'}</th> <th class="cart_description item">{l s='Description'}</th> <th class="cart_unit item">{l s='Unit price'}</th> <th class="cart_quantity item">{l s='Qty'}</th> <th class="cart_total item">{l s='Total'}</th> </tr> </thead> {foreach $displayproducts item=prodpef name=prodpef } <tr> <td class="cart_product first_item">{$prodpef.name}</td> <td class="cart_description item">{$prodpef.description_short}</td> <td class="cart_unit item">{$prodpef.price}</td>> <td class="cart_quantity item">{$prodpef.cart_quantity}</td>> <td class="cart_total item">{$prodpef.total}</td>> </tr> {/foreach} </table> 4. in shopping cart psge i have created a link <a href="{$link->getPageLink('cartprint', true, NULL)}" title="{l s='Invoice'}" class="_blank"><img src="{$img_dir}icon/pdf.gif" alt="{l s='Invoice'}" class="icon" /></a> but still i am not getting pdf output . Any help ? Link to comment Share on other sites More sharing options...
Valérie Assetskaya Posted June 26, 2013 Share Posted June 26, 2013 Hi, First of all it was necessary to make it as a module. Also, in PDF class constructor, there are only 3 parameters: public function __construct($objects, $template, $smarty) And you transfer 4. What version do you have? Besides, are you sure that $displayproducts is transfered and not empty? And we would use $pdf->render(); instead of $pdf->render(false); Best regards. Link to comment Share on other sites More sharing options...
TalerKK Posted July 30, 2013 Share Posted July 30, 2013 hi ,Im currently working on pdf generating with .NET. does prestshop provide any lib written in .NET for C# or ASP ? if so ,Plz give me a detail guide .as an amature in programming ,I came across pdf creating component on web ,but I know whether it is working or not .Any suggestion? Link to comment Share on other sites More sharing options...
tuk66 Posted July 30, 2013 Share Posted July 30, 2013 PrestaShop is PHP software. There is (almost) no way how to use a .NET library and there is no need as well. You can use TCPDF library already built-in in PrestaShop or a premium module like M4 PDF Extensions if you need more control and create a PDF output easily. Link to comment Share on other sites More sharing options...
Abigail111 Posted August 23, 2013 Share Posted August 23, 2013 If you want to create pdf ,you can follow the demo code: using RasterEdge.Imaging.Basic; using RasterEdge.Imaging.Basic.Core; using RasterEdge.Imaging.Basic.Codec; using RasterEdge.Imaging.PDF; namespace RE__Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public static string FolderName = "c:/"; private void button1_Click(object sender, EventArgs e) { string fileName = FolderName + "SampleNew.pdf"; PDFDocument pdf = new PDFDocument(5); REFile.SaveDocumentFile(pdf, fileName, new PDFEncoder());//save new pdf } Link to comment Share on other sites More sharing options...
mani313 Posted October 15, 2013 Share Posted October 15, 2013 hi there, i want to change invoice (pdf) design, i tried background images, font etc, but no result. it accepts only size, color and alignments how do i do? is it not possible anyway? help/suggestions would be appreciated thanks in advance Link to comment Share on other sites More sharing options...
tuk66 Posted October 15, 2013 Share Posted October 15, 2013 It depends on complexity of your request and the time you want to dedicate to find a way. There is an easy as well as hard way, as always: http://www.prestashop.com/forums/topic/2571[spam-filter]how-to-create-pdf-in-prestashop/?view=findpost&p=1322113 Link to comment Share on other sites More sharing options...
mani313 Posted October 15, 2013 Share Posted October 15, 2013 (edited) thanks for the help.. the suggestion of M4 PDF Extensions seems good in invoice control, i have few ques will it support custom styles directly? (i mean can i add styles in invoice.tpl ) i want do a invoice pdf exactly like this .. is anyother tutorial need to study ? Edited October 15, 2013 by mani313 (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted October 15, 2013 Share Posted October 15, 2013 The M4 PDF Extensions module doesn't use invoice.tpl template. It uses own templates (more than one) and CSS style is a part of all templates. So yes, you can create the invoice like yours as easy as a HTML page. Link to comment Share on other sites More sharing options...
Recommended Posts