This article describes how to install Phoca PDF component in Joomla! 3.3 and later version.

 

In Joomla! 2.5 or 3.x the PDF feature is not more available. If you want to create PDF documents from your articles, you should install Phoca PDF component and Phoca PDF Content plugin. However, it's not as easy as it looks. Joomla! core does not include links to PDF in article views and there is no efficient event which allows you to insert PDF link through some plugin. It means, some of core Joomla! content files needs to be edited.

 

Download

Download Phoca PDF component from the Phoca PDF download site. You get a ZIP file.

Install

Login into your Joomla! administration site and follow these steps:

Go to Extension Manager (Extensions - Extension Manager - Install). You can:

  • Upload Package File - select the Phoca PDF component ZIP file from your disc and click onUpload File & Install.
  • Install from Directory - you can upload Phoca PDF component ZIP file into your server directory and install it from this directory
  • Install from URL - you can install it from another URL.


1) Install the component.

 

2) Component itself does not produce PDFs, so for creating PDF document from article, you need to install Phoca PDF content plugin. Install it the same way like you have installed the component. After installation, go to Plugin Manager and enable this plugin so it will be active.

 

3) We have installed Phoca PDF component and Phoca PDF content plugin. Now Joomla! can produce PDF documents from articles. But we need one more little thing - a link to PDF. Unfortunately, articles are a part of Joomla! core and it does not include such links, so we need to create them, there are two options which are possible to do:

 

3a) Installing Phoca PDF system plugin (be aware Phoca PDF system plugin is not Phoca PDF content plugin). Phoca PDF system plugin tries to find a place where Joomla! places all other icons (Print, Email) and then it tries to add the PDF icon (PDF link) there. Such feature has a lot limitations:

  • It works only with standard templates which does not override Joomla! output
  • It can affect other parts of Joomla! output (e.g. remove some other parts of html code from the output)
  • It works only in Article view (not in Featured or Category view)

What is the advantage of such solution? In case you want to display PDF icon only in article view and your template output has standard format, then you don't need to modify the content files (see below) every time you will upgrade your Joomla!.

 

3b) Using system plugin will not work on most sites, so the only one solution is to modify the content files (and of course they should be modified after every Joomla! update) :-(

 

Customizing Joomla! core content files:

 

Edit the following file (if your template overrides Joomla! content files, you need to edit this file in your template's folder):

layouts/joomla/content/icons.php (in your template, it should be: templates/your_template/html/layouts/com_content/icons.php)

line cca 10

FROM:

<?php 
defined('JPATH_BASE') or die;

$canEdit = $displayData['params']->get('access-edit');

?>

<div class="icons">
	<?php if (empty($displayData['print'])) : ?>

		<?php if ($canEdit || $displayData['params']->get('show_print_icon') || $displayData['params']->get('show_email_icon')) : ?>
			<div class="btn-group pull-right">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
				<?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
				<ul class="dropdown-menu">
					<?php if ($displayData['params']->get('show_print_icon')) : ?>
						<li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
					<?php if ($displayData['params']->get('show_email_icon')) : ?>
						<li class="email-icon"> <?php echo JHtml::_('icon.email', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
					<?php if ($canEdit) : ?>
						<li class="edit-icon"> <?php echo JHtml::_('icon.edit', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
				</ul>
			</div>
		<?php endif; ?>

	<?php else : ?>

		<div class="pull-right">
			<?php echo JHtml::_('icon.print_screen', $displayData['item'], $displayData['params']); ?>
		</div>

	<?php endif; ?>
</div>

TO:

<?php 
defined('JPATH_BASE') or die;

$canEdit = $displayData['params']->get('access-edit');
$phocaPDF = false;
if (JPluginHelper::isEnabled('phocapdf', 'content')) {
	include_once(JPATH_ADMINISTRATOR.'/components/com_phocapdf/helpers/phocapdf.php');
	$phocaPDF = PhocaPDFHelper::getPhocaPDFContentIcon($displayData['item'], $displayData['params']);
} 
?>

<div class="icons">
	<?php if (empty($displayData['print'])) : ?>

		<?php if ($canEdit || $displayData['params']->get('show_print_icon') || $displayData['params']->get('show_email_icon') || $phocaPDF) : ?>
			<div class="btn-group pull-right">
				<a class="btn dropdown-toggle" data-toggle="dropdown" href="#"> <span class="icon-cog"></span> <span class="caret"></span> </a>
				<?php // Note the actions class is deprecated. Use dropdown-menu instead. ?>
				<ul class="dropdown-menu">
					<?php if ($displayData['params']->get('show_print_icon')) : ?>
						<li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
					<?php if ($displayData['params']->get('show_email_icon')) : ?>
						<li class="email-icon"> <?php echo JHtml::_('icon.email', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
					<?php if ($canEdit) : ?>
						<li class="edit-icon"> <?php echo JHtml::_('icon.edit', $displayData['item'], $displayData['params']); ?> </li>
					<?php endif; ?>
					<?php echo $phocaPDF; ?>
				</ul>
			</div>
		<?php endif; ?>

	<?php else : ?>

		<div class="pull-right">
			<?php echo JHtml::_('icon.print_screen', $displayData['item'], $displayData['params']); ?>
		</div>

	<?php endif; ?>
</div>

 

Be aware, some of templates override content files, it means, the files to display content (article) are not used from com_content area but from template area. Then the template file needs to be overriden.

 

Using Joomla! cache system plugin

If Joomla! cache system plugin is enabled on your site, don't set PDF Destination parameter to value: Inline Browser in Phoca PDF Content Plugin parameters. Use Inline Browser (Popup) instead (which is default). Cache system plugin does not create correct cache file if Inline Browser parameter is set.