PDF not quite right

Phoca PDF - creating PDF documents in Joomla! CMS
keith@keithvb.com
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 29 May 2023, 20:00

PDF not quite right

Post 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.

Tags:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PDF not quite right

Post 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
If you find Phoca extensions useful, please support the project
keith@keithvb.com
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 29 May 2023, 20:00

Re: PDF not quite right

Post by keith@keithvb.com »

Works perfectly. Thanks for the clear instructions.

Keith
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48386
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: PDF not quite right

Post by Jan »

OK
If you find Phoca extensions useful, please support the project
Post Reply