FPDF로 테스트 해본 결과 PDF 작성과 관련하여 괜찮습니다.응용 프로그램에서 FPDF 사용
내 응용 프로그램에서 'PDF로 변환'이라고 읽는 버튼이 있으며 사용자가 클릭하면 FPDF는 지정된 변수를 사용하여 새 창에서 PDF를 만듭니다.
PDF를 생성하는 코드는 다음과 같다 :
$name = "John";
: 각 필드의 예에 대한 데이터베이스 쿼리 및 변수의 출력을 별도의 페이지에서
require_once("fpdf.php");
$author = "Test";
$title = "Candidate profile";
$width = 10;
$height = 10;
$text = "Test";
$font_family = 'Arial';
$font_size = 11;
$file_name = "candidate-profile-jesse-orange";
$extension = ".pdf";
$output = "I";
$heading_size = 16;
$subheading_size = 13;
class PDF extends FPDF
{
// Page header
function Header()
{
// Logo
$this->Image('logo.png',10,10,30);
// Arial bold 15
$this->SetFont('Arial','B',16);
// Move to the right
$this->Cell(50);
// Title
$this->Cell(100,8,'Candidate profile for: Jesse Orange',1,0,'C');
// Line break
$this->Ln(20);
}
// Page footer
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'R');
}
}
// Create a new instance
$pdf = new PDF("P", "mm", "A4");
// Set some default options
$pdf->setAuthor($author);
$pdf->setTitle($title);
$pdf->AddPage();
$pdf->SetDisplayMode("real",'default');
$pdf->SetFont($font_family, '', $font_size);
// Field
$pdf->SetFont($font_family, 'B', $font_size);
$pdf->Cell(40, $height, "Position applied for:", 0, 0);
// Value
$pdf->SetFont($font_family, '', $font_size);
$pdf->Cell(60, $height, "Innovation Advisor (Job ID: 221)", 0, 0);
// Field
$pdf->SetFont($font_family, 'B', $font_size);
$pdf->Cell(40, $height, "Date of application:", 0, 0);
// Value
$pdf->SetFont($font_family, '', $font_size);
$pdf->Cell(50, $height, "17th July 2017", 0, 1);
$pdf->Output($file_name.$extension, $output);
$surname = "Smith";
이상 correctl Y ...
$name = $row['name'];
내 질문은 : 나는 PDF를 생성하기 위해 별도의 스크립트에 이미 저장된 변수를 게시해야하거나 같은 페이지에 있어야?
이론적으로 버튼을 누른에 당신은 부를 수 $pdf->Output();
추가 페이지에 표시
변수가 브라우저에서보기 위해, 다음 사용자가 단순히 이러한 변수를 잡아 것을 PDF로 변환을 클릭 것이있다 FPDF와 함께 사용하십시오.
Google 애널리틱스에서 보고서를 PDF로 다운로드하는 방법도 비슷한 예입니다.
- 데이터베이스 값이
- 이 사용자는 사용자가 편집 할 수 없습니다 PDF 파일
을 ... 값을 검토하고 선택적으로 생성하여 사용자에게 최종 표시됩니다 :이 흐름을 감안할 때
왜 DB에서 데이터를 가져 오는 두 개의 스크립트가 필요합니까? 변수를 먼저 표시하여 사용자 승인을 얻습니까? –
변수는 웹 페이지에 표시하기 위해 표시되지만 PDF로 볼 수있는 옵션이 있습니다. –
값을 외부 (예 : POST 양식)로 제출하면 변경 가능성이 열립니다. 그게 바람직한가요? –