จับภาพหน้าจอของเว็บไซต์และแปลงเว็บไซต์เป็น PDF โดยใช้เครื่องชิมช็อต - เครื่องกำเนิดภาพหน้าจอและเว็บไซต์ของเว็บไซต์ออนไลน์เป็นตัวแปลง PDF
A) การใช้นักแต่งเพลง - Manager Package สำหรับ PHP
php composer.phar require screenshotmachine/screenshotmachine-phpb) หรือดาวน์โหลดซอร์สโค้ดโดยตรงจาก github.com
ก่อนอื่นคุณต้องสร้างบัญชีฟรี/พรีเมี่ยมที่เว็บไซต์ www.screenshotmachine.com หลังจากลงทะเบียนคุณจะเห็นคีย์ลูกค้าของคุณในโปรไฟล์ผู้ใช้ของคุณ นอกจากนี้ยังมีการดูแลวลีลับที่นี่ โปรดใช้วลีลับเสมอเมื่อการโทร API ของคุณถูกเรียกจากเว็บไซต์ที่เปิดเผยต่อสาธารณะ
ตั้งค่าคีย์ลูกค้าและวลีลับ (ถ้าจำเป็น) ในสคริปต์:
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed ตั้งค่าตัวเลือกเพิ่มเติมเพื่อตอบสนองความต้องการของคุณ:
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;ข้อมูลเพิ่มเติมเกี่ยวกับตัวเลือกสามารถพบได้ในเว็บไซต์หน้าจอ API ของเรา
<?php
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;
$ api_url = $ machine -> generate_screenshot_api_url ( $ options );
//put link to your html code
echo ' <img src=" ' . $ api_url . ' "> ' . PHP_EOL ; ลิงค์ api_url ที่สร้างขึ้นสามารถวางไว้ในแท็ก <img> หรือใช้ในตรรกะธุรกิจของคุณในภายหลัง
หากคุณต้องการจัดเก็บภาพหน้าจอที่จับได้เป็นภาพเพียงโทร:
<?php
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website screenshot API guide for more details
$ options [ ' dimension ' ] = " 1366x768 " ; // or "1366xfull" for full length screenshot
$ options [ ' device ' ] = " desktop " ;
$ options [ ' format ' ] = " png " ;
$ options [ ' cacheLimit ' ] = " 0 " ;
$ options [ ' delay ' ] = " 200 " ;
$ options [ ' zoom ' ] = " 100 " ;
$ api_url = $ machine -> generate_screenshot_api_url ( $ options );
//save screenshot as an image
$ output_file = ' output.png ' ;
file_put_contents ( $ output_file , file_get_contents ( $ api_url ));
echo ' Screenshot saved as ' . $ output_file . PHP_EOL ; ภาพหน้าจอที่จับได้จะถูกบันทึกเป็นไฟล์ output.png ในไดเรกทอรีปัจจุบัน
ตั้งค่าตัวเลือก PDF:
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website to PDF API guide for more details
$ options [ ' paper ' ] = " letter " ;
$ options [ ' orientation ' ] = " portrait " ;
$ options [ ' media ' ] = " print " ;
$ options [ ' bg ' ] = " nobg " ;
$ options [ ' delay ' ] = " 2000 " ;
$ options [ ' scale ' ] = " 50 " ;ข้อมูลเพิ่มเติมเกี่ยวกับตัวเลือกสามารถพบได้ในเว็บไซต์ของเราถึง PDF API
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed
$ machine = new ScreenshotMachine ( $ customer_key , $ secret_phrase );
//mandatory parameter
$ options [ ' url ' ] = " https://www.google.com " ;
// all next parameters are optional, see our website to PDF API guide for more details
$ options [ ' paper ' ] = " letter " ;
$ options [ ' orientation ' ] = " portrait " ;
$ options [ ' media ' ] = " print " ;
$ options [ ' bg ' ] = " nobg " ;
$ options [ ' delay ' ] = " 2000 " ;
$ options [ ' scale ' ] = " 50 " ;
$ pdf_api_url = $ machine -> generate_pdf_api_url ( $ options );
//save PDF file
$ output_file = ' output.pdf ' ;
file_put_contents ( $ output_file , file_get_contents ( $ pdf_api_url ));
echo ' PDF saved as ' . $ output_file . PHP_EOL ; PDF ที่จับได้จะถูกบันทึกเป็นไฟล์ output.pdf ในไดเรกทอรีปัจจุบัน
ใบอนุญาต MIT (MIT)