Note: PHP duplicates string, which is sent by value, only of it's updated. Thus we don't need to care about overhead
366 #require_once 'Zend/Pdf/Exception.php'; 372 while ($byteCount > 0 && !
feof($pdfFile)) {
373 $nextBlock = fread($pdfFile, $byteCount);
374 if ($nextBlock ===
false) {
375 #require_once 'Zend/Pdf/Exception.php'; 380 $byteCount -= strlen($nextBlock);
382 if ($byteCount != 0) {
383 #require_once 'Zend/Pdf/Exception.php'; 393 $pdfVersionComment = $this->_stringParser->readComment();
394 if (substr($pdfVersionComment, 0, 5) !=
'%PDF-') {
395 #require_once 'Zend/Pdf/Exception.php'; 399 $pdfVersion = substr($pdfVersionComment, 5);
400 if (version_compare($pdfVersion,
'0.9',
'<') ||
401 version_compare($pdfVersion,
'1.61',
'>=')
409 #require_once 'Zend/Pdf/Exception.php'; 410 throw new Zend_Pdf_Exception(sprintf(
'Unsupported PDF version. Zend_Pdf supports PDF 1.0-1.4. Current version - \'%f\'', $pdfVersion));
412 $this->_pdfVersion = $pdfVersion;
414 $this->_stringParser->offset = strrpos($this->_stringParser->data,
'%%EOF');
415 if ($this->_stringParser->offset ===
false ||
416 strlen($this->_stringParser->data) - $this->_stringParser->offset > 7) {
417 #require_once 'Zend/Pdf/Exception.php'; 418 throw new Zend_Pdf_Exception(
'Pdf file syntax error. End-of-fle marker expected at the end of file.');
421 $this->_stringParser->offset--;
426 ($this->_stringParser->offset > 0)) {
427 $this->_stringParser->offset--;
433 ($this->_stringParser->offset > 0)) {
434 $this->_stringParser->offset--;
440 ($this->_stringParser->offset > 0)) {
441 $this->_stringParser->offset--;
446 $this->_stringParser->offset -= 9;
448 $nextLexeme = $this->_stringParser->readLexeme();
449 if ($nextLexeme !=
'startxref') {
450 #require_once 'Zend/Pdf/Exception.php'; 451 throw new Zend_Pdf_Exception(sprintf(
'Pdf file syntax error. \'startxref\' keyword expected. Offset - 0x%X.', $this->_stringParser->offset-strlen($nextLexeme)));
454 $startXref = $this->_stringParser->readLexeme();
455 if (!ctype_digit($startXref)) {
456 #require_once 'Zend/Pdf/Exception.php'; 457 throw new Zend_Pdf_Exception(sprintf(
'Pdf file syntax error. Cross-reference table offset must contain only digits. Offset - 0x%X.', $this->_stringParser->offset-strlen($nextLexeme)));
460 $this->_trailer = $this->_loadXRefTable($startXref);
461 $factory->setObjectCount($this->_trailer->Size->value);
static isWhiteSpace($chCode)