Error while adding images to documents

Asked by Boris Gorelik on 2011-09-19

I want to add image to the file generated by POD. I added the following note:

do text
from document(at=img)

In my program I set the img variable to an existing png image, however, when I Render the document and open the resulting file, I get the following error "The file 'result.odt' is corrupt and therefore cannot be loaded". I then select the option to repair the file and after OOo opens it, at the place where I expect to see the image, I see an object with a text in it file:///C:/temp/report/result.odt/C:\temp\report\result.odt.1316422070.069000\unzip\Pictures\f.5.1316422070.210000.png

It is obvious that the text refers to a temporary file that Renderer created during its work, however that file (the entire directrory) is being removed immediately after Renderer completes its job. I tried to set forceOoCall=True during my call to Renderer, but this didn't help. What am I doing wrong?

Question information

Language:
English Edit question
Status:
Solved
For:
Appy Edit question
Assignee:
No assignee Edit question
Solved by:
Boris Gorelik
Solved:
2011-09-20
Last query:
2011-09-20
Last reply:
2011-09-20
Mikhail Denisenko (denisenkom) said : #1

It seems like a bug with Windows version
I've created a patch, you need to apply it to appy/pod/doc_importers.py

Here is the patch file
===================================
67c67
< f = file(self.importPath, 'w')
---
> f = file(self.importPath, 'wb')
184c184
< def getImportFolder(self): return '%s/unzip/Pictures' % self.tempFolder
---
> def getImportFolder(self): return os.path.join(self.tempFolder, 'unzip', 'Pictures')
192c192
< i = importPath.rfind('/Pictures/') + 1
---
> i = importPath.rfind('%sPictures%s' % (os.sep, os.sep)) + 1
211c211
< i = self.importPath.rfind('/Pictures/')
---
> i = self.importPath.rfind('%sPictures%s' % (os.sep, os.sep))
212a213
> imagePath = imagePath.replace('\\', '/')
========================================

Thank you Mikhail! This will be released with Appy 0.7.1. Indeed, few Windows users around... till now ;-) Gaetan

Boris Gorelik (boris-gorelik) said : #3

Thank you, Mikhail. Your patch solved my problem