Wrapping text around images and managing image captions

Phoca PDF - creating PDF documents in Joomla! CMS
cwdee
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 01 Aug 2013, 18:17

Wrapping text around images and managing image captions

Post by cwdee »

Hi

I am trying to use PhocaPDF to allow certain articles from my site to be downloaded as a PDF. As a basic function it works, but I am having two problems with the layout.

1) The text is not wrapped around the image as it is in th eHTML. Is that even possible? If so how do I make PhocaPDF do that?

2) The image captions are rendered inline with all the other text. The HTML structure for captioned images is created with JCE-caption like:

Code: Select all

<span class="wf_caption" ... >
<img src="..." />
<span>CAPTION TEXT</span>
</span>
Is there anyway to influence how the caption text is presented in the PDF (or even suppress it from the PDF)?

Thanks, Chris
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrapping text around images and managing image captions

Post by Jan »

Hi,

1) see the red warning box:
https://www.phoca.cz/phocapdf
HTML is dynamic document, PDF is static document, not every dynamic features can be transformed to PDF :-(

2) I think, that only way is to somehow customize the TCPDF library, which is a library which creates the PDF (tries to transform HTML to PDF)
:idea:

Jan
If you find Phoca extensions useful, please support the project
cwdee
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 01 Aug 2013, 18:17

Re: Wrapping text around images and managing image captions

Post by cwdee »

Thanks. Where exactly in the PhocaPDF code is the article content passed to TCPDF? Maybe there I could catch the image caption and remove orreformat. Maybe wrapping the image and its caption in a table might work.

Thanks, Chris
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrapping text around images and managing image captions

Post by Jan »

Hi, not sure if I understand?
Where exactly in the PhocaPDF code is the article content passed to TCPDF?
Phoca PDF sends the HTML output into the TCPDF class which then tries to transform the html to the fixed design in PDF :idea:

Jan
If you find Phoca extensions useful, please support the project
cwdee
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 01 Aug 2013, 18:17

Re: Wrapping text around images and managing image captions

Post by cwdee »

Yes, which piece of PhocaPDF code does this? I assume I can manipulate the HTML before it is sent.

Thanks, Chris
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48041
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: Wrapping text around images and managing image captions

Post by Jan »

Hi, then see the plugin for content:

Phoca PDF Content plugin:
plugins/phocapdf/content.php and see the $documentOutput variable.

Jan
If you find Phoca extensions useful, please support the project
cwdee
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 01 Aug 2013, 18:17

Re: Wrapping text around images and managing image captions

Post by cwdee »

Thanks, that really helped.

I have improved the rendering substantially by including the following, to wrap the image in a paragraph and wrap and style the immediately following span element :

Code: Select all

// Style JCE captions
$pattern = '/(<img.*>)\s?(<span.*>.*<\/span>)/';
$replacement = '<p>$1</p><p style="font-size: 0.75em;"><i>$2</i></p>';
$documentOutput = preg_replace($pattern, $replacement, $documentOutput);
It is probably not bomb-proof but produces a better PDF than without.

Ideally JCE Caption would tag the inserted span, maybe with a unique class, so that it can be detected.

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

Re: Wrapping text around images and managing image captions

Post by Jan »

Hi, thank you for the guide.

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