我想知道是否有人可以指示如何使用xhtml2pdf用实际的html链接替换超链接。因此,如果我在我创建的PDF中有一个超链接,如下所示:
Google它会将其替换为:
<http://www.google.com>这是我当前使用的简单函数:
import os
import sys
import cgi
import cStringIO
import logging
import xhtml2pdf.pisa as pisa
pisa.showLogging()
def testSimple(
data = open('FILENAME').read(),
dest="test.pdf":
pdf = pisa.CreatePDF(
cStringIO.StringIO(data),
file(dest, "wb")
)
if pdf.err:
dumpErrors(pdf)
else:
pisa.startViewer(dest)
testSimple()发布于 2012-06-19 00:13:16
这是网站打印样式的常见要求,人们不能单击链接,但需要键入链接。
它可以actually be achieved with CSS
a:link:after, a:visited:after { content:" [" attr(href) "] "; }不过,这将取决于xhtmltopdf的CSS实现是否适用于您的情况。
如果只想将其应用于某些链接,则可以使用CSS selectors,例如
a.printable:link:after,
a.printable:visited:after {
content:" [" attr(href) "] ";
}将仅影响包含该类的链接:
<a href="http://stackoverflow.com/" class="printable">Stack Overflow</a>https://stackoverflow.com/questions/11086223
复制相似问题