0

I am trying to use the artkonekt library. I am succesfully using the example using the following code:

require_once(APPPATH . '/third_party/vendor/autoload.php');
use Konekt\PdfInvoice\InvoicePrinter as Printer;
...
    public function createInvoice()
        {
            $invoice = new Printer();
            $imgurl = base_url() . MODULES_IMAGES . 'contact_volunteer_module.jpg';
            $invoice->setLogo($imgurl);   //logo image path
            $invoice->setColor("#007fff");      // pdf color scheme
            $invoice->setType("Sale Invoice");    // Invoice Type
            $invoice->setReference("INV-55033645");   // Reference
            $invoice->setDate(date('M dS ,Y',time()));   //Billing Date
            $invoice->setTime(date('h:i:s A',time()));   //Billing Time
            $invoice->setDue(date('M dS ,Y',strtotime('+3 months')));    // Due Date
            $invoice->setFrom(array("Seller Name","Sample Company Name","128 AA Juanita Ave","Glendora , CA 91740"));
            $invoice->setTo(array("Purchaser Name","Sample Company Name","128 AA Juanita Ave","Glendora , CA 91740"));

            $invoice->addItem("AMD Athlon X2DC-7450","2.4GHz/1GB/160GB/SMP-DVD/VB",6,0,580,0,3480);
            $invoice->addItem("PDC-E5300","2.6GHz/1GB/320GB/SMP-DVD/FDD/VB",4,0,645,0,2580);
            $invoice->addItem('LG 18.5" WLCD',"",10,0,230,0,2300);
            $invoice->addItem("HP LaserJet 5200","",1,0,1100,0,1100);

            $invoice->addTotal("Total",9460);
            $invoice->addTotal("VAT 21%",1986.6);
            $invoice->addTotal("Total due",11446.6,true);

            $invoice->addBadge("Payment Paid");

            $invoice->addTitle("Important Notice");

            $invoice->addParagraph("No item will be replaced or refunded if you don't have the invoice with you.");

            $invoice->setFooternote("My Company Name Here");

            $invoice->render('example1123.pdf','D');

            //var_dump($invoice);
        }

If i then load the page, all i see is a blank page and no PDF is being created. When var_dumping $invoice, i can see that the array is created and all fields are filled in. Is there anything else I need to do to let the file download?

Dennis
  • 3,044
  • 2
  • 33
  • 52

1 Answers1

0

After some digging I figured out the issue was in FPDF class.

Putting ob_clean(); in the output class solved it for me.

This solution was from the topic: FPDF error: Some data has already been output, can't send PDF

Dennis
  • 3,044
  • 2
  • 33
  • 52