Bug 10209 - Cairo 1.4.0 generates invalid PDF files
Summary: Cairo 1.4.0 generates invalid PDF files
Status: RESOLVED INVALID
Alias: None
Product: cairo
Classification: Unclassified
Component: pdf backend (show other bugs)
Version: 1.4.0
Hardware: x86 (IA32) Linux (All)
: high blocker
Assignee: Kristian Høgsberg
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-07 04:24 UTC by Simon Ask Ulsnes
Modified: 2007-03-07 11:49 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
The correct PDF file. (1.07 KB, application/pdf)
2007-03-07 04:25 UTC, Simon Ask Ulsnes
Details
Corrupt PDF file. (1.18 KB, application/pdf)
2007-03-07 04:26 UTC, Simon Ask Ulsnes
Details
Program to generate the PDF. (719 bytes, text/x-csrc)
2007-03-07 04:30 UTC, Simon Ask Ulsnes
Details

Description Simon Ask Ulsnes 2007-03-07 04:24:56 UTC
I just installed cairo-1.4.0 today, and found that my code that outputs PDF files no longer works.

The generated PDF files make every reader I've tried crash. When you look at the files, you can see why.

I'm creating a PDF file of size 200x200 points, with a green background and some lines and arcs.

With the cairo-1.2.6 backend, the BBox header of the PDF file correctly specifies the size.

<< /Length 3 0 R
   /Filter /FlateDecode
   /Type /XObject
   /Subtype /Form
   /BBox [ 0 0 200 200 ]
>>

With cairo-1.4.0, the header looks as follows:

<< /Length 3 0 R
   /Filter /FlateDecode
   /Type /XObject
   /Subtype /Form
   /BBox [ 0 0 0 820455767354305755076758094100026457645073301504 ]
>>

... which is obviously invalid.
Comment 1 Simon Ask Ulsnes 2007-03-07 04:25:54 UTC
Created attachment 9011 [details]
The correct PDF file.

This file was generated by cairo-1.2.6.
Comment 2 Simon Ask Ulsnes 2007-03-07 04:26:26 UTC
Created attachment 9012 [details]
Corrupt PDF file.

This file was created by cairo-1.4.0.
Comment 3 Simon Ask Ulsnes 2007-03-07 04:30:26 UTC
Created attachment 9013 [details]
Program to generate the PDF.

Compile with: gcc -o test test.c -lcairo
Run with: ./test
Outputs test.pdf to the current directory.
Comment 4 Simon Ask Ulsnes 2007-03-07 05:42:38 UTC
Ok, it turns out it's necessary to explicitly cast the pointer to the surface created by cairo_pdf_surface_create to a cairo_surface_t*. This should not be necessary, since the return type of said function is cairo_surface_t*, but it appears to make a difference.

Anyone care to explain? :-S

- Simon
Comment 5 Behdad Esfahbod 2007-03-07 11:49:26 UTC
Because you are on a x86_64 system, with sizeof(int)!=sizeof(void*), and you are not including cairo-pdf.h, so cairo_pdf_surface_create() is not prototyped and assumed to return an int.  So you get the following warning:

test.c: In function ‘main’:
test.c:6: warning: initialization makes pointer from integer without a cast


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.