<s> from xhtml2pdf . util import pisaTempFile , getFile , PyPDF2 <EOL> import logging <EOL> log = logging . getLogger ( "<STR_LIT>" ) <EOL> class pisaPDF : <EOL> def __init__ ( self , capacity = - <NUM_LIT:1> ) : <EOL> self . capacity = capacity <EOL> self . files = [ ] <EOL> def addFromURI ( self , url , basepath = None ) : <EOL> obj = getFile ( url , basepath ) <EOL> if obj and ( not obj . notFound ( ) ) : <EOL> self . files . append ( obj . getFile ( ) ) <EOL> addFromFileName = addFromURI <EOL> def addFromFile ( self , f ) : <EOL> if hasattr ( f , "<STR_LIT>" ) : <EOL> self . files . append ( f ) <EOL> self . addFromURI ( f ) <EOL> def addFromString ( self , data ) : <EOL> self . files . append ( pisaTempFile ( data , capacity = self . capacity ) ) <EOL> def addDocument ( self , doc ) : <EOL> if hasattr ( doc . dest , "<STR_LIT>" ) : <EOL> self . files . append ( doc . dest ) <EOL> def join ( self , file = None ) : <EOL> output = PyPDF2 . PdfFileWriter ( ) <EOL> for pdffile in self . files : <EOL> input = PyPDF2 . PdfFileReader ( pdffile ) <EOL> for pageNumber in xrange ( input . getNumPages ( ) ) : <EOL> output . addPage ( input . getPage ( pageNumber ) ) <EOL> if file is not None : <EOL> output . write ( file ) <EOL> return file <EOL> out = pisaTempFile ( capacity = self . capacity ) <EOL> output . write ( out ) <EOL> return out . getvalue ( ) <EOL> getvalue = join <EOL> __str__ = join </s>
