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

Header / Footer Support #13

Open
Apoc70 opened this issue Mar 24, 2023 · 7 comments
Open

Header / Footer Support #13

Apoc70 opened this issue Mar 24, 2023 · 7 comments

Comments

@Apoc70
Copy link

Apoc70 commented Mar 24, 2023

Does the current release support adding headers and footers to a Word document?

@PrzemyslawKlys
Copy link
Member

$Document.AddHeadersFooters() is what you look for, but as I see it's not available in current PSWriteOffice which is weird.

I really need to make libraries consistent with current versions of OfficeIMO

@jpedlowCDW
Copy link

Bumping this one up, It looks like there's still no header/footer support, but appears to be in OfficeIMOI.
If I were smarter in C#, I'd try to slam in a PR. It also appears that the Lib folder containing the dll's with the release isn't included.
Thanks for everything!

@PrzemyslawKlys
Copy link
Member

I'm pretty sure the current version on PowerShellGallery has support for AddHeadersFooters. Have you tested it?

As for missing Lib, it's because I decided you need to build it yourself using Build script if you want to play with adding new features. We're not supposed to upload binary files to GIT.

@jpedlowCDW
Copy link

@PrzemyslawKlys I could be doing something wrong, but I cannot find any evidence there's support in the module other than REMOVING headers currently. I suspect it's a bit behind IMO.

From what I can see between the docs, and checking PS:
image
It's also appears to not be an exported function in the PSD1 for the module.
Happy to accept that I could be wrong, but I can't find any evidence of it.

I'd submit a PR to fix it if I had the C# knowledge, but I'm not quite there yet, unfortunately.
Really have high hopes for this module :)

@PrzemyslawKlys
Copy link
Member

It's maybe not straightforward but everything doable in C#, all the methods are available.

$Document = New-OfficeWord -FilePath $PSScriptRoot\Documents\BasicDocument.docx

$Document.Settings.FontFamily = 'Times New Roman'

$Document.AddHeadersAndFooters()

$MyParagraph = $Document.Header.Default.AddParagraph("This is a header")

New-OfficeWordText -Document $Document -Text 'This is a test, very big test ', 'and this should be bold' -Bold $null, $true -Underline Dash, $null

New-OfficeWordText -Document $Document -Text 'This is a test, very big test', 'ooops' -Color Blue, Gold -Alignment Right

$Paragraph = New-OfficeWordText -Document $Document -Text 'Centered' -Color Blue, Gold -Alignment Center -ReturnObject

New-OfficeWordText -Document $Document -Text ' Attached to existing paragraph', ' continue' -Paragraph $Paragraph -Color Blue

Save-OfficeWord -Document $Document -Show

image

Wrapping it up into easier PowerShell commands takes effort and time and currently I lack time.

Same goes for properties of given Paragraph for example:

image

image

image

$Document | Get-Member

image

image

I will release new version soon, but mostly just with new DLL, not with fully functional PowerShell cmdlets

@jpedlowCDW
Copy link

jpedlowCDW commented Nov 27, 2023

THANK YOU @PrzemyslawKlys . :) That solves the case right there.

I'm looking for standalone cmdlets while they're sitting as methods.
Thank you for taking the time to explain/demonstrate to a mere mortal like me. I'm off to do some tinkering. :)

I'll try to devote some effort to docs/examples, if that's alright with you? :)

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Nov 28, 2023

Sure, why not. Just a warning - people who say that - usually end up realizing it's harder than it seems and never come back 😂🤣 You can always write wrapper around those commands and do PRs for that. I guess effectively we should have similar options as PSWriteWord project.

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

3 participants