[FX.php List] [off] Anyone familiar w/ mPDF who could help?

Bob Patin bob at patin.com
Fri Jan 13 14:04:53 MST 2012


Well, what's odd is that their example works fine, and it's just a long string of HTML then this

include("../mpdf.php");
$mpdf=new mPDF(); 
$mpdf->WriteHTML($html);
$mpdf->Output();
exit;

Mine is basically the same, except that at top I have code that grabs the records for each report and saves the variables for use in the HTML below.

The only difference may be that mine is going into a DIV using jQuery, while their example's a standalone PHP page not inside my jQuery. The more I think about it, the more I think that may be what is causing the difference…

That being the case, would I need to call those header() commands at the top of my mPDF calls, or at least, beore the Output() call?


Bob Patin
Longterm Solutions LLC
bob at longtermsolutions.com
615-333-6858
http://www.longtermsolutions.com
FileMaker 9, 10 & 11 Certified Developer
Member of FileMaker Business Alliance and FileMaker TechNet
--
Twitter: bobpatin
Google+: http://www.longtermsolutions.com/plus
AIM: longterm1954
iChat: bobpatin
--
Expert FileMaker Consulting 
FileMaker Hosting for all versions of FileMaker

On Jan 13, 2012, at 2:59 PM, Leo R. Lundgren wrote:

> So your PDF contents is in $html (i.e. that variable holds only the PDF contents and no actual HTML)? If so, just echo/print that instead of readfile($filename).
> 
> $filename is whatever you want the file to be named, but beware that it should contain basic ASCII chars, so I'd recommend you keep it to a-z, A-Z, _ and - and no spaces. You can skip the basename() and just put a string there.
> 
> You can get the size of the contents by using strlen($html). so replace $documentFilesize with that.
> 
> 
> 13 jan 2012 kl. 21.55 skrev Bob Patin:
> 
>> Leo,
>> 
>> Thanks for the pointers; what you're saying makes complete sense.
>> 
>> In my case I'm generating a variable called $html, so there's no file to speak of. That being the case, where would I get the values for $filename and $documentFilesize?
>> 
>> Just for grins I added just hte first header line but that didn't get it yet…
>> 
>> Thanks for the help!
>> 
>> Bob
>> 
>> 
>> Bob Patin
>> Longterm Solutions LLC
>> bob at longtermsolutions.com
>> 615-333-6858
>> http://www.longtermsolutions.com
>> FileMaker 9, 10 & 11 Certified Developer
>> Member of FileMaker Business Alliance and FileMaker TechNet
>> --
>> Twitter: bobpatin
>> Google+: http://www.longtermsolutions.com/plus
>> AIM: longterm1954
>> iChat: bobpatin
>> --
>> Expert FileMaker Consulting 
>> FileMaker Hosting for all versions of FileMaker
>> 
>> On Jan 13, 2012, at 2:47 PM, Leo R. Lundgren wrote:
>> 
>>> Yeah, it's exactly what is going on.
>>> 
>>> I haven't seen their code and not yours either, so I can't say how they differ, I just know you need to output some HTTP headers to instruct the client to download the file instead of showing the source of it.
>>> 
>>> Try doing this to output the file to the client:
>>> 
>>> header('Content-type: application/pdf');
>>> header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
>>> header('Content-Length: ' . $documentFilesize);
>>> header('Content-Transfer-Encoding: binary');
>>> readfile($filename);  // Or whatever is appropriate in your case
>>> 
>>> I believe this should allow the client to view the file if that's the default behavior, while if you change the "application/pdf" up there to "application/octet-stream" instead, the client should download the file instead of opening it. Disclaimer; It's been a while since I did this, but that's what I recall. The rationale is that with the latter the client doesn't know it's a PDF, hence doesn't know how to open it, and should therefore download the file.
>>> 
>>> 
>>> 13 jan 2012 kl. 21.34 skrev Bob Patin:
>>> 
>>>> Well, that does describe what it's doing, but with their examples you *do* see the output in your browser.
>>>> 
>>>> Check out this:
>>>> 
>>>> http://ga.longtermsolutions.com/examples/example01_basic.php
>>>> 
>>>> Now, go to this site and login using test/test:
>>>> 
>>>> http://ga.longtermsolutions.com
>>>> 
>>>> click on TEST RESULTS, click SELECT ALL, then click PRINT SELECTED RESULTS.
>>>> 
>>>> You'll see it immediately… :)
>>>> 
>>>> Thanks for any help…
>>>> 
>>>> Bob Patin
>>>> Longterm Solutions LLC
>>>> bob at longtermsolutions.com
>>>> 615-333-6858
>>>> http://www.longtermsolutions.com
>>>> FileMaker 9, 10 & 11 Certified Developer
>>>> Member of FileMaker Business Alliance and FileMaker TechNet
>>>> --
>>>> Twitter: bobpatin
>>>> Google+: http://www.longtermsolutions.com/plus
>>>> AIM: longterm1954
>>>> iChat: bobpatin
>>>> --
>>>> Expert FileMaker Consulting 
>>>> FileMaker Hosting for all versions of FileMaker
>>>> 
>>>> On Jan 13, 2012, at 2:25 PM, Leo R. Lundgren wrote:
>>>> 
>>>>> Just off the top of my head; Could the problem be that you have your generated PDF content, and want to give it to the client, but instead of "getting a file" they see the PDF output right in the browser? A sign of that could be if the junk characters start with "PDF" in the first characters.
>>>>> 
>>>>> 13 jan 2012 kl. 21.23 skrev Bob Patin:
>>>>> 
>>>>>> I'm trying to use mPDF for the first time; my tests work fine, but when I try to render my actual page, I get trash characters.
>>>>>> 
>>>>>> If anyone has experience using it and wants to earn some $$ helping me out, please let me know.
>>>>>> 
>>>>>> Thanks,
>>>>>> 
>>>>>> Bob Patin
>>>>>> Longterm Solutions LLC
>>>>>> bob at longtermsolutions.com
>>>>>> 615-333-6858
>>>>>> http://www.longtermsolutions.com
>>>>>> FileMaker 9, 10 & 11 Certified Developer
>>>>>> Member of FileMaker Business Alliance and FileMaker TechNet
>>>>>> --
>>>>>> Twitter: bobpatin
>>>>>> Google+: http://www.longtermsolutions.com/plus
>>>>>> AIM: longterm1954
>>>>>> iChat: bobpatin
>>>>>> --
>>>>>> Expert FileMaker Consulting 
>>>>>> FileMaker Hosting for all versions of FileMaker
>>>>>> 
>>>>>> _______________________________________________
>>>>>> FX.php_List mailing list
>>>>>> FX.php_List at mail.iviking.org
>>>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>> 
>>>>> 
>>>>> 
>>>>> -|
>>>>> 
>>>>> _______________________________________________
>>>>> FX.php_List mailing list
>>>>> FX.php_List at mail.iviking.org
>>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>> 
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>> 
>>> 
>>> 
>>> -|
>>> 
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>> 
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20120113/ec4e61c0/attachment.html


More information about the FX.php_List mailing list