[reportlab-users] Reportlab text not searchable in Apple OSX Preview.App? but searchable in Acrobat and google-pdf viewer ?

Peter peter at maubp.freeserve.co.uk
Wed Aug 5 11:28:38 EDT 2009


On Wed, Aug 5, 2009 at 4:13 PM, Robin Becker<robin at reportlab.com> wrote:

> ... I would guess the problem lies in the preview app.

>

> If you just substitutute 0 for 90 & -90 in the above then essentially the

> same code as for the failing case is issued. Does the preview still fail?

>

> If the preview is actually rendering the pdf and then searching, the 0

> degrees case should be searchable. If that's the way the search is happening

> then it's no surprise that the search should fail if the rendered letters

> are at 90deg.


I just tied this:

import reportlab.pdfgen.canvas as canvas
c = canvas.Canvas("searchtext.pdf")
c.rotate(0)
textobj = c.beginText(10,10)
textstring = "hello world with rotation of zero!"
textobj.textLines(textstring)
c.drawText(textobj)
c.rotate(0)
c.showPage()
c.save()

And Preview can search this (rotation of 0). I've also got a few other
variations to work like 0.1 degrees. But not 60, 89 or 90 degrees.

Interestingly at 45 degrees, Preview isn't getting all the words right,
some have extra spaces. This means in the following example it
can find "hello" and "45" but none of the other words:

import reportlab.pdfgen.canvas as canvas
c = canvas.Canvas("searchtext.pdf")
c.rotate(45)
textobj = c.beginText(10,-10)
textstring = "hello world with rotation of 45!"
textobj.textLines(textstring)
c.drawText(textobj)
c.rotate(-45)
c.showPage()
c.save()


Peter


More information about the reportlab-users mailing list