Page 1 of 1

Convert HTML code to text

Posted: Mon Aug 24, 2009 10:35 am
by gamenano
Hi everyone, I am new to the forum and this is my first post.

I have an online shop, where one of the mod is to covert orders from html to a PDF file, however, the bit about delivery still show in html code.

Image

I am trying to do something with the template.php file, could anyone tell me what is the code to convert html code to the proper text.

many thanks for help and sugguestion.


Genesis

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 11:41 am
by jackpf
Do you want strip_tags()?

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 6:35 pm
by gamenano
Thank you Jackpf,

I am only a beginner with php, so I don't really know what strip_tags() is. I have been doing some reading about strip_tags() on the web, but still not have any idea about this function. So could you educate me a bit more. :banghead:

many thanks in advance Jackpf

Genesis

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 6:47 pm
by jackpf
strip_tags()

It basically does what it says on the tin - removes HTML tags.

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 7:05 pm
by gamenano
I see. That is what I needed. So how should I to do it? :?:

Genesis

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 7:26 pm
by jackpf
Idk, you haven't posted your code. Run strip_tags() on whatever you're writing to the PDF file.

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 8:46 pm
by gamenano
You are right mate, the guru whom design this mod have use a function call pdfoc_html_cleanup()

But after a hour of looking where the shipping text was generated, I have no luck. I would guess it would be somewhere around those line.


// line under Totals column
//
$pdf->setLineStyle(1.5);
$tx = $x - PDFOC_PRICING_COLUMN_SIZES + 15;
$pdf->line($tx,$pos,$x+13,$pos); // tweak this value to match end of your table

$pos -= PDFOC_SECTION_DIVIDER;

for ($i = $nexttotal, $n = sizeof($order->totals); $i < $n; $i++) {

// check whether too far down page to print more totals
//
if ($pos < PDFOC_BOTTOM_MARGIN) {
$secondpage = true;
return;
}

$pdf->ezSetY($pos+PDFOC_PRODUCT_TOTALS_LEADING);
$x -= PDFOC_PRICING_COLUMN_SIZES;
$pdf->ezText("<b>" . pdfoc_html_cleanup($order->totals[$i]['title']) . "</b>",PDFOC_TABLE_HEADER_FONT_SIZE,array('justification'=> 'right','aright'=>$x));
$x += PDFOC_PRICING_COLUMN_SIZES;
$pdf->ezSetY($pos+PDFOC_PRODUCT_TOTALS_LEADING);
$pdf->ezText(pdfoc_html_cleanup($order->totals[$i]['text']),PDFOC_TABLE_HEADER_FONT_SIZE,array('justification'=> 'right','aright'=>$x));
// $pdf->addText($x,$pos,PDFOC_PRODUCT_TOTALS_FONT_SIZE,pdfoc_html_cleanup($order->totals[$i]['text']), $order->info['currency_value']);

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 9:09 pm
by jackpf
I'm afraid I have no idea what that code does....

Probably best to ask the person who coded it.

Re: Convert HTML code to text

Posted: Mon Aug 24, 2009 9:27 pm
by Eran
This looks like a PDF generation routine and also it looks like some of the tags are a part of the code. You will need to remove those, as well as run strip_tags() on the textual sources (instead of pdfoc_html_cleanup)