Skip to content
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

Docxtemplater read a word file with line break #640

Closed
Angelk90 opened this issue Feb 22, 2022 · 3 comments
Closed

Docxtemplater read a word file with line break #640

Angelk90 opened this issue Feb 22, 2022 · 3 comments

Comments

@Angelk90
Copy link

Environment

  • Version of docxtemplater : ^3.29.0
  • Runner : Browser

How to reproduce my problem :

Hi @edi9999 ,

function getFullText(content, tagsXmlArray) {
const matcher = xmlMatcher(content, tagsXmlArray);
const result = matcher.matches.map(function (match) {
return match.array[2];
});
return wordToUtf8(convertSpaces(result.join("")));
}

I'm looking for a way to be able to read a document even if it has a line wrap.

At the moment the only way to be able to read a document seems to be to use the following function: doc.getFullText().

So I went to see how the function is done, it looks like a join is done, so all the text is seen without wrapping.

So if the function were changed like this what would happen:

 function getFullText(content, tagsXmlArray, separator = '') { 
 	const matcher = xmlMatcher(content, tagsXmlArray); 
 	const result = matcher.matches.map((match) => match.array[2]); 
 	return wordToUtf8(convertSpaces(result.join(separator))); 
 } 
@edi9999
Copy link
Member

edi9999 commented Feb 23, 2022

Yes, doc.getFullText() is there for historical purposes (I added it 7 years ago and didn't want to break backwards-compatibility).

Adding a correct algorithm for this would require quite some work, I'm not considering adding it myself but would accept a pull request.

However the separator thing would not work.

@edi9999 edi9999 closed this as completed Feb 23, 2022
@edi9999
Copy link
Member

edi9999 commented Feb 24, 2022

I have just added to the roadmap to remove the getFullText in v4 to avoid the confusion for future users.

#340

I don't want to have code that I know is not core to the library and will not have the proper care it deserves.

@Angelk90
Copy link
Author

@edi9999 : I personally wouldn't remove it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants