"일꾼이 일을 잘하려면 먼저 도구를 갈고 닦아야 한다." - 공자, 『논어』.
첫 장 > 프로그램 작성 > PHP 및 PERL을 사용하여 브라우저에 PDF 파일을 표시하는 방법 : 포괄적 인 가이드

PHP 및 PERL을 사용하여 브라우저에 PDF 파일을 표시하는 방법 : 포괄적 인 가이드

2025-03-23에 게시되었습니다
검색:242

How to Display PDF Files in the Browser with PHP and Perl: A Comprehensive Guide

Solution Php :

헤더 ( 'content-type : application/pdf'); 헤더 ( 'content-disposition : inline; filename = example.pdf'); @ReadFile ( 'path/to/example.pdf');

solution with perl :

[pdf, 'path/to/example.pdf') 또는 "pdf [$!]"; BINMODE PDF; 내 $ output = do {local $/; }; 닫기 (PDF); "Content-Type : application/pdf \ n"인쇄; "콘텐츠 길이 :"인쇄. 길이 ($ 출력). "\ n \ n";

header('Content-type: application/pdf');
header('Content-Disposition: inline; filename=example.pdf');
@readfile('path/to/example.pdf');

open(PDF, 'path/to/example.pdf') or die "Could not open PDF [$!]";
binmode PDF;
my $output = do { local $/;  };
close(PDF);

print "Content-Type: application/pdf\n";
print "Content-Length: " . length($output) . "\n\n";
print $output;

Adobe Reader x : 가로드 진로 막대를 누락 됨 :

'content-transfer-ender'
  • PDF가 외부 응용 프로그램에서 강제로 다운로드하거나 열 수있는 설정이있을 수 있습니다. $ filename = 'Custom File Name asse.pdf'; 헤더 ( 'content-type : application/pdf'); 헤더 ( 'content-disposition : inline; filename = "'. $ filename. '"); 헤더 ( 'Content-Transfer-Encoding : Binary'); 헤더 ( 'content-length :'. filesize ($ file)); 헤더 ( '수락-범위 : 바이트'); @ReadFile ($ file);
  • 이 코드는 사용자의 브라우저 내에 PDF 파일의 표시를 활성화하고 클릭을 추적하고 원하는 개인 정보 수준을 유지할 수 있어야합니다.
릴리스 선언문 이 기사는 1729332617에 재현됩니다.
최신 튜토리얼 더>

부인 성명: 제공된 모든 리소스는 부분적으로 인터넷에서 가져온 것입니다. 귀하의 저작권이나 기타 권리 및 이익이 침해된 경우 자세한 이유를 설명하고 저작권 또는 권리 및 이익에 대한 증거를 제공한 후 이메일([email protected])로 보내주십시오. 최대한 빨리 처리해 드리겠습니다.

Copyright© 2022 湘ICP备2022001581号-3