<![CDATA[ PDF export - MODX Community Forums]]> https://forums.modx.com/thread/?thread=24611 <![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=4#dis-post-125965
Haven’ t worked with html2pdf ... but did work with fpdf (http://www.fpdf.de/) (one part of html2(f)pdf) ... and ufpdf (http://acko.net/node/56) ...ufpdf is based on fpdf but does unicode a lot better ... the rest is the same so here is the documentation : http://www.fpdf.org/en/doc/index.php

I used getdocumentvariables and then the functions of ufpdf to generate the pdf rather than convert HTML ...

I will look into the ’sanitize’ included in html2pdf because from time to time i ran into PDF’s with empty pages (due to some error)]]>
bartnelis Aug 03, 2010, 04:03 AM https://forums.modx.com/thread/24611/pdf-export?page=4#dis-post-125965
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125964 laugh

Quote from: http://wiki.modxcms.com/index.php/API:getDocumentObject
Retrieves a Document from the database. Document permissions are verified.
mrhaw Aug 03, 2010, 03:34 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125964
<![CDATA[html2pdf SECURE version(!)]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125963 I solved it with utf8_decode() have you tried that?
$pagetitle = utf8_decode($goGet['pagetitle']); 

As for security I changed getValue to $modx->getDocumentObject()
and some more tricks:
Replace images with (image)
and whats inside of <!--NOPDF--> ... <!--NOPDF--> with (video) in my case

My snippet inside MODx:
if(isset($_GET['makepdf'])) {
    $makepdf = $modx->documentObject['id'];
    require_once($modx->config['base_path'] .'myfolder/html2pdf/html2fpdf.php');
    require_once($modx->config['base_path'] .'myfolder/html2pdf/sanitize.php');

    $goGet = $modx->getDocumentObject('id',$makepdf);
    $pagetitle = utf8_decode($goGet['pagetitle']);    
    $introtext = utf8_decode($goGet['introtext']);
    $content = utf8_decode($goGet['content']);
    $content2 = preg_replace("/<img[^>]+\>/i", "(image)", $content);
    $content3 = preg_replace('#<!--NOPDF-->[^>]*>.*?<!--NOPDF-->#si', '(video)', $content2);

    $pdf=new HTML2FPDF();
    $strContent = '
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>'.$pagetitle.' | My Site Name</title>
<strong>'.$pagetitle.' | My Site Name | '.$introtext.'</strong><br /><br /> 

    $pdf_title = sanitize_paranoid_string($pagetitle) . '.pdf';
    //echo "PDF file is generated successfully!";
    header('Pragma: public');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Content-Type: application/pdf');
    header('Content-Disposition: attachment; filename="'.$pagetitle.'.pdf"');
else {

after $strContent = it should be a: ’
$strContent = '

I can’t see it there?¿]]>
mrhaw Aug 03, 2010, 02:29 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125963
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125962 huh

it`s !mportant]]>
lastoftheromans Jul 21, 2009, 05:11 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125962
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125961 Quote from: mrhaw at Jul 17, 2009, 02:21 AM

@Kristalin: Did you change the xml and html header in create_pdf.php?

actually yes,
i try:

<?xml version="1.0" encoding="UTF-8"?>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

no results and then try with windows 1251 -cyrillic encoding - same results.

another attempt is for "fonts" in create_pdf header i put:

this font i upload in FONT folder in my custom/html2pdf.
for this comic.php i follow this steps:

in an interesting manner is when i use FPDF ALONE (no modx, no another scripts...direct input content) is work fine.


lastoftheromans Jul 17, 2009, 12:05 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125961
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125960 http://svn.modxcms.com/docs/display/MODx096/Document+Object (Me like)

@Dimmy: It reads protected pages... In my case I have no "protected content" in content field so
it doesn’t matter if anyone was fishing, but it would be nice to get this fixed!

@Kristalin: Did you change the xml and html header in create_pdf.php?
mrhaw Jul 16, 2009, 09:21 PM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125960
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125959 Quote from: mrhaw at Jul 16, 2009, 07:57 AM

@estring: Thank you!!!! Instead of using the CurrentDoc snippet [*id*] can do it!
<a href="custom/html2pdf/create_pdf.php?docid=[*id*]">Save as PDF</a>

I searched all over the place to find out how to get the id of the current document. I don’t know how I didn’t find [*id*].
Thanks a bunch.]]>
estring Jul 16, 2009, 09:19 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125959
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125958

you now jobs is great!
Question of Questions is cyrillic...
Can anybody help me?

My BD is:
Database Charset: utf8
Database Collation Charset: utf8_general_ci]]>
lastoftheromans Jul 16, 2009, 08:09 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125958
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125957

kongondo Jul 16, 2009, 07:37 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125957
<![CDATA[Re: PDF export]]> https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125956 Dimmy Jul 16, 2009, 07:14 AM https://forums.modx.com/thread/24611/pdf-export?page=3#dis-post-125956