Page 1 of 1

PDF not quite right

Posted: 29 May 2023, 20:12
by keith@keithvb.com
Thanks for creating this great J! 4 extension.

Works for most of my articles. However, the one I'm working on uses monospaced type
and the PDF removes the spaces. I'm using the monofree font.

This is the page: http://songs.keithvb.com/songs-by-write ... -and-young

This is what I started with and what I want:

A AM7 F#m A
I'll light the fire, while you place the flowers
D A D F
In the vase that you bought today.

This is what the PDF looks like:

A AM7 F#m A
I'll light the fire, while you place the flowers
D A D F
In the vase that you bought today.

Thanks, Keith.

Re: PDF not quite right

Posted: 30 May 2023, 14:47
by Jan
Hi, the HTML source for the text if following:

Code: Select all

<p>[Verse 1]<br>A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;AM7 &nbsp; &nbsp; &nbsp; &nbsp; F#m &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A<br>I'll light the fire, while you place the flowers<br>&nbsp; &nbsp; &nbsp; &nbsp;D &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; A &nbsp; &nbsp; &nbsp; &nbsp;D &nbsp; F<br>In the vase that you bought today.<br>&nbsp;A &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AM7 &nbsp; &nbsp; &nbsp;F#m &nbsp; &nbsp; &nbsp; &nbsp;A<br>Staring at the fire for hours and hours,<br>&nbsp; &nbsp; &nbsp; &nbsp; D &nbsp; &nbsp; &nbsp;A &nbsp; &nbsp; &nbsp;D &nbsp; &nbsp; &nbsp; &nbsp; E<br>While I listen to you play your love songs<br>D &nbsp; &nbsp; &nbsp; &nbsp; E &nbsp; &nbsp; &nbsp; &nbsp;A &nbsp; AM7 &nbsp; F#m &nbsp; &nbsp; &nbsp;A &nbsp; D &nbsp;F<br>All night long for me, &nbsp; &nbsp; &nbsp; only for me.</p>
The problem is, Phoca PDF gets this text without &nbsp; from Joomla system:

Image

So the only way to change it is to replace spaces in output (in plugin code) to &npsp; (but the another problem is, it can change spaces even there where we don't want to change it, e.g. in html tags:

Try to test following, open this file:
plugins/phocapdf/content/content.php

and on line cca 240 add following code:

Code: Select all

$documentOutput = str_replace('<br />', '<br/>', $documentOutput);
$documentOutput = str_replace(' ', '&nbsp;', $documentOutput);
above this code:

Code: Select all

// Build the PDF Document string from the document buffer
$pdf->writeHTML($documentOutput , true);
This should do the trick:
Image

Jan

Re: PDF not quite right

Posted: 04 Jun 2023, 19:13
by keith@keithvb.com
Works perfectly. Thanks for the clear instructions.

Keith

Re: PDF not quite right

Posted: 06 Jun 2023, 00:07
by Jan
OK