Thank you very much for your reply. Questions and answers are attached below. I will try it with your suggestion and let you know.
> Hi Jason,
> I tried to register an account on your website today. However I
> haven't received any confirmation yet. So that I have to send my
> question via email,
No sure why that might be - it happens sometimes (could be a spam filter at your end, or something wrong with the mail sender). Anyway, I've activated your registration manually. I'll answer your question here, but please post your question and my response to the forum, thanks.
> I'm using docx4j 2.3.0.
> I'm working on the docx importing, to import one docx file into another. Could you please advice, in general, what should be paid attention?
See http://blogs.msdn.com/brian_jones/archi ... ingml.aspx http://blogs.msdn.com/ericwhite/archive ... l-sdk.aspx
Or you can use altChunk, as those posts mention.
> Currently I have a problem to import images. Here is an example,
> In the main.docx, there is a picture, so that in the word\media directory there is a file image1.jpeg.
> In the sub.docx, there is a picture, so that in the word\media directory there is a file image1.jpeg, which is a different picture than the one in main.docx.
> When using BinaryPartAbstractImage.createImagePart to import sub docx into main.docx, sub image1.jpeg overrides main image1.jpeg.
> I'm suspecting that in docx4j the way to generate image name, with a static counter, may not be appropriate for the situation like, batch processing, multiple thread, etc. I like the way to generate Id in RelationshipsPart, methods getNextId() and resetIdAllocator(). Do you have any suggestion on this issue?
> Please correct me if I'm wrong, or there is a better way to create image part.
In RelationshipsPart, the method addRelationship will automatically assign an id if the rel being added does not already have one.
In this automatic assignment mode, the code needs to be changed to call resetIdAllocator() before getNextId(). I've committed this fix.
If you have to use v2.3.0, you ought to be able to achieve the same effect by calling:
before you createImagePart
Alternatively, you can create the rel yourself, and assign it an id which does not clash. Call this yourRel.
You would then call you main document part's relationships part's loadPart(existingImagePart, yourRel) You may need to existingImagePart.setPackage( newPackage) first.
You'd also have to create the Inline image object yourself.
Hope this helps