Jump to content

[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

 

 

Link to comment
https://forums.phpfreaks.com/topic/138489-solved-print-to-pdf-dynamic-file-name/
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..

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.