ISPConfig module for simplify the creation of websites and DNS zones in a only step
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

119 řádky
2.7 KiB

  1. <?php
  2. require('fpdf.php');
  3. class PDFO6H extends FPDF
  4. {
  5. protected $B = 0;
  6. protected $I = 0;
  7. protected $U = 0;
  8. protected $HREF = '';
  9. public $nombre_bd;
  10. function WriteHTML($html)
  11. {
  12. // Intérprete de HTML
  13. $html = str_replace("\n",' ',$html);
  14. $a = preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
  15. foreach($a as $i=>$e)
  16. {
  17. if($i%2==0)
  18. {
  19. // Text
  20. if($this->HREF)
  21. $this->PutLink($this->HREF,$e);
  22. else
  23. $this->Write(5,$e);
  24. }
  25. else
  26. {
  27. // Etiqueta
  28. if($e[0]=='/')
  29. $this->CloseTag(strtoupper(substr($e,1)));
  30. else
  31. {
  32. // Extraer atributos
  33. $a2 = explode(' ',$e);
  34. $tag = strtoupper(array_shift($a2));
  35. $attr = array();
  36. foreach($a2 as $v)
  37. {
  38. if(preg_match('/([^=]*)=["\']?([^"\']*)/',$v,$a3))
  39. $attr[strtoupper($a3[1])] = $a3[2];
  40. }
  41. $this->OpenTag($tag,$attr);
  42. }
  43. }
  44. }
  45. }
  46. function OpenTag($tag, $attr)
  47. {
  48. // Etiqueta de apertura
  49. if($tag=='B' || $tag=='I' || $tag=='U')
  50. $this->SetStyle($tag,true);
  51. if($tag=='A')
  52. $this->HREF = $attr['HREF'];
  53. if($tag=='BR')
  54. $this->Ln(5);
  55. }
  56. function CloseTag($tag)
  57. {
  58. // Etiqueta de cierre
  59. if($tag=='B' || $tag=='I' || $tag=='U')
  60. $this->SetStyle($tag,false);
  61. if($tag=='A')
  62. $this->HREF = '';
  63. }
  64. function SetStyle($tag, $enable)
  65. {
  66. // Modificar estilo y escoger la fuente correspondiente
  67. $this->$tag += ($enable ? 1 : -1);
  68. $style = '';
  69. foreach(array('B', 'I', 'U') as $s)
  70. {
  71. if($this->$s>0)
  72. $style .= $s;
  73. }
  74. $this->SetFont('',$style);
  75. }
  76. function PutLink($URL, $txt)
  77. {
  78. // Escribir un hiper-enlace
  79. $this->SetTextColor(0,0,255);
  80. $this->SetStyle('U',true);
  81. $this->Write(5,$txt,$URL);
  82. $this->SetStyle('U',false);
  83. $this->SetTextColor(0);
  84. }
  85. }
  86. $html = 'Usuario Base de Datos: <b></b>
  87. Nombre Base de Datos: <b>nombre</b>
  88. Clave Base de Datos: <b>nombre</b>
  89. Usuario FTP: <b>nombre</b>
  90. Clave FTP: <b>nombre</b>
  91. <a href="http://www.open6hosting.com">www.open6hosting.com</a>';
  92. $pdf = new PDFO6H();
  93. // Primera página
  94. $pdf->AddPage();
  95. $pdf->SetFont('Arial','',20);
  96. //$pdf->Write(5,'Para saber qué hay de nuevo en este tutorial, pulse ');
  97. $pdf->SetFont('','U');
  98. //$link = $pdf->AddLink();
  99. //$pdf->Write(5,'aquí',$link);
  100. $pdf->SetFont('');
  101. // Segunda página
  102. //$pdf->AddPage();
  103. $pdf->SetLink($link);
  104. $pdf->Image('imagen/open6-logo.png',10,12,30,0,'','http://www.open6hosting.com');
  105. $pdf->SetLeftMargin(45);
  106. $pdf->SetFontSize(14);
  107. $pdf->WriteHTML($html);
  108. $pdf->Output();
  109. ?>