2011-01-26 2 views

답변

2

안녕하세요, 당신이 편집기를 사용하는 경우 답변을 얻은 다음 그 내용을 "내용"문자열에 저장하십시오. 그러면 다음 코드가 작동합니다.

contents = "<html><head><style type='text/css'>@font-face {font-family: comic sans ms; src: url(media/fonts/comic.ttf);}</style></head><body> " + contents + " </body></html>" 
template = Template(contents) 

context = Context() 
template_rendered = template.render(context) 

name="mypdf.pdf" 

import ho.pisa as pisa 
pfile = file(name, 'wb') 
pisa.CreatePDF(template_rendered.encode("UTF-8"), pfile ,encoding='UTF-8') 
pfile.close() 

내 생각에는 많은 답변이 있지만 필자의 경우 tinymce 편집기를 사용하면이 솔루션이 작동합니다.

+1

피사는 url() 호출의 상대적인 기반으로 프로젝트 루트를 사용하는 것 같습니다. –

관련 문제