Good Morning All,

OK, so here is the deal...

I have a membership site that at some point in time (very soon) I will have an event take place that will require me to produce printed reports...

I have the scripts written to gather the information from the DB, and generate the required reports to the screen, but I now need them in printed form.

If it was just a few of them, I could do a screen capture and print them out, since this is a one time event, but there are several hundred of them...

Anyway, Is there a 'SIMPLE' way to take what is on the screen and send it to the printer, maintaining the formatting?

Thanks in advance for your responses.

Douglas

If you have a script to generate the pages, it should be easy to change it a little, so it outputs every report to a html file. Then you can just select them all and print them at once.

If you have a script to generate the pages, it should be easy to change it a little, so it outputs every report to a html file. Then you can just select them all and print them at once.

I don't understand that answer at all.

I am generating the reports to the screen, but no clue how to get them to the printer, which is why I posed the question in here.

I am saying that, since you already have a script generating reports to screen, it should be possible to modify it to generate files instead. Once you have all files, you can print them all easily.

I am saying that, since you already have a script generating reports to screen, it should be possible to modify it to generate files instead. Once you have all files, you can print them all easily.

OK, well you are saying, I think, the same thing that I am asking...

But the real question is 'How do I accomplish that'?

google tcpdf
output your reports as pdf's - then let users do what they want with them. email save whatever

But the real question is 'How do I accomplish that'?

Since you pasted it here, I guess you have a PHP script, show some relevant parts so we can make suggestions.

For saving the HTML, instead of echo, append it to a string and use file_put_contents.

@jstfsklh211: It's not for users.

I'd still prefer pdf's to html docs when trying to print

Since you pasted it here, I guess you have a PHP script, show some relevant parts so we can make suggestions.

Sorry, yes it is a PHP script...

I will past the relevant portion of the script here that creates the table that is displayed on the screen

The variable $des_mem is set prior to reaching this portion of the script. It basically just defines which member to display the information for...

// query to get member information including bank and tax settings
        $sql_mem="
            SELECT m.user, m.fname, m.lname, m.email, m.phone, r.threshold, r.tax_form, r.bank, r.status
            FROM members AS m, RVreserves AS r
            WHERE m.mem_id=$dsp_mem
            AND r.mem_id=m.mem_id
            LIMIT 1
        ";
        $result_mem=mysql_query($sql_mem);
        $res_ct=0;
        $request_mem=mysql_fetch_array($result_mem);

?>
        <table align="center" width="600" height="200" cellpadding="5" cellspacing="0" border="1">
            <tr>
                <td colspan="7" align="center" class="Bmedi">
                    <h4 class="Borange">Member Post RV Reserve Detail</h4>
                </td>
            </tr>

            <tr>
                <td align="left" class="Bmedi" colspan="4">
                    Mem ID : <?php print $dsp_mem;?><br>
                    Username : <?php print $request_mem[0];?><br>
                    Member Name : <?php print $request_mem[1]." ".$request_mem[2];?><br>
                    email : <?php print $request_mem[3];?><br>
                    phone : <?php print $request_mem[4];?><br>
                </td>

                <td align="left" class="Bmedi" colspan="3">
                    Status  (A, D, H, P) : <?php print $request_mem[8];?><br>
                    Bank Wire Info : <?php print $request_mem[7];?><br>
                    Tax Info Submitted  : <?php print $request_mem[6];?><br>
                    Threshold set at : $<?php print number_format($request_mem[5],2);?><br>
                </td>
            </tr>

            <tr>
                <td align="center" class="Bmedi">Group</td>
                <td align="center" class="Bmedi">Order#</td>
                <td align="center" class="Bmedi">Total Shares</td>
                <td align="center" class="Bmedi">Total Dinar</td>
                <td align="center" class="Bmedi">As Dinar</td>
                <td align="center" class="Bmedi">As Cash</td>
                <td align="center" class="Bmedi">USD to Wire</td>
            </tr>

<?php
            $cur_mem=$dsp_mem;
            $Tshare=0;
            $Tdinar=0;
            $AsDinar=0;
            $AsCash=0;
            $wire=0;
            $sql_mr="
                SELECT group_id, order_id, shares, as_dinar
                FROM RVreserves
                WHERE mem_id=$cur_mem
            ";
            $result_mr=mysql_query($sql_mr);
            while ($request_mr=mysql_fetch_array($result_mr)){
                $Tshare+=$request_mr[2];
                $Tdinar+=($request_mr[2]*200000);
                $AsDinar+=($request_mr[3]*200000);
                $AsCash=$Tdinar-$AsDinar;
                $wire=$AsCash*$RVrate;
?>
                <tr>
                    <td align="center" class="Bmedi"><?php print $request_mr[0];?></td>
                    <td align="center" class="Bmedi"><?php print $request_mr[1];?></td>
                    <td align="right" class="Bmedi"><?php print number_format($request_mr[2],0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format(($request_mr[2]*200000),0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format(($request_mr[3]*200000),0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format((($request_mr[2]-$request_mr[3])*200000),0);?></td>
                    <td align="right" class="Bmedi">$<?php print number_format((($request_mr[2]-$request_mr[3])*200000)*$RVrate,2);?></td>
    </tr>

<?php
            }
?>
                <tr>
                    <td align="right" class="Bmedi" colspan="2">Totals</td>
                    <td align="right" class="Bmedi"><?php print number_format($Tshare,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($Tdinar,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($AsDinar,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($AsCash,0);?></td>
                    <td align="right" class="Bmedi">$<?php print number_format($wire,2);?></td>
                </tr>
            </table>

<?php

}

Just remembered, if you use a tool like wget you can let it do the saving for you. You just need to make a script that handles all the url's you need.

Otherwise, you'd need to append the output to a string, as previously stated, but seeing your code, it would be A LOT of work, or make a script calling this one (but that's like building your own wget).

require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');

$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle('page title' . (date("F j Y")));
$pdf->SetSubject("");
$pdf->SetKeywords("");

// set default header data
$pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING . '                                         ' . date('F j Y'));

// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);

//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

//set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);

//set some language-dependent strings
$pdf->setLanguageArray($l);

// ---------------------------------------------------------
// set default font subsetting mode
//$pdf->setFontSubsetting(true);
// Set font
// dejavusans is a UTF-8 Unicode font, if you only need to
// print standard ASCII chars, you can use core fonts like
// helvetica or times to reduce file size.
$pdf->SetFont('helvetica', '', 12);
$pdf->SetPrintHeader(false);
//$pdf->SetPrintFooter(false);
$pdf->SetMargins(PDF_MARGIN_LEFT, 15, PDF_MARGIN_RIGHT);
$pdf->setImageScale(1.75);
$pdf->SetFontSize(10);
$pdf->AddPage('P');//L for landscape P for portrait
ob_start();

// query to get member information including bank and tax settings
        $sql_mem="
            SELECT m.user, m.fname, m.lname, m.email, m.phone, r.threshold, r.tax_form, r.bank, r.status
            FROM members AS m, RVreserves AS r
            WHERE m.mem_id=$dsp_mem
            AND r.mem_id=m.mem_id
            LIMIT 1
        ";
        $result_mem=mysql_query($sql_mem);
        $res_ct=0;
        $request_mem=mysql_fetch_array($result_mem);

?>
        <table align="center" width="600" height="200" cellpadding="5" cellspacing="0" border="1">
            <tr>
                <td colspan="7" align="center" class="Bmedi">
                    <h4 class="Borange">Member Post RV Reserve Detail</h4>
                </td>
            </tr>

            <tr>
                <td align="left" class="Bmedi" colspan="4">
                    Mem ID : <?php print $dsp_mem;?><br>
                    Username : <?php print $request_mem[0];?><br>
                    Member Name : <?php print $request_mem[1]." ".$request_mem[2];?><br>
                    email : <?php print $request_mem[3];?><br>
                    phone : <?php print $request_mem[4];?><br>
                </td>

                <td align="left" class="Bmedi" colspan="3">
                    Status  (A, D, H, P) : <?php print $request_mem[8];?><br>
                    Bank Wire Info : <?php print $request_mem[7];?><br>
                    Tax Info Submitted  : <?php print $request_mem[6];?><br>
                    Threshold set at : $<?php print number_format($request_mem[5],2);?><br>
                </td>
            </tr>

            <tr>
                <td align="center" class="Bmedi">Group</td>
                <td align="center" class="Bmedi">Order#</td>
                <td align="center" class="Bmedi">Total Shares</td>
                <td align="center" class="Bmedi">Total Dinar</td>
                <td align="center" class="Bmedi">As Dinar</td>
                <td align="center" class="Bmedi">As Cash</td>
                <td align="center" class="Bmedi">USD to Wire</td>
            </tr>

<?php
            $cur_mem=$dsp_mem;
            $Tshare=0;
            $Tdinar=0;
            $AsDinar=0;
            $AsCash=0;
            $wire=0;
            $sql_mr="
                SELECT group_id, order_id, shares, as_dinar
                FROM RVreserves
                WHERE mem_id=$cur_mem
            ";
            $result_mr=mysql_query($sql_mr);
            while ($request_mr=mysql_fetch_array($result_mr)){
                $Tshare+=$request_mr[2];
                $Tdinar+=($request_mr[2]*200000);
                $AsDinar+=($request_mr[3]*200000);
                $AsCash=$Tdinar-$AsDinar;
                $wire=$AsCash*$RVrate;
?>
                <tr>
                    <td align="center" class="Bmedi"><?php print $request_mr[0];?></td>
                    <td align="center" class="Bmedi"><?php print $request_mr[1];?></td>
                    <td align="right" class="Bmedi"><?php print number_format($request_mr[2],0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format(($request_mr[2]*200000),0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format(($request_mr[3]*200000),0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format((($request_mr[2]-$request_mr[3])*200000),0);?></td>
                    <td align="right" class="Bmedi">$<?php print number_format((($request_mr[2]-$request_mr[3])*200000)*$RVrate,2);?></td>
    </tr>

<?php
            }
?>
                <tr>
                    <td align="right" class="Bmedi" colspan="2">Totals</td>
                    <td align="right" class="Bmedi"><?php print number_format($Tshare,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($Tdinar,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($AsDinar,0);?></td>
                    <td align="right" class="Bmedi"><?php print number_format($AsCash,0);?></td>
                    <td align="right" class="Bmedi">$<?php print number_format($wire,2);?></td>
                </tr>
            </table>

<?php

}

$html = ob_get_contents();
ob_end_clean();
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output('pdf name' . (date("m_d_Y")) . '.pdf', 'I');
?>

google tcpdf
output your reports as pdf's - then let users do what they want with them. email save whatever

The tcpdf information is very interesting... Something I may be able to use in other applications.

It does look like it probably has a pretty lengthy learning curve though, and I was hoping for a magic bullet.... LOL

Thanks for the response... I am definitely saving this info, and will take a little time now to see if it is something I can implement within the timeframe that I have to work with this project.

Thanks
Douglas

I haven't really resolved this yet, but decided to mark it solved because I'm off on a different project at the moment, and may not get back to this for another week or so.

Thanks for the feedback.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.