Closed OwenMeany57 closed 4 years ago
I have no clue why it wasn't working. I simply rebuilt PSWritePDF and it … works.
Published new version. Give it a try please. Added tests for this case and it seems to work.
It appears to work now. Thank you!
This solved the null array issue, thank you. But it seems to have introduced a new issue with bolding text.
The code: New-PDFText -Text ‘Title1’, $value1 -Font HELVETICA -FontColor BLACK -FontBold $true, $false produces a PDF with the title bolded and the value not bolded, as expected.
However, the code: New-PDFText -Text ‘Title1’, $value1, ‘Title2’, $value2 -Font HELVETICA -FontColor BLACK -FontBold $true, $false, $true, $false produces a PDF with no bolding at all.
It seems that once bold is toggled on and off, it prevents bold from working for that entire line. This feature worked fine in previous versions.
Do you want me to file a bug ticket?
Thanks!
From: Przemysław Kłys notifications@github.com Sent: Saturday, August 1, 2020 3:28 PM To: EvotecIT/PSWritePDF PSWritePDF@noreply.github.com Cc: OwenMeany57 wbender780@gmail.com; Author author@noreply.github.com Subject: Re: [EvotecIT/PSWritePDF] Null array error when data table contains only one element (#10)
Published new version. Give it a try please. Added tests for this case and it seems to work.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/PSWritePDF/issues/10#issuecomment-667576689 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPBLUOCXU5T4IY7VKCHGF3R6RUDDANCNFSM4PRYJ6EQ . https://github.com/notifications/beacon/AQPBLUKGWJSVWKQGRGHLK2DR6RUDDA5CNFSM4PRYJ6E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOE7FGS4I.gif
-- This email has been checked for viruses by AVG. https://www.avg.com
As always ;-) Best with reproduction code :-) It's weird that it happens when I have not touched original code. Maybe updates to iText library broke it.
I did a clean reinstall of the module and the problem persists.
I was able to create a workaround for the null array issue by adding a blank first element to the single-element arrays, which kept my script from breaking. I don’t think there’s a workaround for this one, though. I’ll keep v.0.0.8 running in production with my workaround in place.
From: Przemysław Kłys notifications@github.com Sent: Monday, August 3, 2020 11:18 AM To: EvotecIT/PSWritePDF PSWritePDF@noreply.github.com Cc: OwenMeany57 wbender780@gmail.com; Author author@noreply.github.com Subject: Re: [EvotecIT/PSWritePDF] Null array error when data table contains only one element (#10)
As always ;-) Best with reproduction code :-) It's weird that it happens when I have not touched original code. Maybe updates to iText library broke it.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/PSWritePDF/issues/10#issuecomment-668080696 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPBLUJNQJADFUIK4VJAP5DR63ILRANCNFSM4PRYJ6EQ . https://github.com/notifications/beacon/AQPBLUMVIJ2EZBOAMZPDGUTR63ILRA5CNFSM4PRYJ6E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOE7JBUOA.gif
-- This email has been checked for viruses by AVG. https://www.avg.com
If you can send me sample code to reroduce it, ill fix it.
Here you go. Thank you!!
$path = "C:\Test\TestPDF.pdf"
$value1 = 'This bolding example works.'
$value2 = 'The second bolding example breaks them both.'
New-PDF -MarginLeft 20 -MarginRight 20 -MarginTop 20 -MarginBottom 20 {
New-PDFPage -PageSize A4 {
New-PDFText -Text 'The goal is to have the titles bolded and the values in normal font:' -Font HELVETICA -FontColor BLACK
New-PDFText -Text 'Title: ', $value1 -Font HELVETICA -FontColor BLACK -FontBold $true, $false
New-PDFText -Text "But with more than one toggle, the bolding doesn't work at all:" -Font HELVETICA -FontColor BLACK
New-PDFText -Text 'Title: ', $value1, ' Title2: ', $value2 -Font HELVETICA -FontColor BLACK -FontBold $true, $false, $true, $false
New-PDFText -Text "This worked in previous versions." -Font HELVETICA -FontColor BLACK
}
} -FilePath $path -Show
From: Przemysław Kłys notifications@github.com Sent: Monday, August 3, 2020 11:54 AM To: EvotecIT/PSWritePDF PSWritePDF@noreply.github.com Cc: OwenMeany57 wbender780@gmail.com; Author author@noreply.github.com Subject: Re: [EvotecIT/PSWritePDF] Null array error when data table contains only one element (#10)
If you can send me sample code to reroduce it, ill fix it.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/PSWritePDF/issues/10#issuecomment-668099897 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPBLUL4N3M7V6IT754GCCLR63MQVANCNFSM4PRYJ6EQ . https://github.com/notifications/beacon/AQPBLUJRWAOG7TVV2DVXGE3R63MQVA5CNFSM4PRYJ6E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOE7JGKOI.gif
-- This email has been checked for viruses by AVG. https://www.avg.com
I've found the issue. It's coming from my function Remove-EmptyValue.
Never knew that empty string compared to boolean false will give $true
$false -eq ''
Updated module. Should work now. Sorry for that.
Added a lot of tests for that: https://github.com/EvotecIT/PSSharedGoods/blob/master/Tests/Remove-EmptyValue.Tests.ps1
Yep, that seems to have fixed it. Thank you so much!
I like your little project. I look forward to additional enhancements.
Wayne Bender
11450 Mears Drive
Zionsville, IN 46077-9819
From: Przemysław Kłys notifications@github.com Sent: Monday, August 3, 2020 1:36 PM To: EvotecIT/PSWritePDF PSWritePDF@noreply.github.com Cc: OwenMeany57 wbender780@gmail.com; Author author@noreply.github.com Subject: Re: [EvotecIT/PSWritePDF] Null array error when data table contains only one element (#10)
I've found the issue. It's coming from my function Remove-EmptyValue.
Never knew that empty string compared to boolean false will give $true
$false -eq ''
Updated module. Should work now. Sorry for that.
Added a lot of tests for that: https://github.com/EvotecIT/PSSharedGoods/blob/master/Tests/Remove-EmptyValue.Tests.ps1
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EvotecIT/PSWritePDF/issues/10#issuecomment-668149700 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPBLUNVZ4WEVT7O44PB3CTR63YRPANCNFSM4PRYJ6EQ . https://github.com/notifications/beacon/AQPBLUKJSR3MSMVCIZYCSFTR63YRPA5CNFSM4PRYJ6E2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOE7JSPRA.gif
-- This email has been checked for viruses by AVG. https://www.avg.com
Since v.0.0.8, when using New-PDFTable, a null array error is thrown if the -DataTable array contains only one element:
Cannot index into a null array. At C:\Program Files\WindowsPowerShell\Modules\PSWritePDF\0.0.8\PSWritePDF.psm1:343 char:9
Using "New-PDFTable -DataTable $Data", the input array was: $Data = @( [PSCustomObject] @{ Test = 'Name'; Test2 = 'Name2'; Test3 = 'Name3' } )
If at least one more element is added to this input array, a PDF will be generated as expected. This error did not occur prior to version 0.0.8.