sergey-tihon / Clippit

Fresh PowerTools for OpenXml
https://sergey-tihon.github.io/Clippit/
MIT License
50 stars 19 forks source link

remove caracters to prevent > at document assembler #57

Closed luizfbicalho closed 2 years ago

luizfbicalho commented 2 years ago

In some cases I have page breaks or line breaks between the assembly and I get this issue image

sergey-tihon commented 2 years ago

@luizfbicalho can you please explain why this change actually fix the issue? (it looks very magical 😁)

Or/better add simple test that reproduce this behavior without this change.

luizfbicalho commented 2 years ago

@luizfbicalho can you please explain why this change actually fix the issue? (it looks very magical 😁)

Or/better add simple test that reproduce this behavior without this change.

In some cases, there is one character in the middle of the replace that is a line break or a page break, and this character doesn't add 1 to the lenth of the string, this way the replaced string is one string smaller than the template string and when the replace happens, one ">" remains on the result document, I'll try to create a test here

luizfbicalho commented 2 years ago

Now I have different results in OpenXmlPowerTools and in Clippit correct.docx error.docx

But the clippit result in test doesn't have the > charactere in the error.docx any idea whats going on?

DA-TemplateMaior-processed-by-DocumentAssembler.docx

The test is the DA-templateMaior.docx and DA-templateMaior.xml, if you run them on old power tools you get the >

The element that I'm filtering is this

<r xmlns="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
  <lastRenderedPageBreak />
</r>

this element in this code has the Ch property as null or empty

var charsAndRuns = runsTrimmed
    .Select(r => new { Ch = UnicodeMapper.RunToString(r), r })
    //.Where(w => !string.IsNullOrEmpty(w.Ch))
    .ToList();

but for some reason this element doesn't appear on the list.

luizfbicalho commented 2 years ago

This Is solved by the #58 PR