Create PDF and Reader Open Parameters

14 posts by 4 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 4, 2011   (RSS)

Hi all,

This is actually a 2 part question relating to the createPDF plugin.

BACKGROUND
I had been adding some additional parameters to code in the "the output_as_inline_pdf" example to preset the PDF reader window when it opens.

In the head:
<?php if (@$_REQUEST['pdf']) { createPDF_fromOutput('inline', 'example.pdf'); } ?>

and in the body:

<?php if (@$_REQUEST['pdf']): ?>&nbsp;<?php else: ?><a href="http://my_site.com/about.php?pdf=1&<?php echo $my_tableRecord['num'] ?>#toolbar=1&navpanes=1&scrollbar=1&zoom=100">CLICK TO CONVERT THIS PAGE TO A PDF</a><?php endif ?>

I now need to create a PDF from a page that has a black background and white type. (about.php)

Here’s what my approach has been so far (it works but it seems a bit klugey):

1) Create a page with a white background and black type. (about3.php)

2) Create an interim page (about2.php) using the code from the url_as_inline example in the head to convert the white background page to a PDF
<?php
$url = "http://www.my_site.com/about3.php";
$data = createPDF_fromUrl($url);
createPDF_display('inline', $data, 'example.pdf');
?>


3) link to about2.php from about.php
<a href="about2.php">CLICK TO CONVERT THIS PAGE TO A PDF</a>

THE QUESTIONS
1) How would I add the reader parameters to the code in step 2 above? Everything that I’ve tried gave me php errors before I ever uploaded the page.

2) Is there a more elegant approach to accomplish the entire process?

Thanks,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Create PDF and Reader Open Parameters

By Jason - March 25, 2011

Hi Jerry,

Just to clarify what you're trying to do. You have a page that displays with a black background with white text. You want to convert this into a pdf that uses a white background with black text.

Is that right? Let me know and I can send you some steps to try.

Thanks
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] Create PDF and Reader Open Parameters

Hi jason,

Thanks for the reply.

I'm already accomplishing the steps you outlined, but I can't figure out how to pass reader parameters along.

My two questions are...

1) how can I pass the properties to the PDF reader as I was doing in the example above,

2) Is there a more elegant way to accomplish the whole task...

IE:convert to white BG, Black text, pass the parameters to the reader that make it open dependably at 100%

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Create PDF and Reader Open Parameters

By Jason - March 28, 2011

Hi Jerry,

I've never worked with the parameters you're showing. Could you provide us with a link that shows these parameters working? Could you also provide us with a link to your current page so we can see what's happening on your page vs a working example?

If you don't want to post links in the forum, you can email them to support@interactivetools.com

Hope this helps
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [gkornbluth] Create PDF and Reader Open Parameters

By Damon - March 29, 2011

Hi Jerry,

I'm getting inconsistent results. I might vary from browser to browser and also with what version of Acrobat is installed?

Also, I tried changing the zoom variable to 200 in the URL and reloading with no effect:
http://50.6.159.105/about.php?pdf=1&1#toolbar=1&navpanes=1&scrollbar=1&zoom=200

But I was able to change the zoom to 200 here and it worked:
http://www.elleschorrphotography.com/exhibitions2.php?pdf=1&1#toolbar=1&navpanes=1&scrollbar=1&zoom=200

Can you just add the parameters you want to the PDF link?
That seems like it should work.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] Create PDF and Reader Open Parameters

Damon,

Thanks for your suggestion but I’m more lost than ever.

As I mentioned in the first post in this thread, I can get the added parameters to set the opening style of the reader in the output_as_inline_pdf implementation by simply appending them to the createPDF call. The problem comes in with the url_as_inline_pdf code.

Based on your suggestion, I thought that I could create a field called pdf_parameters, use that in a variable ($addon, and append that variable to the url that’s created. The test value I used for pdf_parameters was #toolbar=1&navpanes=1&scrollbar=1&zoom=185, expecting that on success, the reader would open at 185% zoom.

I tried changing the original url_as_inline_pdf createPDF call:

<?php
$url = "http://www.elleschorrphotography.com/exhibitions3.php";
$data = createPDF_fromUrl($url);
createPDF_display('inline', $data, 'example.pdf');
?>


To this:

<?php
$url = "http://www.elleschorrphotography.com/exhibitions3.php"; ?>
<?php $addon = $common_informationRecord['pdf_parameters'] ;
$data = createPDF_fromUrl($url);
createPDF_display('inline',$data . $addon, 'example.pdf');
?>


That didn’t work, so also tried this:

<?php
$url = "http://www.elleschorrphotography.com/exhibitions3.php"; ?>
<?php $addon = $common_informationRecord['pdf_parameters'] ;
$data = createPDF_fromUrl($url);
createPDF_display('inline',$data, 'example.pdf . $addon');
?>


And this:

<?php
$url = "http://www.elleschorrphotography.com/exhibitions3.php"; ?>
<?php $addon = $common_informationRecord['pdf_parameters'] ;
$data = createPDF_fromUrl($url . $addon);
createPDF_display('inline',$data, 'example.pdf');
?>


Since in each case when the PDF was created the zoom was never set to 185, and I don’t know how to show the URL that’s actually being passed to the plugin, I’m lost as to how to proceed.

Any help would be appreciated.

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [gkornbluth] Create PDF and Reader Open Parameters

By robin - March 30, 2011

Hey Jerry,

I think you were closest with the 2nd last example. Here is a suggested change:
<?php
$url = "http://www.elleschorrphotography.com/exhibitions3.php"; ?>
<?php $addon = $common_informationRecord['pdf_parameters'] ;
$data = createPDF_fromUrl($url);
createPDF_display('inline',$data, 'example.pdf' . $addon);
?>


Damon and I were testing with pdf parameters and as he said it is inconsistent between browsers, but hopefully you have some success with the above change.

Good luck!
Robin
Robin
Programmer
interactivetools.com

Re: [robin] Create PDF and Reader Open Parameters

Thanks guys,

I'll give it a try.

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

Re: [robin] Create PDF and Reader Open Parameters

By gkornbluth - March 30, 2011 - edited: March 31, 2011

Thanks Damon and Robin,

I must be doing something wrong, because no matter what I put into the pdf_parameter field (even gibberish) it has no effect on the resulting PDF.

I'm guessing that nothing is actually being appended to the URL passed to the createPDF plugin, but I don't know how to test what the actual value of the url + $addon is.

Any suggestions how to test the actual URL+?

BTW, I'm no longer using a proxy server. One less possible complication.

Thanks,

Jerry
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php