Jump to content

Archived

This topic is now archived and is closed to further replies.

aiyou

[SOLVED] Print to PDF - Dynamic File Name

Recommended Posts

Hello.

 

I'm a newby to PHP, but manage to follow existing code pretty well.  So, I'm not a developer, but can muddle my way through things.  Here's what I would like to accomplish:

 

I have an OSCommerce site, and I'm looking to streamline some functionality.  I have packing slips and invoices which I typically print.  However, on occassion, I generate a PDF for emailing.  I would like to have a a unique filename generated, so I don't have to manually rename the page during the Print To PDF dialog.

 

Something like: PackingSlipOrderNo-YYYYDDMM (current date).pdf

 

I'm using CutePDF, and this defaults to the TITLE value.

 

Thanks in advance.

--Rob

 

 

Share this post


Link to post
Share on other sites

CutePDF is not a PHP application. It's not actually a web application from what I see. It seems to be a Windows app, that installs as additional printer and allows users to 'print' PDF files.

Share this post


Link to post
Share on other sites

Thanks...I was thinking that this might have beens something that was inherited from the page itself, and therefore something that I could modify.  I'll pose the same question out on a CuteFTP forum, and see if they have any suggestions.

Share this post


Link to post
Share on other sites

Does it take TITLE value, as in page title (the one that is displayed in your browser's title bar)? If so, then yes, you could affect it.

Share this post


Link to post
Share on other sites

I've tried modifying Title (i.e. MySite) so that it displays something like MySitePackingSlip0001.  That value now displays on the browser, but when I select File-->Print, and select the CutePDF printer, it defaults to a file name of just MySite. 

 

I was hoping that it was just another attribute in the page that wasn't being set..

Share this post


Link to post
Share on other sites

This might be something along these lines. Check for other places in your HTML where MySite is present. Trial and error... maybe will give you results.

Share this post


Link to post
Share on other sites

With a bit more playground time, i found an answer...

 

The print to file name was indeed coming from the Title value.  However, my Title included the ".com" extension.  So, while I was passing in MySite.comPackingSlip, the value populated in the filename dialog box only up to the point of the decimal/period.

 

I would like to clean up my code a bit, so that it is more dynamic for others, but for now, the following works with a bit of hardcoding

 

<title>MySitePackingSlip<?php echo (int)$oID; ?></title>

 

Thanks for taking the time to provide some feedback, as it ended up sending me in a workable direction....just needed someone to bounce it against, I guess...

 

--Rob

Share this post


Link to post
Share on other sites

Good work. Glad I could poke you in general direction ;)

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.