20đź‘Ť
Seems that Google Chrome doesn’t display the PDF titles at all.
I tested the link in your comment (biblioteca.org.ar) and it displays in Firefox as ” – 211756.pdf”, seems there’s an empty title and Firefox then just displays the filename instead of the full URL path.
I reproduced the same behaviour using this piece of code:
from reportlab.pdfgen import canvas
c = canvas.Canvas("hello.pdf")
c.setTitle("hello stackoverflow")
c.drawString(100, 750, "Welcome to Reportlab!")
c.save()
Opening it in Firefox yields the needed result:
I found out about setTitle
in ReportLab’s User Guide. It has it listed on page 16. 🙂
6đź‘Ť
I was also looking for this and I found this in the source code.
reportlab/src/reportlab/platypus/doctemplate.py
@ line – 467
We can set the document’s title by
document.title = 'Sample Title'
- Django unable to find MySQLdb python module
- Maintain SQL operator precedence when constructing Q objects in Django
- Group models in django admin
- Django select_related for multiple foreign keys
5đź‘Ť
I realise this is an old question but dropping in an answer for anyone using SimpleDocTemplate
. The title
property can be set in constructor of SimpleDocTemplate
as a kwarg. e.g.
doc = SimpleDocTemplate(pdf_bytes, title="my_pdf_title")
- How do you use Django-filter's '__in' lookup?
- ERROR: Invalid HTTP_HOST header: '/webapps/../gunicorn.sock'
- How to debug a Django MultiValueDictKeyError on Formset POST
- Has_permission() missing 1 required positional argument: 'view'
0đź‘Ť
If you are using trml2pdf, you will need to add the “title” attribute in the template tag, ie., <template title=”Invoices” …
- Should I use Celery or Carrot for a Django project?
- Uwsgi http is ambiguous
- How to add attributes to option tags?
0đź‘Ť
In addition to what others have said, you can use
Canvas.setTitle("yourtitle")
which shows up fine in chrome.
- IPython doesn't work in Django shell
- How do you access query params in a Django Rest Framework 3.0 serializer?
- Can Django run on Gunicorn alone (no Apache or nginx)?