/app/vendors/Pear/mc/PDF.php

https://github.com/hardsshah/bookmarks · PHP · 73 lines · 46 code · 5 blank · 22 comment · 0 complexity · 91b55c81de83f5e33007c12b3f8b1bf7 MD5 · raw file

  1. <?php
  2. // extends the pear PDF class
  3. require_once "File/PDF.php";
  4. class mc_PDF extends File_PDF
  5. {
  6. function __construct(){
  7. $this->setInfo(array(
  8. "title" => "Invoice",
  9. "subject" => "Invoice",
  10. "author" => "Made Secure LLC",
  11. "keywords" => "Invoice",
  12. "creator" => "Made Secure LLC"
  13. ));
  14. $this->setCompression(true);
  15. $this->setAutoPageBreak(true);
  16. }
  17. function header(){
  18. // add an image (file, x-cord, y-cord, [width], [height], [type], [link]) w or h 0 sets to default img will auto size which one is given
  19. $this->image('img/pdf/msc_logo.jpg', 10, 5, 0, 10, 'jpg', "http://www.madesecure.com/");
  20. // Line break Create spacing so img does not overlap text
  21. $this->newLine(15);
  22. // make a line accross the page, neg value starts from opposite side
  23. $this->line(10.0, 16.0, -10.0, 16.0);
  24. }
  25. function footer(){
  26. $text ='For questions contact Matthew Campbell. Office: 1.704.461.1664, Email: matt@madesecure.com';
  27. // Center and display the text
  28. $offset = ($this->getStringWidth($text))/2;
  29. $x_pos = 108 - $offset;
  30. // min from bottom 12.7 plus height 5
  31. $y_pos = -18;
  32. $this->text($x_pos, $y_pos, $text);
  33. }
  34. /**
  35. *Set the cursor position to write a line with right alignment
  36. *
  37. * @param string $line
  38. * @return float x position
  39. */
  40. function alignRight($line){
  41. // get position to write at
  42. $width = $this->getStringWidth($line);
  43. // calc distance from right side margin plus width of string // neg val not working
  44. $pos_x = $this->getPageWidth() + $this->_left_margin - $width - 3;
  45. // set position to write at
  46. $this->setX($pos_x);
  47. return $pos_x;
  48. }
  49. /**
  50. * Draw a fold line 1/3 down the page
  51. */
  52. function addFoldLine(){
  53. // Add a fold line 1/3 of page is 93 plus 8 who knows why but it works
  54. $y = 101.0;
  55. $this->line(10.0, $y, -10.0, $y);
  56. // Write the text below the fold line
  57. $this->setFontSize(6);
  58. $line = "Fold Along This Line";
  59. $width = $this->getStringWidth($line);
  60. //center the text
  61. $pos_x = 108 - ($width/2);
  62. $this->setX($pos_x);
  63. // add fold line text
  64. $this->setY($y);
  65. $this->write(3, $line);
  66. }
  67. }
  68. ?>