PDF not only text, but also graphics/pictures

Locked
hansvdhoeven
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Nov 04, 2005 1:02 pm

PDF not only text, but also graphics/pictures

Post by hansvdhoeven » Fri Nov 04, 2005 2:56 pm

Hi developers!

First of all: thanks for the good work with Joomla! I myself am not an IT-specialist, so I'm glad that you have made Joomla! work so well (and easy).

I'm a newbie, but have already a topic for the wishlist:

Can you provide a tool under the PDF-buttons of Joomla! that not only converts the text of the webpage to PDF-format, but also the graphics and pictures? That would be a very nice option.

Thanks.
Regards,

Hans
The Netherlands

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3788
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Hackwar » Fri Nov 04, 2005 4:26 pm

Since this is not trivial and the whole PDF-export-function does not quite meet the high quality standards of the dev-team, there were serious discussions about removing pdf-export completely from Joomla. I don't know if there was some progress, but the export with images is a very hard thing to do, as you can see with many other tools that fail to export PDF in a standard-compliant way. Last thing I heard, they wanted to remove the function till a better php-pdf-export-api is available.
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6536
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Jinx » Fri Nov 04, 2005 4:28 pm

That is indeed correct, back in the Mambo days we decided to remove the PDF functionality for the reasons explained by Hackware. At this time we haven't reopened the discussion for Joomla! 1.1.
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
jwr
Joomla! Guru
Joomla! Guru
Posts: 543
Joined: Thu Aug 18, 2005 5:54 pm
Location: Sliedrecht, the Netherlands

Re: PDF not only text, but also graphics/pictures

Post by jwr » Fri Nov 04, 2005 7:10 pm

Well, I would appreciate, if the PDF-discussion was reopened.

As a practical user too, I'd like to mention the following example.
A company using a Joomla-intranet is creating its "product specifications" using groupware (eg. widombo),
and there is a group of editors maintaining these specs.
In order to send them to a client/prospect/etc, the usual practice is to send out a PDF of these "specs"
by the sales dept, who are not necesary the editors.
(PDF's are datetime-stamped, and no infringements with editors are possible)
It would be nice, to send out a PDF created by the intranet.

See it, as another nice, attractive (, and in businesses welcomed ) edge of the CMS, if you want.

2 eurocents,

Jan Willem

It is already possible to create PDFs with images using fpdf & fpdfhack (search if you want)
Looking for J! help ? Paste your (English preferred) errormessage in the searchbar !

hansvdhoeven
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Fri Nov 04, 2005 1:02 pm

Re: PDF not only text, but also graphics/pictures

Post by hansvdhoeven » Fri Nov 04, 2005 7:12 pm

But I've seen that Open Office has quite a well functioning PDF-export. Since Open Office is also Open Source, can it maybe be adopted into Joomla. Maybe a stupid suggestion, but I don't have any technical background [as you will have noticed  ;-)].

Please reconsider the present view on this matter.

Thanks,

Hans

User avatar
Hackwar
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 3788
Joined: Fri Sep 16, 2005 8:41 pm
Location: NRW - Germany
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Hackwar » Fri Nov 04, 2005 7:58 pm

OpenOffice is written in C (I think) and Joomla in php... And you have to take into calculation that Joomla has to be able to service hundreds of calls at the same time and can't use as much CPU-power for PDF creating like Open Office probably does. You need an extremely lightweight pdf API and the devs haven't sound one yet that suits there needs.
I don't know the performance of FPDF, the features sound interesting, but as they write on their homepage the performance is less than PDFlib. Probably it could be used to create a static PDF thats stored as a file in some folder, probably together with the new virtual filesystem that came out of the google code summer? By the way, any news about that? Didn't hear anything lately about it... (Or probably just read the wrong sub-forum ;) )
god doesn't play dice with the universe. not after that drunken night with the devil where he lost classical mechanics in a game of craps.

Since the creation of the Internet, the Earth's rotation has been fueled, primarily, by the collective spinning of English teachers in their graves.

User avatar
gsbe
Joomla! Guru
Joomla! Guru
Posts: 871
Joined: Wed Aug 17, 2005 10:13 pm
Location: Lexington, VA
Contact:

Re: PDF not only text, but also graphics/pictures

Post by gsbe » Tue Dec 13, 2005 6:45 am

I have some experience with FDF systems. Perhaps I could assist. Had a similar suggestion back in Feb '05 here:
http://gigcalendar.net: the world's first free solution for maintaining a touring calendar for Joomla!

User avatar
PhilTaylor-Prazgod
Joomla! Ace
Joomla! Ace
Posts: 1230
Joined: Sat Aug 20, 2005 12:32 pm
Location: Jersey, Channel Islands
Contact:

Re: PDF not only text, but also graphics/pictures

Post by PhilTaylor-Prazgod » Tue Dec 13, 2005 6:54 am

I am the guy that put PDF generation in Core Mambo, and the guy that announced it was being withdrawn.

The automatic generation of PDFs with images style and layouts is a difficult process using just PHP.  There is a product caled HTMLDoc that you can install on a server (if you have full admin/root rights) that allows a certain about of style/graphics to be added, although the finished result is not exactly like te HTML Page.

Once HTMLDoc is integrated you will need a new pdf.php in Joomla - I used to have one for Mambo but I cant find it right now.

Phil.
Phil Taylor
Founder, Lead Developer
- https://mySites.guru - Manage Multiple Joomla/WordPress Sites In One Dashboard for Security, Audits, Backups and more....
- https://www.phil-taylor.com/ - My Twitter Streams

User avatar
PhilTaylor-Prazgod
Joomla! Ace
Joomla! Ace
Posts: 1230
Joined: Sat Aug 20, 2005 12:32 pm
Location: Jersey, Channel Islands
Contact:

Re: PDF not only text, but also graphics/pictures

Post by PhilTaylor-Prazgod » Tue Dec 13, 2005 7:01 am

I found my old pdf.php from Mambo 4.5.1

The following code is GPL GNU Code from Mambo 4.5.1 Package.
It is provided here AS IS

Code: Select all

<?php
/**
* @version $Id: pdf.php,v 1.10 2004/08/31 11:20:41 eddieajau Exp $
* @package Mambo_4.5.1
* @copyright (C) 2000 - 2004 Miro International Pty Ltd
* @copyright (C) 2004 Blue Flame IT Ltd - www.blueflameit.ltd.uk
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
* Created by Phil Taylor me@phil-taylor.com
* Support file to display PDF Text Only using class from - http://www.ros.co.nz/pdf/readme.pdf
* HTMLDoc is available from: http://www.easysw.com/htmldoc and needs installing on the server for better HTML to PDF conversion
**/

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global $mosConfig_offset, $mosConfig_hideAuthor, $mosConfig_hideModifyDate, $mosConfig_hideCreateDate, $mosConfig_live_site;

$safe = '0';
if ( get_php_setting('safe_mode') == 'ON' ) {
	$safe = '1';
}

if ( $safe == '0' ) {
	if ( @file_exists( '/usr/bin/htmldoc' ) ) {
		$id = intval( mosGetParam( $_REQUEST, 'id', 1 ) );
		$article = $mosConfig_live_site . '/index2.php?option=com_content&task=view&pop=1&page=0&hide_js=1&pdf=1&id=' . $id;
		header( 'Content-Type: application/pdf' );
		header( 'Content-Disposition: inline; filename="pdf-mambo.pdf"' );
		flush();
		//following line for Linux only - windows may need the path as well...
		passthru( '/usr/bin/htmldoc --no-localfiles --no-compression -t pdf14 --jpeg --webpage --header t.D --footer ./. --size letter --left 0.5in "'. $article .'"' );
	} else {
		dofreePDF ( $database );
	}
} else {
	dofreePDF ( $database );
}

function dofreePDF ( $database ) {
	global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate;

	$id = intval( mosGetParam( $_REQUEST, 'id', 1 ) );
	include( 'includes/class.ezpdf.php' );
	$row = new mosContent( $database );
	$row->load( $id );
	//Find Author Name
	$users_rows = new mosUser( $database );
	$users_rows->load( $row->created_by );
	$row->author = $users_rows->name;
	$row->usertype = $users_rows->usertype;

	// Ugly but needed to get rid of all the stuff the PDF class cant handle
	$row->fulltext 	= str_replace( '<p>', "\n\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<P>', "\n\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<br />', "\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<br>', "\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<BR />', "\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<BR>', "\n" , $row->fulltext );
	$row->fulltext 	= str_replace( '<li>', "\n - " , $row->fulltext );
	$row->fulltext 	= str_replace( '<LI>', "\n - " , $row->fulltext );
	$row->fulltext 	= strip_tags( $row->fulltext );
	$row->fulltext 	= str_replace( '{mosimage}', '', $row->fulltext );
	$row->fulltext 	= str_replace( '{mospagebreak}', '', $row->fulltext );
	$row->fulltext 	= decodeHTML( $row->fulltext );

	$row->introtext 	= str_replace( '<p>', "\n\n", $row->introtext );
	$row->introtext 	= str_replace( '<P>', "\n\n", $row->introtext );
	$row->introtext 	= str_replace( '<li>', "\n - " , $row->introtext );
	$row->introtext 	= str_replace( '<LI>', "\n - " , $row->introtext );
	$row->introtext 	= strip_tags( $row->introtext );
	$row->introtext 	= str_replace( '{mosimage}', '', $row->introtext );
	$row->introtext 	= str_replace( '{mospagebreak}', '', $row->introtext );
	$row->introtext 	= decodeHTML( $row->introtext );

	$pdf =& new Cezpdf( 'a4', 'P' );  //A4 Portrait
	$pdf -> ezSetCmMargins( 2, 1.5, 1, 1);
	$pdf->selectFont( './fonts/Helvetica.afm' ); //choose font

	$all = $pdf->openObject();
	$pdf->saveState();
	$pdf->setStrokeColor( 0, 0, 0, 1 );

	// footer
	$pdf->line( 10, 40, 578, 40 );
	$pdf->line( 10, 822, 578, 822 );
	$pdf->addText( 30, 34, 6, $mosConfig_live_site .' - '. $mosConfig_sitename );
	$pdf->addText( 250, 34, 6, 'Powered by Mambo' );
	$pdf->addText( 450, 34, 6, 'Generated: '. date( 'j F, Y, H:i', time() + $mosConfig_offset*60*60 ) );

	$pdf->restoreState();
	$pdf->closeObject();
	$pdf->addObject( $all, 'all' );
	$pdf->ezSetDy( 30 );

	$txt1 = $row->title;
	$pdf->ezText( $txt1, 14 );

	$txt2 = NULL;
	$mod_date = NULL; 
	$create_date = NULL;
	if ( intval( $row->modified ) <> 0 ) {
		$mod_date = mosFormatDate( $row->modified );
	}
	if ( intval( $row->created ) <> 0 ) {
		$create_date = mosFormatDate( $row->created );
	}

	if ( $mosConfig_hideCreateDate == '0' ) {
		$txt2 .= '('. $create_date .') - ';
	}

	if ( $mosConfig_hideAuthor == "0" ) {
		if ( $row->author != '' && $mosConfig_hideAuthor == '0' ) {
			if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') {
				$txt2 .=  _WRITTEN_BY .' '. ( $row->created_by_alias ? $row->created_by_alias : $row->author );
			} else {
				$txt2 .=  _AUTHOR_BY .' '. ( $row->created_by_alias ? $row->created_by_alias : $row->author );
			}
		}
	}

	if ( $mosConfig_hideModifyDate == "0" ) {
		$txt2 .= ' - '. _LAST_UPDATED .' ('. $mod_date .') ';
	}

	$txt2 .= "\n\n";
	$pdf->ezText( $txt2, 8 );
	$txt3 = $row->introtext ."\n". $row->fulltext;
	$pdf->ezText( $txt3, 10 );
	$pdf->ezStream();
}

function decodeHTML( $string ) {
	$string = strtr( $string, array_flip(get_html_translation_table( HTML_ENTITIES ) ) );
	$string = preg_replace( "/&#([0-9]+);/me", "chr('\\1')", $string );
	return $string;
}

function get_php_setting ($val ) {
	$r = ( ini_get( $val ) == '1' ? 1 : 0 );
	return $r ? 'ON' : 'OFF';
}
?>



Phil Taylor
Founder, Lead Developer
- https://mySites.guru - Manage Multiple Joomla/WordPress Sites In One Dashboard for Security, Audits, Backups and more....
- https://www.phil-taylor.com/ - My Twitter Streams

User avatar
PhilTaylor-Prazgod
Joomla! Ace
Joomla! Ace
Posts: 1230
Joined: Sat Aug 20, 2005 12:32 pm
Location: Jersey, Channel Islands
Contact:

Re: PDF not only text, but also graphics/pictures

Post by PhilTaylor-Prazgod » Tue Dec 13, 2005 7:13 am

Phil Taylor
Founder, Lead Developer
- https://mySites.guru - Manage Multiple Joomla/WordPress Sites In One Dashboard for Security, Audits, Backups and more....
- https://www.phil-taylor.com/ - My Twitter Streams

User avatar
gsbe
Joomla! Guru
Joomla! Guru
Posts: 871
Joined: Wed Aug 17, 2005 10:13 pm
Location: Lexington, VA
Contact:

Re: PDF not only text, but also graphics/pictures

Post by gsbe » Tue Dec 13, 2005 7:26 am

Here is an excellent possibility for a free HTML to PDF converter that includes support for stylesheets: [quote="readme"]HTML_ToPDF
Version 3.3
http://www.rustyparts.com/pdf.php

What is HTML_ToPDF?
-------------------


HTML_ToPDF is a PHP class that makes it easy to convert HTML documents to PDF
files on the fly.  HTML_ToPDF grew out of the need to convert HTML files (which
are easy to create) to PDF files (which are not so easy to create) fast and
easily.  It has the following features:

* The ability to convert images in the webpage to images embedded in the PDF.
  The script tries to convert relative image paths in to absolute ones as well.

* The ability to use the CSS in the HTML file in the creation of the PDF.  This
  includes remote CSS files as well.

* The ability to convert remote files

* The ability to convert links into embedded clickable links in the PDF file.

* The ability to scale the HTML page.

* Easy setting of any of these options through the methods of the class.

* Tries to fix quirks in html pages which break html2ps.

* PEAR error handling.

* Works on both Unix/Linux and Windows.

What is PDFEncryptor?
---------------------


PDFEncryptor is a helper class that comes with this package.  It is also a
wrapper for a couple of free java libraries that allow you to digitally sign
and protect the PDFs you create by adding a password, permissions (such as
printing and copying rights), and meta-data such as the Keywords and Author.

Obtaining HTML_ToPDF
--------------------


Further information on HTML_ToPDF and the latest version can be obtained at

  http://www.rustyparts.com/pdf.php

Installation
------------


There is no real installation other than requiring the file.  See the
examples directory for help in how to use the class.  However, you do need to
make sure that whatever directory the PDF files are going to be created in is
writable by the user the webserver runs as.

Included Files
--------------


The following files are available in the HTML_ToPDF distribution:

README                - This file
CHANGES              - The list of changes
examples/            - Several example files to aid you on your way
docs/                - Class documentation (in HTML)
lib/                  - Where some of the encryption libraries live

Common Problems
---------------


* No files are created.
    - Likely the problem is due to a lack of permissions.  Either the tmp
      directory that HTML_ToPDF uses for intermediary files is not writable by
      the webserver or the output directory for the PDF file is not writable by
      the webserver.  Possible fixes are:
      // Change the tmp directory
      $pdf->setTmpDir('/somewhere/writable');
      // Change the directory permissions
      bash# chmod 777 www/pdfs; chown apache www/pdfs

* It complains of not being able to include PEAR.php.
    - This is because HTML_ToPDF uses PEAR for error handling.  You can
      download PEAR from http://pear.php.net/&nbsp; If you cannot get your hands on
      PEAR you can comment out all the places where an error is raised.

* The images don't show up.
    - Often the program getting the images (i.e. curl) is having a problem.
      These errors can usually be seen if the program is run from the command
      line.

* ps2pdf fails with error code 127
    - See http://www.rustyparts.com/phpBB/viewtopic.php?p=601#601

Requirements
------------


* PHP: Version 4.0.4 or greater (http://www.php.net).

* html2ps: Does the initial conversion of html to a postscript file, and
  thus is the most crucial part of the conversion.  More information
  about it is here: http://www.tdb.uu.se/~jan/html2ps.html You will
  especially want to read the user's guide here:
  http://www.tdb.uu.se/~jan/html2psug.html if this script is not making
  the pdf look like you want.  If running windows you will need to install
  activeperl as well.

* ps2pdf: This comes with the Ghostscript package, and can be found
  here: http://www.cs.wisc.edu/~ghost/ This package is normally
  installed as an RPM on RedHat systems, so if you're using that OS you
  shouldn't have to worry.  There is a windows install for this as well.

* curl: Or some program that grabs documents off the web (lynx, w3m,
  etc.).  HOWEVER, for whatever reason only curl has worked in my tests
  when the script page is running as a web script and not just a script
  from the command line.  Curl can be found here: http://curl.haxx.se/

* PEAR: The default installation of PEAR is needed for the error
  handling and OS checking.  PEAR comes with the default installation of
  PHP 4 so you should normally not have to worry.  Installation instructions
  can be found here: http://pear.php.net/manual/en/installation.php

* Valid HTML: Good HTML (XHTML is best) definitely helps.

* PDFEncryptor needs java (http://java.sun.com) and the iText jar file
  (http://itext.sourceforge.net/downloads/)

License
-------

Both HTML_ToPDF.php and PDFEncryptor are under version 3 of the PHP license.

Credits
-------

Thanks to Jack Utano (http://tnloghomes.com) for funding development of ver. 3.0
[/quote]
Last edited by gsbe on Tue Dec 13, 2005 7:39 am, edited 1 time in total.
http://gigcalendar.net: the world's first free solution for maintaining a touring calendar for Joomla!

User avatar
maxa
Joomla! Guru
Joomla! Guru
Posts: 557
Joined: Sat Aug 27, 2005 11:07 am
Location: Sweden
Contact:

Re: PDF not only text, but also graphics/pictures

Post by maxa » Thu Feb 09, 2006 1:12 am

VirtueMart produces pdf's with images. How is that done?

User avatar
maxa
Joomla! Guru
Joomla! Guru
Posts: 557
Joined: Sat Aug 27, 2005 11:07 am
Location: Sweden
Contact:

Re: PDF not only text, but also graphics/pictures

Post by maxa » Thu Feb 09, 2006 1:20 am

jwr wrote: It is already possible to create PDFs with images using fpdf & fpdfhack (search if you want)
I searched, but did not find it...

User avatar
jwr
Joomla! Guru
Joomla! Guru
Posts: 543
Joined: Thu Aug 18, 2005 5:54 pm
Location: Sliedrecht, the Netherlands

Re: PDF not only text, but also graphics/pictures

Post by jwr » Thu Feb 09, 2006 10:06 pm

the "former name' forum will help you out there  ;)
Looking for J! help ? Paste your (English preferred) errormessage in the searchbar !

User avatar
Relax
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Mon Dec 26, 2005 8:52 pm
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Relax » Sun Feb 19, 2006 3:36 pm

Hey Phil Taylor,

u seem to know alot about, PDF printing. Using Joomla1.7 and need to generate pdf#s which uses the css parameter of the web page. So far ur suggestion using html2pdf, right?
But I dont have root access and cant setup all the Programms needed.  How can I then reach efford?

Is there an Work arround, Manipulation of the pdf.php to use Webseit css?


THANKS and Relax

"We are collecting mor Knowledge - calling it learning. Happiely we can through away that again, otherwise our brain couldn't compete with the gravity."

User avatar
Jinx
Joomla! Champion
Joomla! Champion
Posts: 6536
Joined: Fri Aug 12, 2005 12:47 am
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Jinx » Mon Feb 20, 2006 5:15 pm

Hi guys,

Just wanted to throw in that the new pdf library in J! 1.1 is able to generate images and is fully UTF-8 compilant, meaning that it also supports different fontsets for non latin languages.

Johan
Johan Janssens - Joomla Co-Founder, Lead Developer of Joomla 1.5

http://www.joomlatools.com - Joomla extensions that just work

User avatar
Relax
Joomla! Apprentice
Joomla! Apprentice
Posts: 11
Joined: Mon Dec 26, 2005 8:52 pm
Contact:

Re: PDF not only text, but also graphics/pictures

Post by Relax » Mon Feb 20, 2006 5:33 pm

Nice and what is about css support?

mihai007
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jun 28, 2006 9:35 pm

Re: PDF not only text, but also graphics/pictures

Post by mihai007 » Thu Jun 29, 2006 6:54 am

Jinx wrote: Hi guys,

Just wanted to throw in that the new pdf library in J! 1.1 is able to generate images and is fully UTF-8 compliant, meaning that it also supports different fontsets for non Latin languages.

Johan
Hi there..! I have installed 1.1 and the pdf images still do not work: I can see it works in VirtueMart but not with the joomla normal content. What can be done to fix this problem?

User avatar
Tonie
Joomla! Master
Joomla! Master
Posts: 16556
Joined: Thu Aug 18, 2005 7:13 am

Re: PDF not only text, but also graphics/pictures

Post by Tonie » Thu Jun 29, 2006 7:32 am

Have you installed 1.1 Alpha? This version is an old developer version of last february. Since then the naming changed to 1.5. This version is still in development, and it is not recommended to build production websites with it as of yet. The latest nightlies can be obtained from dev.joomla.org.


Locked

Return to “Wishlist Archives - Archived”