Menangkap tangkapan layar situs web dan mengonversi situs web ke PDF menggunakan mesin tangkapan layar - generator tangkapan layar situs web online dan situs web ke PDF Converter.
a) Menggunakan Composer - Paket Manajer untuk PHP
php composer.phar require screenshotmachine/screenshotmachine-phpb) atau unduh kode sumber langsung dari github.com
Pertama, Anda perlu membuat akun gratis/premium di situs web www.screenshotmachine.com. Setelah pendaftaran, Anda akan melihat kunci pelanggan Anda di profil pengguna Anda. Frasa rahasia juga dipertahankan di sini. Tolong, gunakan frasa rahasia selalu, ketika panggilan API Anda dipanggil dari situs web yang tersedia untuk umum.
Mengatur Kunci Pelanggan dan Frasa Rahasia Anda (jika perlu) dalam skrip:
$ customer_key = " PUT_YOUR_CUSTOMER_KEY_HERE " ;
$ secret_phrase = "" ; //leave secret phrase empty, if not needed Tetapkan opsi tambahan untuk memenuhi kebutuhan Anda:
//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 " ;Info lebih lanjut tentang opsi dapat ditemukan di situs web kami Screenshot 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 ; Tautan api_url yang dihasilkan dapat ditempatkan di tag <img> atau digunakan dalam logika bisnis Anda nanti.
Jika Anda perlu menyimpan tangkapan layar yang ditangkap sebagai gambar, hubungi saja:
<?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 ; Tangkapan layar yang ditangkap akan disimpan sebagai file output.png di direktori saat ini.
Atur opsi 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 " ;Info lebih lanjut tentang opsi dapat ditemukan di situs web kami ke 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 yang ditangkap akan disimpan sebagai file output.pdf di direktori saat ini.
Lisensi MIT (MIT)