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

Can't display Pagenumber in Footer with custom Font #187

Closed
WinkiG opened this issue Sep 23, 2021 · 2 comments
Closed

Can't display Pagenumber in Footer with custom Font #187

WinkiG opened this issue Sep 23, 2021 · 2 comments
Assignees
Labels

Comments

@WinkiG
Copy link

WinkiG commented Sep 23, 2021

I'm using the Custom-Font Arial in my document
the Font displayes correctly in the whole document except the Footer.

heres the relevant part of my ts

pdfpage = PAGE
pdfpage.typeNum = 28032014

pdfpage.config {
		disableAllHeaderCode = 1
		xhtml_cleaning = 0
		admPanel = 0
		debug = 0
		disablePrefixComment = 1
}

pdfpage.20 = COA
pdfpage.20  {
     15 < tt_content.list.20.eventpdf_eventpdf
}
	plugin.eventpdf {
		view {
			templateRootPaths >
			templateRootPaths {
				0 = EXT:eventpdf/Resources/Private/Templates/
			}
		}
	}
.....
	plugin.tx_pdfviewhelpers.settings.generalText.fontFamily = arial
	plugin.tx_pdfviewhelpers.settings {
		config.fonts {
			addTTFFont {
					arial {
							path = EXT:eventpdf/Resources/Public/Fonts/arial.ttf		
....

text.types.footer {
color = #888
fontSize = 14
fontFamily = arial
}

and my html of the footer:

	<pdf:footer>
			<pdf:text type="footer">Seite {pdf:getPageNumberAlias()} von {pdf:getTotalNumberOfPagesAlias()}</pdf:text>
	</pdf:footer>

heres the output:
grafik

this happens only when i include the Viewhelpers in the footer. normal text ist displayed correctly. and the viewhelpers are also working correctly when used anywhere else...

TYPO3 version(s): 10.4.20
pdfviewhelpers version: 2.3.5

@maechler
Copy link
Member

maechler commented Sep 24, 2021

@WinkiG Thanks for your bug report! I had a look at the issue and I can easily reproduce this with a simple example:

<pdf:document>
    <pdf:page>
        <pdf:text fontFamily="roboto">{pdf:getPageNumberAlias()}</pdf:text>
    </pdf:page>
</pdf:document>

It seems to be an issue with the order in which we do the rendering in the AbstractTextViewHelper.php and is not directly related to the footer. When I move the call $this->getPDF()->SetFont to the beginning of the method (just before $this->renderChildren()), the problem is solved for my example. If we set the font after $this->renderChildren() it seems to create the page number alias with the wrong font.

Can you try to apply the following patch and test whether that works for you?

diff --git a/Classes/ViewHelpers/AbstractTextViewHelper.php b/Classes/ViewHelpers/AbstractTextViewHelper.php
index a91ceb7..cb72d7f 100755
--- a/Classes/ViewHelpers/AbstractTextViewHelper.php
+++ b/Classes/ViewHelpers/AbstractTextViewHelper.php
@@ -98,6 +98,10 @@ abstract class AbstractTextViewHelper extends AbstractContentElementViewHelper
 
         $this->mergeSettingsAndArguments();
 
+        if ($this->validationService->validateFontFamily($this->arguments['fontFamily'])) {
+            $this->getPDF()->SetFont($this->arguments['fontFamily'], $this->conversionService->convertSpeakingFontStyleToTcpdfFontStyle($this->arguments['fontStyle']));
+        }
+
         if (empty($this->arguments['text'])) {
             $this->arguments['text'] = $this->renderChildren();
         }
@@ -126,10 +130,6 @@ abstract class AbstractTextViewHelper extends AbstractContentElementViewHelper
             $this->getPDF()->SetFontSize($this->arguments['fontSize']);
         }
 
-        if ($this->validationService->validateFontFamily($this->arguments['fontFamily'])) {
-            $this->getPDF()->SetFont($this->arguments['fontFamily'], $this->conversionService->convertSpeakingFontStyleToTcpdfFontStyle($this->arguments['fontStyle']));
-        }
-
         if ($this->validationService->validateLineHeight($this->arguments['lineHeight'])) {
             $this->getPDF()->setCellHeightRatio($this->arguments['lineHeight']);
         }

However I will have to further investigate the issue to find out whether that is already the proper solution.

@WinkiG
Copy link
Author

WinkiG commented Sep 27, 2021

@maechler thanks for the fast reply.
yep applying that fix solves my problem.

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

No branches or pull requests

2 participants