[reportlab-users] Anchors (was: Re: Table column width - problem with >2 cols)
Juha Tuomala
Juha.Tuomala at iki.fi
Tue Jan 30 07:37:27 EST 2007
On Monday 29 January 2007 15:22, Robin Becker wrote:
> Well for completeness I checked in to svn a non link alias <a> tag with two forms.
>
> # <a>anchor text</a>
> # attributes of anchors
> # fontSize=num
> # fontName=name
> # fg/textColor/color=color
> # backcolor/backColor/bgcolor=color
> # href=href
> # <a name="anchorpoint"/>
>
>
> the anchorpoint form doesn't allow interior text. As discussed I was able to
> make use of the onDraw tag machinery to get the semantics working for the second
> case. In the first case we allow href to start with # (equivalent to a document
> scheme) or you can have href with pdf:filepath or http: etc etc.
This is great news. :-)
I tried to use those and for some reason I face a wierd problem
with it.
--------------------------------------------------------------------------
#!/usr/bin/python
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus.doctemplate import SimpleDocTemplate
from reportlab.platypus.paragraph import Paragraph
def firstPage(c, t):
pass
def laterPages(c, t):
pass
f = []
gs = getSampleStyleSheet()
s = gs['Normal']
text = '<a href="#CHAPTER">CHAPTER</a>\n'
text2 = '<a name="CHAPTER" />'
f.append(Paragraph(text, s) )
f.append(Paragraph(text2, s) )
t = SimpleDocTemplate('o.pdf')
t.build(f, onFirstPage=firstPage, onLaterPages=laterPages)
-----------------------------------------------------------------------------
This fails with:
File "............./reportlab/pdfbase/pdfdoc.py", line 1526, in format
if f is None: raise ValueError, "format not resolved %s" % self.name
ValueError: format not resolved CHAPTER
However, if both <a> tags are inside the same Paragraph(), it works.
(that is, text and text2 are appended into same string
and used in the same Paragraph.)
> There's a test case usage in test/test_platypus_paragraphs.py (see the output
> file test_platypus_paragraphs_ul.pdf). There are two jumps at the beginning and
> two anchors at the end. If you zoom up the document you should be able to see if
> the jump is right for your.
I tried to use those and managed to build the particular test chapter
where those are in separate Paragraphs and it works fine there.
What could cause this 'format not resolved' error?
BR,
Tuju
--
Ajatteleva ihminen tarvitsee unta.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: link.py
Type: application/x-python
Size: 773 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20070130/71f34962/attachment.bin
More information about the reportlab-users
mailing list