views:

272

answers:

2

I am using TCPDF to generate PDF file using following command $pdf->writeHTML($htmlcontent, true, 0, true, 0);

TCPDF also provides a way to create barcode with following commands $pdf->Cell(0, 0, 'C39+', 0, 1); $pdf->write1DBarcode('Code 39', 'C39+', '', '', 80, 15, 0.4, $style, 'N'); $pdf->Ln();

I want to be able to write barcode as part of the HTML code above. Is there easy way?

I can potentially call a barcode image inthe writeHTML code above, but not sure how to use above barcode function ( or any in TCPDF) which would allow me to create image and then get that image into HTML generation

+1  A: 

You could put your barcode number is a fake HTML tag and then parse for that tag as you write out the HTML like in this example.

This would be in your HTML:

some HTML.... <POSTNET>12345-1234</POSTNET> ....some more HTML

This is the code to parse for the fake tag.

        // look to see if there is a POSTNET tag
        if (strpos($letter_html, "<POSTNET>") !== false) {
            $postnet_pre = explode("<POSTNET>", $letter_html);
            $this->WriteHTML($postnet_pre[0], $this->line_height);

            // write the barcode
            $postnet_post = explode("</POSTNET>", $postnet_pre[1]);
            $zip_code = $postnet_post[0];
            $this->write1DBarcode($zip_code, 'POSTNET', '', '', 80, 15, 0.4, $style, 'N');

            // write rest of the letter
            $this->WriteHTML($postnet_post[1], $this->line_height);

        } else {

            // no POSTNET so just write the whole letter
            $this->WriteHTML($letter_html, $this->line_height);
        }
tru10000
File does not begin with %PDF error. can you help?
abel
A: 

What is $this->line_height this is not working...

BhavikChauhan