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 and Footer #80

Open
itamartz opened this issue Jul 30, 2018 · 10 comments
Open

Header and Footer #80

itamartz opened this issue Jul 30, 2018 · 10 comments

Comments

@itamartz
Copy link

Hi,
Do you plan to add Header and Footer option to the module?

BR,
Itamar

@iainbrighton
Copy link
Owner

Hi @itamartz - Yes at some point, time permitting.

@itamartz
Copy link
Author

Hi,
Any News regrds Header and Footer?

BR,
Itamar

@iainbrighton
Copy link
Owner

@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

@itamartz
Copy link
Author

itamartz commented Mar 7, 2020 via email

@tpcarman
Copy link

tpcarman commented Mar 7, 2020

My vote is for option 1. Option to have separate first page header/footer, and page numbers would be ideal.

@itamartz
Copy link
Author

@iainbrighton
Hi, Any progress regrds this?

BR,
Itamar

@iainbrighton
Copy link
Owner

@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
Copy link
Author

itamartz commented Mar 29, 2020 via email

@iainbrighton
Copy link
Owner

@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"
    }
}

@iainbrighton
Copy link
Owner

~\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}}

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

No branches or pull requests

3 participants