|
| 1 | +<?php |
| 2 | +/******************************************************************************* |
| 3 | +* PDML to PDF conversion * |
| 4 | +* * |
| 5 | +* Parameters: * |
| 6 | +* buffer = pdml data * |
| 7 | +* Result: * |
| 8 | +* return = raw pdf data * |
| 9 | +* * |
| 10 | +*******************************************************************************/ |
| 11 | +function pdml2pdf($buffer) |
| 12 | +{ |
| 13 | + global $PDML_Orientation; |
| 14 | + global $PDML_Format; |
| 15 | + |
| 16 | + $pdml = new PDML($PDML_Orientation,'pt',$PDML_Format); |
| 17 | + $pdml->compress=0; |
| 18 | + $pdml->ParsePDML($buffer); |
| 19 | + $s = $pdml->Output("","S"); |
| 20 | + return ($s); |
| 21 | +} |
| 22 | + |
| 23 | +/******************************************************************************* |
| 24 | +* Create and display PDF to STDOUT * |
| 25 | +* * |
| 26 | +* Parameters: * |
| 27 | +* buffer = pdml data * |
| 28 | +* Result: * |
| 29 | +* return = raw pdf data * |
| 30 | +* * |
| 31 | +*******************************************************************************/ |
| 32 | +function ob_pdml($buffer) |
| 33 | +{ |
| 34 | + global $PDML_FileName; |
| 35 | + |
| 36 | + $s = pdml2pdf($buffer); |
| 37 | + |
| 38 | + Header('Content-Type: application/pdf'); |
| 39 | + Header('Content-Length: '.strlen($s)); |
| 40 | + Header('Content-disposition: inline; filename='.$PDML_FileName); |
| 41 | + |
| 42 | + header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); |
| 43 | + header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); |
| 44 | + header( "Cache-Control: no-cache, must-revalidate" ); |
| 45 | + header( "Pragma: no-cache" ); |
| 46 | + |
| 47 | + return $s; |
| 48 | +} |
| 49 | + |
| 50 | +/********************************************************************************** |
| 51 | +* Convert HTML/PDML entities into special characters * |
| 52 | +* * |
| 53 | +* Parameters: * |
| 54 | +* given_html = pdml data (with entities) * |
| 55 | +* quote_style = Quotation Style * |
| 56 | +* ENT_COMPAT :Convert double-quotes and leave single-quotes alone.* |
| 57 | +* ENT_QUOTES :Convert both double and single quotes. * |
| 58 | +* ENT_NOQUOTES:Leave both double and single quotes unconverted. * |
| 59 | +* Result: * |
| 60 | +* return = pdml data (with entities converted into special characters * |
| 61 | +* * |
| 62 | +**********************************************************************************/ |
| 63 | +function pdml_entity_decode( $given_html, $quote_style = ENT_QUOTES ) |
| 64 | +{ |
| 65 | + $trans_table = array_flip(array_merge( |
| 66 | + get_html_translation_table( HTML_SPECIALCHARS, $quote_style ), |
| 67 | + get_html_translation_table( HTML_ENTITIES, $quote_style) )); |
| 68 | + $trans_table['''] = "'"; |
| 69 | + $trans_table['€'] = chr(128); |
| 70 | + $trans_table['•'] = chr(149); |
| 71 | + return ( strtr( $given_html, $trans_table ) ); |
| 72 | +} |
0 commit comments