您可以在將任何頁面捕獲為圖像、PDF 或 DOCX 之前更改其 HTML。
為此,您需要使用您正在使用的編程語言中的適當方法來讀取 HTML 頁面的內容。 完成此操作後,請更改 HTML,其示例如下所示。 然後將地址參數設置為用於讀取內容的相同地址參數。 這將確保使用相同的 URL 捕獲網頁,以便正確呈現任何相關資源。
string html = ""; //populate this variable by the HTML from http://www.example.com/index.html //alter HTML html += "<style>body{background-color:red !important;}</style>"; GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.Address = "http://www.example.com/index.html"; grabzIt.HTMLToImage(html, options); grabzIt.SaveTo("result.jpg");
String html = ""; //populate this variable by the HTML from http://www.example.com/index.html //alter HTML html += "<style>body{background-color:red !important;}</style>"; GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); ImageOptions options = new ImageOptions(); options.setAddress("http://www.example.com/index.html"); grabzIt.HTMLToImage(html, options); grabzIt.SaveTo("result.jpg");
var grabzit = require('grabzit'); var html = ""; //populate this variable by the HTML from http://www.example.com/index.html //alter HTML html += "<style>body{background-color:red !important;}</style>"; var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret"); client.html_to_image(html,{"address":"http://www.example.com/index.html"}); client.save_to("result.jpg", function (error, id){ if (error != null){ throw error; } });
$html = ""; #populate this variable by the HTML from http://www.example.com/index.html #alter HTML html .= "<style>body{background-color:red !important;}</style>"; $grabzIt = GrabzItClient->new("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = GrabzItImageOptions->new(); $options->address("http://www.example.com/index.html"); $grabzIt->HTMLToImage($html,$options); $grabzIt->SaveTo("result.jpg");
$html = ""; //populate this variable by the HTML from http://www.example.com/index.html //alter HTML $html .= "<style>body{background-color:red !important;}</style>"; $grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret"); $options = new \GrabzIt\GrabzItImageOptions(); $options->setAddress("http://www.example.com/index.html"); $grabzIt->HTMLToImage($html, $options); $grabzIt->SaveTo("result.jpg");
html = "" #populate this variable by the HTML from http://www.example.com/index.html #alter HTML html += "<style>body{background-color:red !important;}</style>" grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzItImageOptions.GrabzItImageOptions() options.address = "http://www.example.com/index.html" grabzIt.HTMLToImage(html, options) grabzIt.SaveTo("result.jpg")
html = "" #populate this variable by the HTML from http://www.example.com/index.html #alter HTML html += "<style>body{background-color:red !important;}</style>"; grabzIt = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret") options = GrabzIt::ImageOptions.new() options.address = "http://www.example.com/index.html" grabzIt.html_to_image(html, options) grabzIt.save_to("result.jpg")