Ver Mensaje Individual
  #9 (permalink)  
Antiguo 24/11/2009, 15:29
Avatar de JessicaTJ
JessicaTJ
 
Fecha de Ingreso: enero-2007
Ubicación: 127.0.0.1
Mensajes: 472
Antigüedad: 17 años, 3 meses
Puntos: 25
Respuesta: FPDF e imprimir el contenido en pantalla

Iap, ia logre hacerlo, ahora, cuando descarga el PDF y trato de abrirlo me marca esto:



Alguna idea de porke abimaelrc?

El codigo es algo asi:
Código PHP:
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');

// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');

// The PDF source is in original.pdf
readfile('original.pdf');
?>
<?php

require('fpdf.php');

//Connect to your database
include("connection.php");

//Select the Products you want to show in your PDF file
$result=mysql_query("SELECT ...");
$number_of_products mysql_num_rows($result);

//Initialize the 3 columns and the total
$column_part "";
$column_price "";
$column_image "";
$total 0;

//For each row, add the field to the corresponding column
while($row mysql_fetch_array($result))
{
    
$part $row["part"];
    
$price $row["price"];
    
$image $row["image"];
    
$price number_format($row["price"],',','.','.');

    
$column_part $column_part.$part."\n";
    
$column_price $column_price.$price."\n";
    
$column_image $column_image.$image."\n";
        
    
//Sum all the Prices (TOTAL)
    
$total $total+$column_price;
}
mysql_close();

//Convert the Total Price to a number with (.) for thousands, and (,) for decimals.
$total number_format($total,',','.','.');

//Create a new PDF file
$pdf=new FPDF();
$pdf->AddPage();

//Fields Name position
$Y_Fields_Name_position 20;
//Table position, under Fields Name
$Y_Table_Position 26;

//First create each Field Name
//Gray color filling each Field Name box
$pdf->SetFillColor(232,232,232);
//Bold Font for Field Name
$pdf->SetFont('Arial','B',12);
$pdf->SetY($Y_Fields_Name_position);
$pdf->SetX(45);
$pdf->Cell(20,6,'CODE',1,0,'L',1);
$pdf->SetX(65);
$pdf->Cell(100,6,'NAME',1,0,'L',1);
$pdf->SetX(135);
$pdf->Cell(30,6,'PRICE',1,0,'R',1);
$pdf->Ln();

//Now show the 3 columns
$pdf->SetFont('Arial','',12);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(45);
$pdf->MultiCell(20,6,$column_part,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(65);
$pdf->MultiCell(100,6,$column_image,1);
$pdf->SetY($Y_Table_Position);
$pdf->SetX(135);
$pdf->MultiCell(30,6,'$ '.$column_price,1,'R');
$pdf->SetX(135);
$pdf->MultiCell(30,6,'$ '.$total,1,'R');

//Create lines (boxes) for each ROW (Product)
//If you don't use the following code, you don't create the lines separating each row
$i 0;
$pdf->SetY($Y_Table_Position);
while (
$i $number_of_products)
{
    
$pdf->SetX(45);
    
$pdf->MultiCell(120,6,'',1);
    
$i $i +1;
}

$pdf->Output();
?>
__________________
٩(͡๏̯͡๏)۶ || ٩(͡๏̯͡๏)۶