项目作者: ofancn

项目描述 :
PHP Invoice 快速生成精美的PDF报价单或订单
高级语言: PHP
项目地址: git://github.com/ofancn/invoice.git
创建时间: 2019-05-07T11:22:27Z
项目社区:https://github.com/ofancn/invoice

开源协议:MIT License

下载


Invoice

English Document

港澳台繁體文档

只需几行代码即可生成设计精美的报价单或订单。使用您自己的徽标和主题颜色进行品牌化,使用自动分页添加无限制的项目和总行数。您可以在用户的​​浏览器中传送PDF输出,保存在服务器上或强制下载文件
Invoice内置了中文简体、中文繁体、英语的翻译,您可以设置每个文档所需的货币。

项目已集成 思源黑体(Source Han Sans)中文版

安装Invoice

Invoice利用Composer来管理其依赖关系。 因此,在使用Invoice之前,请确保在您的计算机上安装了Composer

  1. composer require invoice/invoice

演示

苹果报价表

货币

货币代码

文档

实例

  1. use Invoice\Invoice;
  2. $invoice=new Invoice();

or

  1. $invoice=get_invoice();

  1. $invoice = new Invoice('CNY','A4');
  2. //Set number formatting
  3. $invoice->setNumberFormat('.',',')
  4. //设置字体
  5. //->setFontFamily('SourceHanSans', '', '~/font/sourcehansans.ttf')
  6. //->setFontFamily('SourceHanSans','b', '~/font/sourcehansansb.ttf')
  7. //设置LOGO
  8. ->setLogo("images/apple.png",100,88)
  9. //设置颜色
  10. ->setColor("#ed4014")
  11. //设置要文档类型
  12. ->setType("报价表")
  13. //设置文档编号
  14. ->setReference(date('Ymd').'001')
  15. //报价日期
  16. ->setDate(date('Y-m-d'))
  17. //截止日期
  18. ->setDue(date('Y-m-d',strtotime('+3 months')))
  19. //报价人
  20. ->setFrom(["Apple Inc","1 Infinite Loop","Cupertino, CA 95014","United States of America","IE9700053D"])
  21. //客户
  22. ->setTo(["京东商城 刘强东","北京市","北京经济技术开发区科创","十四街99号2号楼B168室","400-6065500 "])
  23. //新增产品
  24. ->addItem("Apple iPhone X","64G 红色",1,"21%",299,'5%',284.05)
  25. ->addItem("Apple iPhone X","158G 红色",1,"21%",299,0,299)
  26. //增加合计
  27. ->addTotal("合计",583.05)
  28. ->addTotal("折扣 21%",122.44)
  29. ->addTotal("总计",705.5,true)
  30. //增加李老师
  31. ->addTitle("声明")
  32. //添加段落
  33. ->addParagraph("只需几行代码即可生成设计精美的报价单或订单\nInvoice利用Composer来管理其依赖关系。 因此,在使用Invoice之前,请确保在您的计算机上安装了Composer\ncomposer require invoice/invoice")
  34. //设置页脚
  35. ->setFooternote("http://www.apple.com")
  36. //设置徽章
  37. ->addBadge('A级机密')
  38. //切换公司信息和客户信息的水平位置
  39. ->flipflop()
  40. //交付PDF
  41. ->render('Apple.pdf','I');

类说明

  1. /**
  2. * 实例
  3. * @param string $currency
  4. * 货币代码
  5. * @param string $size
  6. * 纸张大小 A4 Letter Legal
  7. * @param string $language
  8. * 语言
  9. */
  10. function __construct($currency = 'CNY', $size = 'A4', $language = 'zh');
  11. /**
  12. * 获取货币符号
  13. *
  14. * @param string $code
  15. * 货币代码
  16. * @return string|null
  17. */
  18. public function getCurrencySymbol(string $code);
  19. /**
  20. * 判断货币是否可用
  21. *
  22. * @param string $code
  23. * 货币代码
  24. * @return bool
  25. */
  26. public function hasCurrency(string $code);
  27. /**
  28. * 设置字体
  29. *
  30. * @param string $family
  31. * 字体名称
  32. * @param string $style
  33. * 字体样式 至少包含两种字体样式 ''和'b'
  34. * @param string $file
  35. * 字体文件
  36. * @return $this
  37. */
  38. public function setFontFamily(string $family, string $style = '', string $file = '');
  39. /**
  40. * 设置语言
  41. *
  42. * @param string $language
  43. * @return $this
  44. */
  45. public function setLanguage(string $language);
  46. /**
  47. * 设置要文档类型
  48. *
  49. * @param type $title
  50. * @return $this
  51. */
  52. public function setType(string $title);
  53. /**
  54. * 设置颜色
  55. *
  56. * @param string $rgbcolor
  57. * 十六进制颜色代码。红色示例:'#FF0000'
  58. * @return $this
  59. */
  60. public function setColor(string $rgbcolor);
  61. /**
  62. * 设置文档日期
  63. *
  64. * @param string $date
  65. * @return $this
  66. */
  67. public function setDate(string $date);
  68. /**
  69. * 截止日期
  70. *
  71. * @param string $date
  72. * @return $this
  73. */
  74. public function setDue(string $date);
  75. /**
  76. * 设置logo
  77. *
  78. * @param string $logo
  79. * 要使用的图像文件的本地路径或远程URL
  80. * @param int $maxWidth
  81. * 宽度 毫米为单位
  82. * @param int $maxHeight
  83. * 高度 毫米为单位
  84. * @return $this
  85. */
  86. public function setLogo($logo = 0, $maxWidth = 0, $maxHeight = 0);
  87. /**
  88. * 设置公司详细信息
  89. *
  90. * @param array $data
  91. * @return $this
  92. */
  93. public function setFrom(array $data);
  94. /**
  95. * 客户信息
  96. *
  97. * @param array $data
  98. * @return $this
  99. */
  100. public function setTo(array $data);
  101. /**
  102. * 设置文档编号
  103. *
  104. * @param string $reference
  105. * @return $this
  106. */
  107. public function setReference($reference);
  108. /**
  109. * 设置数字格式
  110. *
  111. * @param string $decimals
  112. * 小数点的字符
  113. * @param string $thousands_sep
  114. * 千位分隔符的字符
  115. * @return $this
  116. */
  117. public function setNumberFormat($decimals, $thousands_sep);
  118. /**
  119. * 新增商品
  120. *
  121. * @param string $item
  122. * 产品或服务名称
  123. * @param string $description
  124. * 描述 使用<br>或\ n添加换行符
  125. * @param decimal $quantity
  126. * 数量
  127. * @param decimal|string $vat
  128. * 金额
  129. * @param decimal $price
  130. * 单价
  131. * @param string|decimal|boolean $discount
  132. * 折扣 没有请填 false
  133. * @param int $total
  134. * 总计
  135. * @return $this
  136. */
  137. public function addItem($item, $description, $quantity, $vat, $price, $discount, $total);
  138. /**
  139. * 设置总计
  140. *
  141. * @param string $name
  142. * 名称
  143. * @param decimal $value
  144. * 值
  145. * @param boolean $colored
  146. * 背景色 true 则背景色
  147. * @return $this
  148. */
  149. public function addTotal($name, $value, $colored = false);
  150. /**
  151. * 添加标题
  152. *
  153. * @param string $title
  154. * @return $this
  155. */
  156. public function addTitle($title);
  157. /**
  158. * 添加段落
  159. *
  160. * @param string $paragraph
  161. * @return $this
  162. */
  163. public function addParagraph($paragraph);
  164. /**
  165. * 添加徽章
  166. *
  167. * @param string $badge
  168. * @return $this
  169. */
  170. public function addBadge($badge);
  171. /**
  172. * 设置页脚
  173. *
  174. * @param string $note
  175. * @return $this
  176. */
  177. public function setFooternote($note);
  178. /**
  179. * 切换公司信息和客户信息的水平位置
  180. *
  181. * @return $this
  182. */
  183. public function flipflop();
  184. /**
  185. * 渲染交付
  186. *
  187. * @param string $name
  188. * 名称
  189. * @param string $destination
  190. * 交付方式
  191. * I(将文件内联发送到浏览器)
  192. * D(发送到浏览器并强制使用名称给出的名称下载文件)
  193. * F(保存到本地文件。确保在name参数中设置传递路径)
  194. * S(将文档作为字符串返回)
  195. * @return $this
  196. */
  197. public function render($name = '', $destination = '');