We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in Composer.insert(self, index, doc, remove_property_fields) ... --> 213 img_part = doc.part.rels[rid].target_part 215 new_img_part = self.pkg.image_parts._get_by_sha1(img_part.sha1) 216 if new_img_part is None:
KeyError: None
this happened when I append a document that has some pic to Composer like this: tp = Document(os.path.join(directory, file)) master.append(tp)
The text was updated successfully, but these errors were encountered:
from docxcompose.image import ImageWrapper from docxcompose.utils import NS from docx.opc.constants import RELATIONSHIP_TYPE as RT def add_shapes(self, doc, element): shapes = xpath(element, './/v:shape/v:imagedata') for shape in shapes: rid = shape.get('{%s}id' % NS['r']) if rid is None: # 这里会有时候取不到 导致报错 重写 continue img_part = doc.part.rels[rid].target_part new_img_part = self.pkg.image_parts._get_by_sha1(img_part.sha1) if new_img_part is None: image = ImageWrapper(img_part) new_img_part = self.pkg.image_parts._add_image_part(image) new_rid = self.doc.part.relate_to(new_img_part, RT.IMAGE) shape.set('{%s}id' % NS['r'], new_rid) Composer.add_shapes = add_shapes
Add this code to the front of your code. You can fix it temporarily with this method.
Sorry, something went wrong.
No branches or pull requests
in Composer.insert(self, index, doc, remove_property_fields)
...
--> 213 img_part = doc.part.rels[rid].target_part
215 new_img_part = self.pkg.image_parts._get_by_sha1(img_part.sha1)
216 if new_img_part is None:
KeyError: None
this happened when I append a document that has some pic to Composer like this:
tp = Document(os.path.join(directory, file))
master.append(tp)
The text was updated successfully, but these errors were encountered: