diff --git a/product/ERP5/Document/PDFDocument.py b/product/ERP5/Document/PDFDocument.py index 685c35e438b5c7eb3631c0270f08cd45b8a0d21d..7e50612bf81882ecabc7e33cfb2b08e5c1f2ea6e 100644 --- a/product/ERP5/Document/PDFDocument.py +++ b/product/ERP5/Document/PDFDocument.py @@ -28,7 +28,8 @@ import tempfile, os, cStringIO from AccessControl import ClassSecurityInfo -from Products.CMFCore.utils import getToolByName +from Products.CMFCore.utils import getToolByName, _setCacheHeaders,\ + _ViewEmulator from Products.ERP5Type import Permissions, PropertySheet, Constraint, interfaces from Products.ERP5Type.Cache import CachingMethod @@ -79,7 +80,14 @@ class PDFDocument(Image, ConversionCacheMixin): it is always a zip because multi-page pdfs are converted into a zip file of many images """ - if format is None: + _setCacheHeaders(_ViewEmulator().__of__(self), {'format' : format}) + if format is '': + if self.getSourceReference() is not None: + filename = self.getSourceReference() + else: + filename = self.getId() + RESPONSE.setHeader('Content-Disposition', + 'attachment; filename="%s"' % filename) RESPONSE.setHeader('Content-Type', 'application/pdf') return str(self.data) if format in ('html', 'txt', 'text'):