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

Metadata is returning wrong number of pages #240

Closed
Ademking opened this issue Sep 26, 2021 · 4 comments
Closed

Metadata is returning wrong number of pages #240

Ademking opened this issue Sep 26, 2021 · 4 comments
Labels

Comments

@Ademking
Copy link

Thank you so much for this library. It's so helpful.

I have this bug... Metadata is returning wrong page number... the final document is 47 pages but it's showing 5

I think it's because of HTML content? Maybe?

image

image

  • Runtime environment; NodeJs
  • Version: 4.8.0

I'm using HTML content inside a FOR Loop... example

+++HTML `
<body>
  ${$t.code}
</body>
`+++
@mathe42
Copy link
Contributor

mathe42 commented Sep 27, 2021

Is your template document 5 pages long?

@jjhbw
Copy link
Collaborator

jjhbw commented Sep 27, 2021

The number of pages is simply grabbed from a docx XML metadata element. It can only feasibly be determined by a docx renderer, like MS Word or LibreOffice.
The document needs to be rendered by e.g. Word at least once before the length of the document can be known. Word will update the 'number of pages' metadata element when saving the document. You are probably looking at the number of pages of your template because the metadata hasn't been updated yet, like @mathe42 says.

In more technical terms: I don't think the length of the document can be determined just by static analysis of the docx XML; the XML needs to be rendered. The pages metadata is just a reflection of that.

@jjhbw jjhbw added the question label Sep 27, 2021
@Ademking
Copy link
Author

@mathe42: Yes. It's 5 pages

@jjhbw: I get it now... So i can't get the exact number using metadata
Thank you guys for the help 👍👍
Keep up the good work

@Ademking Ademking changed the title Metadata is return wrong number of pages Metadata is returning wrong number of pages Sep 27, 2021
@jjhbw
Copy link
Collaborator

jjhbw commented Sep 27, 2021

👍 Great. Yes, this seems to be a hard limitation. Sorry I couldn't give a more satisfying answer.

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

No branches or pull requests

3 participants