Forum Moderators: coopster

Message Too Old, No Replies

Displaying a pdf

         

calmseas

9:49 pm on Apr 18, 2011 (gmt 0)

10+ Year Member



Simple question; but I'm puzzled. Object is to display a given newsletter (january_11.pdf)
whose month and year is specified by the user in a form from drop down combo boxes.

$year = $_POST[ 'year' ] ;
$month = $_POST[ 'month' ] ;
$issue = $month + $year ;

Once the specific $issue has been defined, how can the pdf be automatically displayed
without clicking on another link? This should be obvious to me; but I just don't see it.

Matthew1980

7:02 am on Apr 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there calmseas,

At a guess I would say use header to forewarn the browser about what you intend to be outputting, and the way your joining the values is wrong: $issue = $month." ".$year; The way you were doing it was literally adding it up - thankfully default type from post is string, so *possibly* could have wobbled together.

There are loads of PDF creation classes out there; just use header(); to tell the browser that you intend to output a PDF.

Cheers,
MRb

calmseas

4:19 pm on Apr 19, 2011 (gmt 0)

10+ Year Member



Hi Matthew!

I'm afraid my question is so dumb, I'm having trouble relating it, so let me try again.
The file january_11.pdf already exists in a website folder. I can output the file by having the user click on a link like <a href="january_11.pdf">January 2011</a>.
But now the particular issue is parameterized by the variable $issue. In this case, how do I output the file without having the user click on a link? I hope this makes more sense. BTW, thanks for pointing out my syntax error.

rocknbil

5:45 pm on Apr 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like he said, by example:

header("Location:/foldername/january_11.pdf");

Matthew1980

8:02 pm on Apr 19, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Like he said, by example:

header("Location:/foldername/january_11.pdf");


Then as this page is being parsed, just weave in the variables so that it is done on-the-fly.

so long as the content type is defined, and then output to the browser this should looke 'natural' - from this guess as your trying to include variables IN the PDF as it is being parsed ;)

Cheers,
MRb

rocknbil

6:15 pm on Apr 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No I think just the file name . . . .

$pdfdir = 'foldername';
$year = $_POST[ 'year' ] ;
$month = $_POST[ 'month' ] ;
$issue = $month . '_' . $year . '.pdf';

header("Location:/$pdfdir/$issue");

Matthew1980

7:15 pm on Apr 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>>No I think just the file name . . . .

Ahh, sorry my bad.

Cheers,
MRb