php教程 PHP开发 PHP FPDF 클래스 라이브러리 애플리케이션 구현 코드

PHP FPDF 클래스 라이브러리 애플리케이션 구현 코드

Dec 14, 2016 pm 12:00 PM
fpdf

require('chinese.php');
class PDF 확장 PDF_중국어
{
function Header() //헤더 설정
{
$ this->SetFont('GB','',10);
$this->Write(10,'XX 회사 제품 디렉토리')
$this->Ln(20); /줄 바꿈
}
function Footer() //바닥글 설정
{
$this->SetY(-15)
$this->SetFont('GB' , '',10);
$this->Cell(0,10,'th'.$this->PageNo().'Page');
$conn = mysql_connect("localhost", "root", ""); //데이터베이스에 연결

mysql_select_db("product", $conn) //SQL 실행

$ query_rs_prod = " SELECT * PROM PRODER BY PROD_ID ";

$ RS_PROD = MySQL_QUERY($ Query_RS_PROD, $ Conn) 또는 DIE(mysql_error ())

$ row_rs_prod = _Fetch_assoc($ rs_prod); Totalrows_RS_PROD = MySQL_NUM_ROWS ($rs_prod);

$pdf=new PDF(); //새 FPDF 객체 생성
$pdf->AddGBFont() //중국어 글꼴 설정
$ pdf-> ;Open(); //PDF 만들기 시작

$pdf->AddPage(); //페이지 추가


$pdf->SetFont('GB','', 10); //글꼴 스타일 설정

$header=array('제품 번호', '제품 이름', '제품 유형', '제품 단가') //헤더 설정

$width =array( 20,80,40,20); //각 열의 너비 설정

for($i=0;$i$ pdf->Cell($width[$i],6,$header[$i],1)
$pdf->Ln();

do // 루프 출력 테이블 본문
{
$pdf->Cell($width[0],6,$row_rs_prod['prod_id'],1)

$pdf->Cell($width[ 1],6 ,$row_rs_prod['prod_name'],1);

$pdf->Cell($width[2],6,$row_rs_prod['prod_type'],1)
$pdf ->Cell ($width[3],6,$row_rs_prod['prod_price'],1)
$pdf->Ln()
} while ($row_rs_prod = mysql_fetch_assoc($rs_prod) );

$pdf->Output("product.pdf", true); //PDF 파일 다운로드
?>

코드는 다음과 같습니다.
define('FPDF_FONTPATH','font/'); //글꼴 폴더 경로 정의

require_once('fpdf/fpdf.php') //fpdf 포함 클래스 라이브러리 파일
$pdf= new FPDF('P', 'mm', 'A4') //새 FPDF 객체를 생성하고 용지를 세로로 놓습니다. 단위는 밀리미터이고 용지 크기는 A4입니다.
$pdf->Open(); // PDF 만들기 시작
$pdf->AddPage() //페이지 추가
$pdf->SetFont('Courier','I', 20); //글꼴 스타일 설정
$ pdf->Cell(0,0,'Hello World!') //셀 추가
$pdf->Output(); 브라우저에
?>


코드는 다음과 같습니다.
define('FPDF_FONTPATH','font/') //Define the 글꼴 폴더 경로

require_once('fpdf/fpdf.php'); //fpdf 클래스 라이브러리 파일 포함
$pdf=new FPDF('P', 'mm', 'A4') // 새로운 FPDF 개체를 만들고, 용지를 세로로 놓습니다. 단위는 밀리미터입니다. 용지 크기는 A4
$pdf->Open() //PDF 만들기 시작
$pdf->AddPage() // 페이지 추가
$pdf->SetFont('Courier' ,'I',20) //글꼴 스타일 설정
$pdf->Image('sight.jpg',20,20, 0,0); //sight.jpg
$pdf->Output() //PDF를 브라우저에 출력


코드는 다음과 같습니다.
define( 'FPDF_FONTPATH','font/') //글꼴 폴더 경로 정의

require_once('fpdf/fpdf.php' ); //fpdf 클래스 라이브러리 파일 포함

$pdf=new FPDF('P ', 'mm', 'A4') //새 FPDF 객체를 생성하고 용지를 세로로 놓습니다. 단위는 밀리미터입니다. 용지 크기는 A4
$pdf->Open(); //PDF 만들기 시작
$pdf->AddPage() //페이지 추가
$pdf->SetFont(' Courier','I',20); //글꼴 스타일 설정
$pdf->Cell (60,10,'Hello World!',1) //1에 셀 테두리 추가
$ pdf->Output(); //PDF를 브라우저에 출력
?>


코드는 다음과 같습니다.
define('FPDF_FONTPATH ','font/'); //글꼴 폴더 경로 정의

require_once('fpdf/fpdf.php') //fpdf 클래스 라이브러리 파일 포함

$pdf=new FPDF('P' , 'mm', 'A4'); //새 FPDF 객체를 생성하고 용지를 세로로 놓습니다. 단위는 밀리미터입니다. 용지 크기는 A4
$pdf->Open() //PDF 생성 시작
$pdf->AddPage(); //페이지 추가

$pdf->SetFont( 'Arial','',14) //글꼴 스타일 설정

$header=array('이름','Age','Sex','Salary'); //테이블 헤더 설정
$data=array() //테이블 본문 설정
$data [0] = array('사이먼','24','남성','5,000.00')
$data[1] = array('엘레인','25','여성','6,000.00 ') ;
$data[2] = array('수잔','25','여성','7,000.00')
$data[3] = array('데이비드','26', '남성','8,000.00');

$width=array(40,40,40,40) //각 열의 너비 설정

for($i=0; $i$pdf->Cell($width[$i],6,$header[$i],1)
$ pdf-> ;Ln();

foreach($data as $row) //루프 출력 테이블 본문
{
$pdf->Cell($width[0],6, $row[ 0],1);
$pdf->Cell($width[1],6,$row[1],1)
$pdf->Cell($width[2) ],6 ,$row[2],1);
$pdf->Cell($width[3],6,$row[3],1)
$pdf->Ln( );
}

$pdf->Output(); //PDF를 브라우저에 출력
?>


코드는 다음과 같습니다. 🎜>define('FPDF_FONTPATH','font/'); //글꼴 폴더 경로 정의
require_once('fpdf/fpdf.php') //fpdf 클래스 포함 library file
$pdf= new FPDF('P', 'mm', 'A4'); //새 FPDF 객체를 생성하고 용지를 세로로 배치합니다. 단위는 밀리미터이며 용지 크기는 A4입니다.
$pdf->Open(); // PDF 만들기 시작
$pdf->AddPage() //페이지 추가
$pdf->SetFont('Courier','I',20 ); //글꼴 스타일 설정
$ pdf->Cell(0,0,'Hello, FPDF') //셀 추가 및 중국어 출력
$pdf->Output(); PDF를 브라우저에 출력
? >

코드는 다음과 같습니다.
require('chinese.php')
class PDF 확장 PDF_중국어
{
function Header( ) //헤더 설정
{
$this->SetFont('GB','',10); Write(10,'FPDF 중국어 테스트');
$this->Ln(20)
}

function Footer() //바닥글 설정

{

$this->SetY(-15) ;
$this->SetFont('GB','',10)
$this->Cell(0,10,'페이지 '.$ this->PageNo().' ');
}

$pdf=new PDF(); //PDF 문서 생성
$pdf->AddGBFont() ;

$pdf->

$pdf->AliasNbPages()
$pdf->SetFont('GB' ,'I',20);
$pdf->Cell(0,10,'Hello, FPDF') //한문 조각 출력
$pdf->Output(); >?>


코드는 다음과 같습니다.
$conn = mysql_connect("localhost", "root", ""); 데이터베이스

$colname_rs_article = $_GET['id'] ; //매개변수 ID 가져오기


mysql_select_db("cms", $conn); //SQL 실행
$query_rs_article = sprintf(" SELECT * FROM 기사 WHERE 기사 ID = %s", $colname_rs_article);
$rs_article = mysql_query($query_rs_article, $conn) 또는 die(mysql_error());
$row_rs_article = mysql_fetch_assoc($rs_article);

$totalRows_rs_article = mysql_num_rows($rs_article);


function conv($Text) //반환된 텍스트 처리
{
$Text=htmlspecialchars($Text); //HTML 키 변환 문자
$Text=nl2br($Text); / /줄 바꿈

return $Text;}

?> ;


<글꼴 크기=2> PDF 문서 다운로드 a>






코드는 다음과 같습니다:
require('chinese.php')
class PDF extends PDF_English
{
function Header() / /설정 페이지 눈썹
{
$this->SetFont('GB','',10)
$this->Write(10,'Article System-XX Website'); 🎜>$ this->Ln(20); //줄 바꿈
}
function Footer() //바닥글 설정
{
$this->SetY(-15);
$ this->SetFont('GB','',10)
$this->Cell(0,10,'th'.$this->PageNo().'page' );
}
}
//메인 프로그램 시작
$conn = mysql_connect("localhost", "root", "") //데이터베이스에 연결
$colname_rs_article = $_GET['id' ]; //매개변수 ID 가져오기

mysql_select_db("cms", $conn); //SQL 실행

$query_rs_article = sprintf("SELECT * FROM 기사 WHERE 기사_id = %s", $colname_rs_article) ;
$rs_article = mysql_query($query_rs_article, $conn) 또는 die(mysql_error());
$row_rs_article = mysql_fetch_assoc($rs_article);
$totalRows_rs_article = mysql_num_rows( $rs_article);
//PDF 문서 만들기 시작
$pdf->AddGBFont()
$pdf->Open(); >$pdf->AliasNbPages ();
$pdf->AddPage()
$pdf->SetFont('GB','B',20); ;Cell(0,10, $row_rs_article['title']); //기사 제목 출력
$pdf->Ln() //줄 바꿈
$pdf->SetFont('GB' ,'',10);
$pdf->Cell(0,10,$row_rs_article['author']); //출력 기사 작성자
$pdf->Ln(); $pdf->SetFont(' GB','',12);
$content = $row_rs_article['content']
while($content != "") //기사 작성을 반복합니다. 콘텐츠를 페이지별로 PDF로 가져오기
{
$length = strlen($content); //기사 길이 가져오기
$output = substr($content, 0, 1024) //출력 콘텐츠 가져오기 이 페이지의 1024자마다 1페이지
$pdf->Cell(0,10,$output) //기사 내용 출력
$content = substr($content, 1024, $length) ; //출력되지 않은 나머지 콘텐츠 가져오기
$pdf ->AddPage(); //페이지 변경
}
$pdf->Output($row_rs_article['title'].".pdf" , true); //PDF 파일 출력, 파일명 기사 제목


코드는 다음과 같습니다.
define('FPDF_FONTPATH' ,'font/'); //글꼴 폴더에 대한 경로 정의
require_once('fpdf/fpdf.php') //fpdf 클래스 라이브러리 파일 포함

class PDF는 FPDF를 확장합니다. >{
function Header() //헤더 설정
{
$this->SetFont('Arial','B',15) //헤더 글꼴 설정
$this ->Cell(80); //셀 이동

$ this->Cell(30,10,'Title') //헤더 텍스트 쓰기

$this->Ln(20); //줄바꿈
}

function Footer () //바닥글 설정
{
$this->SetY(-15) //바닥글 위치 설정
$this->SetFont('Arial','I', 8); //바닥글 글꼴 설정
$this->Cell(0,10,'Page - '.$this->PageNo( )); //현재 페이지 번호를 바닥글 내용으로 출력
}

}


$pdf=new PDF('P', 'mm', 'A4') //생성 새 FPDF 개체, 용지를 세로로 배치합니다. 단위는 밀리미터이며 용지 크기는 A4입니다.
$pdf->Open() //PDF 만들기 시작
$pdf->AddPage() / /페이지 추가
$pdf->SetFont('Courier','I ',20) //글꼴 스타일 설정
$pdf->Cell(0,0,'Hello World!') ; //셀 추가
$pdf->Output(); / /브라우저에 PDF 출력

?>


위는 PHP FPDF 클래스 라이브러리 응용 프로그램 구현 코드입니다. 더 많은 관련 내용을 보려면 PHP 중국어 웹사이트(www.php.cn)를 주목하세요!

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)