Webをキャプチャして変換するツール

WebページとHTMLをPDFに変換する

Node.js API

WebページとHTMLをPDFに変換する場合 GrabzItのNode.js API 次の機能を提供します integrate GrabzIt intoシステムをできるだけ簡単に。 ただし、開始する前に、 url_to_pdf, html_to_pdf or file_to_pdf メソッド save or save_to PDFスクリーンショットを取得するか、HTMLを直接PDFに変換するには、メソッドを呼び出す必要があります。

基本オプション

Webページを変換するために必要なパラメーターは1つだけです intPDF文書または HTMLをPDFに変換 としてジョブステータス出力ログに記録されます。

client.url_to_pdf("https://www.tesla.com");
//Then call the save or save_to method
client.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>");
//Then call the save or save_to method
client.file_to_pdf("example.html");
//Then call the save or save_to method

カスタム識別子

にカスタム識別子を渡すことができます PDF 次に示すメソッドを使用すると、この値はGrabzIt Node.jsハンドラーに返されます。 たとえば、このカスタム識別子はデータベース識別子であり、スクリーンショットを特定のデータベースレコードに関連付けることができます。

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.url_to_pdf("https://www.tesla.com", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"customId":123456};

client.file_to_pdf("example.html", options);
//Then call the save method
client.save("http://www.example.com/handler", function (error, id){
    if (error != null){
        throw error;
    }
});

ヘッダーとフッター

PDFスクリーンショットを作成するとき、特定の適用を要求することができます template 生成されたPDFへ。 このテンプレートは savedを事前に指定し、ヘッダーとフッターの内容を特別な変数とともに指定します。 以下のコード例では、ユーザーは「my template」というテンプレートを使用しています。

ヘッダーまたはフッターの上部マージンまたは下部マージンが十分に大きくない場合、PDFには表示されません。 次の例では、十分なスペースを確保するために、上部と下部のマージンを20に設定しています。

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"marginTop":20,"marginBottom":20,"templateId":"my template"};

client.url_to_pdf("https://www.tesla.com", options);
//Then call the save or save_to method
client.save_to("result.pdf", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"marginTop":20,"marginBottom":20,"templateId":"my template"};

client.html_to_pdf("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the save or save_to method
client.save_to("result.pdf", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});
var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

var options = {"marginTop":20,"marginBottom":20,"templateId":"my template"};

client.file_to_pdf("example.html", options);
//Then call the save or save_to method
client.save_to("result.pdf", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

HTML要素をPDFに変換

divやspanなどのHTML要素を直接変換する場合 intGrabzItのNode.jsライブラリで使用できるPDFドキュメント。 あなたは合格しなければなりません CSSセレクター に変換するHTML要素の targetElement パラメータに一致する最初のデバイスのリモートコントロール URL を返します。

...
<span id="Article">
<p>This is the content I am interested in.</p>
<img src="myimage.jpg">
</span>
...

この例では、次のIDを持つスパン内のすべてのコンテンツをキャプチャします。 Article、したがって、以下に示すようにこれをGrabzItに渡します。

var grabzit = require('grabzit');

var client = new grabzit("Sign in to view your Application Key", "Sign in to view your Application Secret");

grabzIt.url_to_pdf("http://www.bbc.co.uk/news", {"targetElement":"#Article"});
//Then call the save or save_to method
client.save_to("result.pdf", function (error, id){
    //this callback is called once the capture is downloaded
    if (error != null){
        throw error;
    }
});

HTML要素をターゲットにするときにPDFがトリミングされる方法 これらの手法を使用して制御.