|
1 | 1 | <?php
|
2 | 2 | //============================================================+
|
3 | 3 | // File name : tcpdi_parser.php
|
4 |
| -// Version : 1.0 |
| 4 | +// Version : 1.1 |
5 | 5 | // Begin : 2013-09-25
|
6 |
| -// Last Update : 2013-09-25 |
| 6 | +// Last Update : 2016-05-03 |
7 | 7 | // Author : Paul Nicholls - https://github.com/pauln
|
8 | 8 | // License : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
|
9 | 9 | //
|
|
44 | 44 | * This is a PHP class for parsing PDF documents.<br>
|
45 | 45 | * @author Paul Nicholls
|
46 | 46 | * @author Nicola Asuni
|
47 |
| - * @version 1.0 |
| 47 | + * @version 1.1 |
48 | 48 | */
|
49 | 49 |
|
50 | 50 | // include class for decoding filters
|
|
82 | 82 | * This is a PHP class for parsing PDF documents.<br>
|
83 | 83 | * Based on TCPDF_PARSER, part of the TCPDF project by Nicola Asuni.
|
84 | 84 | * @brief This is a PHP class for parsing PDF documents..
|
85 |
| - * @version 1.0 |
| 85 | + * @version 1.1 |
86 | 86 | * @author Paul Nicholls - github.com/pauln
|
87 | 87 | * @author Nicola Asuni - info@tecnick.com
|
88 | 88 | */
|
@@ -1219,6 +1219,42 @@ private function _getPageResources ($obj) { // $obj = /Page
|
1219 | 1219 | }
|
1220 | 1220 | }
|
1221 | 1221 |
|
| 1222 | + /** |
| 1223 | + * Get annotations from current page |
| 1224 | + * |
| 1225 | + * @return array |
| 1226 | + */ |
| 1227 | + public function getPageAnnotations() { |
| 1228 | + return $this->_getPageAnnotations($this->pages[$this->pageno]); |
| 1229 | + } |
| 1230 | + |
| 1231 | + /** |
| 1232 | + * Get annotations from /Page |
| 1233 | + * |
| 1234 | + * @param array $obj Array of pdf-data |
| 1235 | + */ |
| 1236 | + private function _getPageAnnotations ($obj) { // $obj = /Page |
| 1237 | + $obj = $this->getObjectVal($obj); |
| 1238 | + |
| 1239 | + // If the current object has an annotations |
| 1240 | + // dictionary associated with it, we use |
| 1241 | + // it. Otherwise, we move back to its |
| 1242 | + // parent object. |
| 1243 | + if (isset ($obj[1][1]['/Annots'])) { |
| 1244 | + $annots = $obj[1][1]['/Annots']; |
| 1245 | + } else { |
| 1246 | + if (!isset ($obj[1][1]['/Parent'])) { |
| 1247 | + return false; |
| 1248 | + } else { |
| 1249 | + $annots = $this->_getPageAnnotations($obj[1][1]['/Parent']); |
| 1250 | + } |
| 1251 | + } |
| 1252 | + |
| 1253 | + if ($annots[0] == PDF_TYPE_OBJREF) |
| 1254 | + return $this->getObjectVal($annots); |
| 1255 | + return $annots; |
| 1256 | + } |
| 1257 | + |
1222 | 1258 |
|
1223 | 1259 | /**
|
1224 | 1260 | * Get content of current page
|
|
0 commit comments