Header and Footer
itamartz opened this issue · 10 comments
Hi,
Do you plan to add Header and Footer option to the module?
BR,
Itamar
Hi @itamartz - Yes at some point, time permitting.
Hi,
Any News regrds Header and Footer?
BR,
Itamar
@itamartz I've managed to catch up on the backlog of issues and this one is next on the list (finally!). Do you still want/need this functionality and do you have any particular requirements?
- Would a single header/footer throughout the document (with an option to not include the first page) be sufficient? This should be fairly simple to implement.
- Would you need a different header/footer per "section". This would be a lot more complicated to implement and take longer.
An example DSL implementation:
Document Example {
Style -Name Centered -Align Center
Header MyCustomHeader {
Paragraph 'My Custom Heading' -Style Centered
}
Paragraph ...
Table ....
Footer MyCustomFooter {
Paragraph 'Page $[PageNumber] of $[TotalPages]' -Style Centered
}
}
Thanks, Iain
My vote is for option 1. Option to have separate first page header/footer, and page numbers would be ideal.
@iainbrighton
Hi, Any progress regrds this?
BR,
Itamar
@itamartz It's pretty much done! I've pushed my working branch so you can take a look. I won't merge this into dev until the current dev code is published as people are asking for this to be done soon.
Check out the new examples and take them for a spin. Let me know if you see any strange behaviour!
@itamartz There is no support for images in headers/footers and I don't think there ever will be. To do so would require being able to have PScribo tables support images.
I'm not sure I understand the file path question. It's just PowerShell so you should be able to grab the filename from the $PSCommandPath
environment variable, e.g.
Document FilenameExample {
Header -Default {
Paragraph "Filename: $PSCommandPath"
}
}
~\Desktop\Document.ps1
[CmdletBinding()]
param
(
[Parameter()]
[ValidateNotNullOrEmpty()]
[String] $StylePath
)
Document CallScopes {
# Set Document Style
if ($StylePath) {
.$StylePath
}
& "$PSScriptRoot\Report.ps1" -StylePath $StylePath
}
~\Desktop\Report.ps1
[CmdletBinding()]
param
(
[String] $StylePath
)
## Report.ps1
# If custom style not set, use default style
if (!$StylePath) {
& "$PSScriptRoot\DefaultStyles.ps1"
}
Section Test {
Paragraph 'Test Paragraph'
}
~\DefaultStyles.ps1
## DefaultStyles.ps1
Header -Default -IncludeOnFirstPage -ScriptBlock {
Paragraph 'Default Header'
}
Footer -Default -IncludeOnFirstPage -ScriptBlock {
Paragraph 'Default Footer'
}
~\Desktop\Styles.ps1
## Styles.ps1
Header -Default -IncludeOnFirstPage -ScriptBlock {
Paragraph 'Custom Header'
}
Footer -Default -IncludeOnFirstPage -ScriptBlock {
Paragraph 'Custom Footer'
}
Running this results in no error?
C:\Users\Iain> ~\Desktop\Document.ps1 -Verbose
Id : CALLSCOPES
Type : PScribo.Document
Name : CallScopes
Sections : {@{Id=1c1b72ea-24cd-4da9-897b-75e9a8625d15; Level=0; Number=1; Name=Test; Type=PScribo.Section;
Style=; Tabs=0; IsExcluded=False; Sections=System.Collections.ArrayList; Orientation=Portrait;
IsSectionBreak=False; IsSectionBreakEnd=False}}
Options : {MarginBottom, MarginLeft, PageOrientation, MarginRight...}
Properties : {TableStyles, Paragraphs, Sections, Styles...}
Styles : {Caption, TOC, Heading4, Heading2...}
TableStyles : {TableDefault}
NumberStyles : {Number, Roman, Letter}
Lists : {}
DefaultStyle : Normal
DefaultTableStyle : TableDefault
DefaultNumberStyle : Number
Header : @{HasFirstPageHeader=False; HasDefaultHeader=False; FirstPageHeader=; DefaultHeader=}
Footer : @{HasFirstPageFooter=False; HasDefaultFooter=False; FirstPageFooter=; DefaultFooter=}
TOC : {@{Id=1c1b72ea-24cd-4da9-897b-75e9a8625d15; Number=1; Level=0; Name=Test}}