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

Question: Table width #13

Open
Greyland99 opened this issue Aug 17, 2020 · 4 comments
Open

Question: Table width #13

Greyland99 opened this issue Aug 17, 2020 · 4 comments

Comments

@Greyland99
Copy link

Hi,

i'm sorry but i can't figure out, how to keep the tables within the page boarders. For the most tables it works, but if there are only a few characters, then the table goes over the page width.

Any suggestion?

code is looking like this

New-PDFPage -PageSize A4 -MarginLeft 20 -MarginRight 20 -MarginTop 20 -MarginBottom 20 { New-PDFText -Text 'TITEL' -FontBold $true New-PDFText -Text 'LONGTEXT' New-PDFText -Text 'TITEL' -FontBold $true New-PDFText -Text 'LONGTEXT' New-PDFText -Text 'TITEL' -FontBold $true New-PDFTable -DataTable $PropertyTable }

@PrzemyslawKlys
Copy link
Member

Can you provide what data you have in $PropertyTable?

@Greyland99
Copy link
Author

Greyland99 commented Aug 17, 2020

As this information is confidential, i will try to give you a valid example. The provided example is exact as long as the original, but anonymised. I think the crucial element is the DistinguishedName, which is a little bit too long. But i have examples which are in the boarders, so it is not in general like this.

I attached example code as txt, because the codeblock douesnt work very good.

EXAMPLE2.pdf
EXAMPLE1.pdf
ExampleTableWidthInPDF.txt

###### ORGINAL CODE EXTRACT #########

#Group Variable
$Group = 'ExampleGroupName'

#Property Set for AD Query
$GroupProperties = @( 'Name', 'Description', 'Info', 'managedby','msExchCoManagedByLink', 'SID', 'GroupCategory', 'GroupScope', 'DistinguishedName')

#Base Data for PropertyTable
$ADGroup = Get-ADGroup -Identity $Group -Properties $GroupProperties | select $GroupProperties

#PropertyTable normaly is generated by this ....
$PropertyTable = @(
        [ordered] @{ Name = $ADGroup.Name}
        [ordered] @{ Description = $ADGroup.Description}
        [ordered] @{ Info = $ADGroup.Info}

        if (($ADGroup.managedby).count -ne 0) {
            [ordered] @{ Manager = $ADGroup.managedby | Get-ADUser | select -ExpandProperty name}
        } else {
            [ordered] @{ Manager = "Not defined!"}
        }
        
        $i = 1
        if (($ADGroup.msExchCoManagedByLink).count -ne 0) {
            foreach ($CoManager in ($ADGroup.msExchCoManagedByLink | Get-ADUser | select -ExpandProperty name)) {
                    [ordered] @{ "CoManager $i" = $CoManager}
                    $i++
                }
        } else {
            [ordered] @{ "CoManager" = "Not defined!"}
        }
        [ordered] @{ SID = $ADGroup.SID}
        [ordered] @{ GroupCategory = $ADGroup.GroupCategory}
        [ordered] @{ GroupScope = $ADGroup.GroupScope}
        [ordered] @{ DistinguishedName = $ADGroup.DistinguishedName}
        
    )


###### ORGINAL CODE EXTRACT #########

#Example with the exact same length.
$PropertyTable = @(
        [ordered] @{ Name = 'ExampleGroupName23Chars'}
        [ordered] @{ Description = 'DESC: ExampleGroupName23Chars'}
        [ordered] @{ Info = ''}
		[ordered] @{ Manager = 'Not defined!'}
        [ordered] @{ "CoManager" = "Not defined!"}
        [ordered] @{ SID = 'S-6-6-66-6666666666-6666666666-6666666666-66666'}
        [ordered] @{ GroupCategory = 'Security'}
        [ordered] @{ GroupScope = 'Global'}
        [ordered] @{ DistinguishedName = 'CN=ExampleGroupName23Chars,OU=Examp,OU=Examps,OU=Exam,DC=EXA,DC=EXAMP'}
        
    )

New-PDF {


    New-PDFPage -PageSize A4 -MarginLeft 20 -MarginRight 20 -MarginTop 20 -MarginBottom 20 {
            New-PDFText -Text 'XXXX XXXXX XXXXXX' -FontBold $true
            New-PDFText -Text 'XXXX XXXXXX XXXXXX XXXX XXXXXXXXXXX (XXXXXXXX, XXXXXXXX) XX XXXXXX (XXXXXXXXXXXXXXXX XXXXXX, XXXXXXXXXX, XXX.) XXXXXXXXXXXXXXXX. XX XXXXXX XXXXXX XXXXXXXXXXXXXXXXXXX / XXXX XXXXXX XXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXX. XXXXXX XXXXXX XXXX XXXXXXX XXXXXX XXXXXXXXXX XXXXXX XXX XXXXXXXXXXXXXX XX XXXXXXX XXXXXX. XXX XXXXXXXXX XXXXXXX XXXXXXX XX XXXXXX XXXXXXXX'
            New-PDFText -Text 'XXXXXXX XXX XXXXXXXXXXXXXXX' -FontBold $true
            New-PDFText -Text 'XXX XXXXXXXXXXXXXXXXXXXX XXX XXXXXX XXXX XXXXX XXX XXXXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXX XX XXXXXXXXXX. XXXXXXXXXX XXXXXXXXXX XXX XXXXXXXXXXXXXX XXX/XXXX XXXXXXXXXXXXXXXXXXXXXX XXXX XXX XX-XXXXXXXXXXXXXX XXX. XXX XXXXXXXXXXX.'
            New-PDFText -Text 'XXXXXXXXXXXXX XXX XXXX XXXXX' -FontBold $true
            New-PDFTable -DataTable $PropertyTable
        }


} -FilePath $env:temp\EXAMPLE1.pdf


#normally this example is within the page boarders, but the anonymised one is not.. DOnt know why....
$PropertyTable = @(
        [ordered] @{ Name = 'ExampleGroupName18'}
        [ordered] @{ Description = 'DESC: ExampleGroupName18'}
        [ordered] @{ Info = ''}
		[ordered] @{ Manager = 'Not defined!'}
        [ordered] @{ "CoManager" = "Not defined!"}
        [ordered] @{ SID = 'S-6-6-66-6666666666-6666666666-6666666666-66666'}
        [ordered] @{ GroupCategory = 'Security'}
        [ordered] @{ GroupScope = 'Global'}
        [ordered] @{ DistinguishedName = 'CN=ExampleGroupName18,OU=Examp,OU=Examps,OU=Exam,DC=EXA,DC=EXAMP'}
        
    )

New-PDF {


    New-PDFPage -PageSize A4 -MarginLeft 20 -MarginRight 20 -MarginTop 20 -MarginBottom 20 {
            New-PDFText -Text 'XXXX XXXXX XXXXXX' -FontBold $true
            New-PDFText -Text 'XXXX XXXXXX XXXXXX XXXX XXXXXXXXXXX (XXXXXXXX, XXXXXXXX) XX XXXXXX (XXXXXXXXXXXXXXXX XXXXXX, XXXXXXXXXX, XXX.) XXXXXXXXXXXXXXXX. XX XXXXXX XXXXXX XXXXXXXXXXXXXXXXXXX / XXXX XXXXXX XXXXXXXXXXXXXXX XXXXXXXXXX XXXXXXXXXX. XXXXXX XXXXXX XXXX XXXXXXX XXXXXX XXXXXXXXXX XXXXXX XXX XXXXXXXXXXXXXX XX XXXXXXX XXXXXX. XXX XXXXXXXXX XXXXXXX XXXXXXX XX XXXXXX XXXXXXXX'
            New-PDFText -Text 'XXXXXXX XXX XXXXXXXXXXXXXXX' -FontBold $true
            New-PDFText -Text 'XXX XXXXXXXXXXXXXXXXXXXX XXX XXXXXX XXXX XXXXX XXX XXXXXXXXXXXXXXXX XXX XXXXXXXXXXXXXXX XX XXXXXXXXXX. XXXXXXXXXX XXXXXXXXXX XXX XXXXXXXXXXXXXX XXX/XXXX XXXXXXXXXXXXXXXXXXXXXX XXXX XXX XX-XXXXXXXXXXXXXX XXX. XXX XXXXXXXXXXX.'
            New-PDFText -Text 'XXXXXXXXXXXXX XXX XXXX XXXXX' -FontBold $true
            New-PDFTable -DataTable $PropertyTable
        }


} -FilePath $env:temp\EXAMPLE2.pdf

@PrzemyslawKlys
Copy link
Member

I've edited your content - see what I did and use it for future. I don't need everything. Just some reproduction code.

@Greyland99
Copy link
Author

hi i have noticed that breaks occur with spaces and minus (-), maybe there is a connection.

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

2 participants