글쎄, 방법이 있어야한다 예를 들어보고 좀 더 깊이를 탐구하지 않은 있지만, 나는 희망 이것은 다른 누군가에게 영감을줍니다 (나는 잠시 시간을 내면 저에게 갈 것입니다).
http://www.fpdf.org/en/script/script36.php에서 언급했듯이 (인쇄 대화 상자를 열려면) 자바 스크립트를 삽입 할 수 있습니다. 이제이 확장은 FPDF 용이며 HTML2PDF 라이브러리 용 확장은 아닙니다.
어쩌면 HTML2PDF 확장이 작성되었거나 작성 될 수도 있지만 필자의 직감은 문서를 만든 후 일반 PHP에서 쉽게 수행 할 수 있다는 것입니다. 여기에 설명 된 바와 같이
, 그것은 정직해야한다 :
은 기존 PDF을 텍스트 편집기에서 엽니 다 찾아/카탈로그와/페이지 참조 후 상용구를 삽입하고 코드에 넣어
(SRC : http://bililite.com/blog/2012/06/06/adding-javascript-to-pdf-files/)
좀 더 정보 또는 (HTML2PDF 사용) 개념의 증거가 있다면이 업데이트됩니다.
편집
난 그냥 개념을 테스트하고 잘 작동합니다. 예와 같이이 스크립트를/Catalog와 새 줄 바로 뒤에 삽입하십시오.
/Names << % the Javascript entry
/JavaScript <<
/Names [
(EmbeddedJS)
<<
/S /JavaScript
/JS (
print(true);
)
>>
]
>>
>> % end of the javascript entry
하지만 조심,
를 이것은 단지 Adobe Reader 또는 아크로뱃 프로에서 작동하며 (OSX에서 미리보기 응용 프로그램은 작동하지 않았다처럼,하지만 크롬에서 리더 빌드가 잘 작동)하지 않을 수 있습니다 다른 PDF 리더에서
편집 2 - 난 HTML 문서를 변환하고 오토매틱를 인쇄 보냅니다 pyton에 스크립트를 작성
$printCommand = <<<EOF
/Type /Catalog
/Names <<
/JavaScript <<
/Names [
(EmbeddedJS)
<<
/S /JavaScript
/JS (
print(true);
)
>>
]
>>
>>
EOF;
// Using the output method like this, you will get
// the raw ouput back to manipulate
$bin = $html2pdf->Output('', true);
// When the /Names block shows up somewhere later in
// in PDF code, it will override your script and will do nothing.
// This is just for proof of concept, you want to use regex here
if (strpos($bin, '/Names << >>') === false) {
$bin = str_replace('/Type /Catalog', $printCommand, $bin);
} else {
$printCommand = str_replace('/Type /Catalog', '', $printCommand);
$bin = str_replace('/Names << >>', $printCommand, $bin);
}
// Since we don't use the output function from HTML2PDF,
// you have to set the headers manually
header('Content-Type: application/pdf');
header('Cache-Control: public, must-revalidate, max-age=0');
header('Pragma: public');
header('Expires: Sat, 29 Jun 1985 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Content-Disposition: inline; filename="your-pdf-title";');
echo $bin;
exit;