ISPConfig module for simplify the creation of websites and DNS zones in a only step
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

140 line
3.1 KiB

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