-
-
Notifications
You must be signed in to change notification settings - Fork 465
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
Different First Page Header **Question** #72
Comments
Sorry, this isn't available in this package as of yet |
Has any progress been made on this? If not, I can contribute. I desperately need this feature. |
no progress has been made I wasnt aware of "Different First Page" until you mentioned actually If you can make a PR, that would be awesome |
Ok no problem, I'll work on it. |
In your opinion what is the best way to add and test new features? Are you creating files, like the demo files, and then compiling the code everytime you want to run it? Any advice would be appreciated. This is my first time working with TypeScript and WebpackLoader. |
And But yes, what I generally do is run the demo each time I make a change to see if it creates the correct result, as well as write the Because you are working with headers section, I would run the header and footer demo to test if it broke existing functionality or not |
Happy to report back with findings on Page Numbers and Different First Page Headers. I have both Features working. Different First Page Header:
Content added to header2.xml is the content of the first-page header. Content in header1.xml is 2nd-page onward. Page Numbers:
I have code working for page numbers and different first-page header. I don't feel comfortable doing a PR though because the code is a mess! I would like to discuss how you would like to organize the code, and how the features should be set. For example, how would you like page numbers to be set? Currently, I have a function in the Run class that sets them. However, this probably is not the best place since realistically page numbers only go in headers. Same for the different first-page header option, what makes the most sense to for that? Maybe something similar to the current header... And if the the firstpageheader is not empty, then use it.
Any thoughts or recommendations? |
Is this feature exclusive to the "first page" only? What about second page header, third page header? If so, maybe it makes more sense making headers into an array like: doc.Header // for main header
doc.PageHeaders.getForPage(1), doc.PageHeaders.getForPage(2) // etc If not, then this is fine: doc.FirstPageHeader Or something like that Edit:From some research, word only supports first page header, and odd/even headers: https://www.howtogeek.com/103481/how-to-use-multiple-headers-and-footers-in-a-single-document/ So do:
and leave We will worry about odd/even headers some point in the future |
Okay, sounds good. I'll get to work on that. For the page numbers, I verified that they are only possible in headers. This means that they should only be available when adding to paragraphs that will be added to a header. How can we do that? Currently, this is how I am setting them.
|
What does I cannot see it in your code: https://github.com/formatically/docx/blob/master/src/file/paragraph/run/run.ts Does it add 1, 2, 3, etc? What about customising it, so it's "Page 1", "Page 2" |
Sorry, I have not committed my code yet. I'll finish cleaning somethings and commit. pageNumber() just adds the number, like 1, 2, 3. To customize to say "Page 1", you must do
I think this is preferred since many people will want custom text before the page number. Also, they may want to right align, left align, etc. This gives them ability to fully customize. |
Nice, it seems good 👍 |
In order for there to be a "different first page" header, the following properties must be in the sectionProperties for the body.
How do you recommend adding these properties after the sectionProperties has already been initialized? For example if someone makes a different first page header by doing, For testing purposes I just hard coded them in, to verify my methods work. |
I think to simplify things, hard code it in: Make sure it does not break existing demos Yes, it may seem bad, but it will make the code cleaner and nicer to work with. Otherwise we would have to make conditional setters depending on whether the user have made a first page header and what not. Not worth it IMO. |
Unfortunately hardcoding it in is not an option b/c those properties should not be present when all the headers are the same. Those properties should only be in the section properties when the user wants a "different first page" header. Maybe the easiest solution would be to add an option that can be passed in when creating a new document. That way not much would have to change in the code. The sectionProperties would still be initialized the same way. Maybe adding a field in SectionPropertiesOptions that designates a "different first page header". |
Hmm I see what you mean Yeah that sounds good Easy to use for the user are you going to add a |
I'll work something out and commit the code to my fork so you can make sure everything looks okay. Ill be traveling for the next 24 hours so it might not be till Tuesday until I have something. |
Sure! No problem 😄 I will have a look once I get time |
I added a differentFirstPageHeader option to sectionProperties. I have the code committed to my fork and demo8 has an example of using it. |
Good work Can you call it demo14? Thanks |
Absolutely, I’ll make the change and do another commit. Thanks! |
Hello,
When creating word documents with Word or Google Docs, there is a "Different First Page" header option. Can this functionality be recreated in this package?
Thanks!
The text was updated successfully, but these errors were encountered: