I have several Jasper reports with deprecated properties (pdfFontName
, pdfEncoding
and isPdfEmbedded
) which cause the warning "PDF Font is deprecated and replaced by the Font Extension".
As there are many files to be corrected (maybe more than a thousand of them), I'm trying to come up with a script that automatically removes those properties and their values from the source code of the files (replaces the string in question with the empty string).
For example:
The following line of code of one of a file's source code:
<font fontName="Courier New" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="cour.ttf"/>
Would become:
<font fontName="Courier New" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" />
I already tried to ran this script on Windows Powershell:
Get-ChildItem "pathToFile" -Recurse | ForEach-Object {
(Get-Content $_.FullName).Replace('pdfFontName="\w+"','') | Set-Content $_.FullName
}
The property wasn't removed with this so I tried to replace the regular expression with the actual property value like this:
Get-ChildItem "pathToFile" -Recurse | ForEach-Object {
(Get-Content $_.FullName).Replace('pdfFontName="Helvetica"','') | Set-Content $_.FullName
}
It worked. For this reason, I think the problem has to do with the regular expression. I tried other regex but none of them worked. Can you help me correct this?