I did some thing different opened the PDF file in GIMP and then converted it to XPM which was much smaller as size.
Then this XPM was successfully imported in the layout using your script.
But anyway the final layout picture looked pretty ugly ( wires to bondpads looked like rows of squares for example ).
So I will try to find another decision, convert PDF to some vector ascii format and then to extract data.
In fact we did some thing similar. Converted PDF to PS and then opened PS file in text editor, and just manually taken the sizes of the lines. And using this number pairs to create lines in layout, we succeeded to do that in one old Layout tool called ( ICED ) but now I will try to automate that for Cadence.