Page break, for printing.

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Page break, for printing.

Post by penguinboy »

This isn't necessarily a problem with php... :)
Well, I'm taking output from a database and forcing the user to download it as a word.doc, so they can print it without the header and footer from the browser.
But the problem is... the query is saved as one file
(its quicker than saving 100 files :) )
And I need page breaks for ever new record....
Inserting page breaks manually is not an option, but I've yet to find any way to make a page break.

So if anyone can help I'd appreciate it.

-thank, pb
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

This isn't necessarily a problem with php...
right, therefor it's moved to Miscellaneous
How do you create the word-document? (MS-Word?)
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

The code is written in php.

Code: Select all

<?php
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Content-Disposition:attachment;filename=report.doc");
header("Content-Description: OnlineOK Generated Data");
header("Content-Type/Content-Disposition:application/msword");


$x=0;
while($x<=$_POST[var_count])
{
$sql = mysql_query("SELECT * blah blah blah ") or die (mysql_error());
$row=mysql_fetch_array($sql);
echo " $allthetext";
<<<<I need a page break right here.>>>>
$x++;
}
?>
[/quote]
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

So you're writing a plain text file only marked as msword-doc by the content-header.
try chr(12) as form feed character

btw: I had to install a converter (from the office cd) before word imported my test document.
penguinboy
Forum Contributor
Posts: 171
Joined: Thu Nov 07, 2002 11:25 am

Post by penguinboy »

Thank you.
That is exactly what I needed.
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

This same function only in HTML is:

Code: Select all

<div style="page-break-before: always">contentofpage</div>
Post Reply