raunakbinani / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

Document without text causes PHP an undefined index notice #105

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a document that has no text (including white space)
2. Render the document (DOMPDF Revision 194 or greater)

What is the expected output? What do you see instead?
The document should render without error. However, PHP will throw the
following notice instead:

Notice: Undefined index: in dompdf/lib/class.pdf.php on line 3695

The severity of the result depends on whether or not display_errors is
enabled. When enabled the PDF will not display correctly. When disabled the
PDF will display, but the user may see notices in the PHP error.log.

The problem is due to the change made in Revision 194. As of this revision
CPDF::filterText() relies on the currently loaded font to determine whether
or not to return the text as Unicode. A font is not loaded by CPDF until
document text is created. However, filterText() is applied to document
metadata (author, creation date, etc.) as well as document text.

Original issue reported on code.google.com by eclecticgeek on 8 Dec 2009 at 9:56

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 8 Dec 2009 at 9:58

Attachments:

GoogleCodeExporter commented 9 years ago
There are a number of text-related methods that rely on a font having been 
loaded. If
no font is loaded these methods load the core font Helvetica. I updated 
filterText()
so that it, too, loads Helvetica if needed.

Since multiple methods load a font when needed I modified the CPDF class so 
that the
font loaded is stored in a class property (defaultFont) so that this value can 
be
easily maintained.

Original comment by eclecticgeek on 8 Dec 2009 at 10:07

GoogleCodeExporter commented 9 years ago
addressed in Revision 205

Original comment by eclecticgeek on 8 Dec 2009 at 10:07

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 30 May 2013 at 5:15