-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
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
New bug in ApplyTemplate method after V2.1.0 released #445
Comments
Also, there is old bug in this method - whereas |
Hello,
An easy fix could be to use a copy of the Paragraphs, by replacing the for loop with:
In Container.RemoveParagraph(), the call to "paragraph.Xml.Remove()" should remove any images contained in a paragraph. On the other hand, tables are currently not removed because they are located just after their associated paragraph in the ooxml. Here's what you could do in Container.RemoveParagraph() to remove the paragraph's tables:
Those 2 issues will be fixed in v2.5. |
Thanks for the feedback, @XceedBoucherS. |
Hi @podolsky-v , This will be fixed in v2.5. In the meantime, you can go in Container.RemoveParagraph() and add:
Thank you for your feedback ! |
Hello,
My old code stopped working after I updated nuget package from V2.0.0 to V2.3.0. The reason is that
ApplyTemplate( Stream templateStream, bool includeContent )
method now throws anSystem.InvalidOperationException
whenincludeContent
is set tofalse
because of those reasons:In this part of
ApplyTemplate
methodparagraph.Remove( false );
modifiesParagraphs
collection, and this causes foreach-loop to break. This is happening because in V2.1.0 (commit9c431afb
) realization of Paragraphs collection was changed and now there is underlyingList<Paragraph> _editableParagraphsCollection
list which is modified whenparagraph.Remove( false );
callsRemoveParagraphFromCache( paragraph );
The code to reproduce the bug is as simple as that:
where
template.docx
is any docx created in MS Word, because even empty document includes one empty paragraph. I'm not sure which is the most accurate way to fix this issue.The text was updated successfully, but these errors were encountered: