The Question has been closedby
I have 2 pdfs stored as strings. I want to store them as a temporary file on the server. My problem is the PDF is not properly being stored. Whatever file is written second over writes the file that is written first. Seperately, the 2 files can be stored like this and if you reverse the order of the files the second file always over writes the first.
fd, file_name = mkstemp() temp = result temp2 = base64.decodestring(record.attachment_id.datas) output = ''.join([temp,"\f",temp2]) os.write(fd, output)
I want to insert a new page character or something to prevent the second file from over writing the second file in the PDF. What can I do to concatenate 2 PDFs in openerp?
This is the way i finally got it to work, but this seems overly complicated. There has to be a way to concatenate the PDFs without storing them as temporary files first.
fd, file_name = mkstemp() fd2, file_name2 = mkstemp() fd3, file_name3 = mkstemp() os.write(fd, result) os.write(fd2, base64.decodestring(record.attachment_id.datas)) output = PdfFileWriter() pdfOne = PdfFileReader(file(file_name, "rb")) pdfTwo = PdfFileReader(file(file_name2, "rb")) pgcnt=pdfOne.getNumPages() for i in range(0,pgcnt): output.addPage(pdfOne.getPage(i)) pgcnt=pdfTwo.getNumPages() for i in range(0,pgcnt): output.addPage(pdfTwo.getPage(i)) outputStream = file(file_name3, "wb") output.write(outputStream) outputStream.close()
About This Community
|Asked: 5/7/13, 3:05 AM|
|Seen: 2073 times|
|Last updated: 3/16/15, 8:10 AM|