Web Yakalama ve Dönüştürme Araçları

Web sayfalarını ve HTML'yi PDF'ye dönüştürün

Node.js API

Web sayfalarını ve HTML'yi PDF'ye dönüştürürken GrabzIt'ın Node.js API'si yardımcı olan aşağıdaki özellikleri sunar intEgrate GrabzIt into Sisteminiz mümkün olduğunca kolay. Ancak başlamadan önce aradıktan sonra bunu hatırlayın. url_to_pdf, html_to_pdf or file_to_pdf yöntemler save or save_to PDF ekran görüntüsünü almak veya HTML'yi doğrudan PDF'ye dönüştürmek için yöntem çağrılmalıdır.

Temel Seçenekler

Bir web sayfasını dönüştürmek için sadece bir parametre gereklidir into bir PDF belgesi veya HTML'yi PDF'ye dönüştür Aşağıda gösterildiği gibi.

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

Özel tanımlayıcı

Özel bir tanımlayıcıyı PDF Aşağıda gösterildiği gibi yöntemler, bu değer daha sonra GrabzIt Node.js işleyicinize döndürülür. Örneğin, bu özel tanımlayıcı, bir ekran görüntüsünün belirli bir veritabanı kaydı ile ilişkilendirilmesine izin veren bir veritabanı tanıtıcısı olabilir.

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;
    }
});

Başlıkları ve Altbilgiler

Bir PDF ekran görüntüsü oluşturduğunuzda, belirli bir uygulamayı uygulamak isteyebilirsiniz. şablon oluşturulan PDF'ye. Bu şablon olmalı saved önceden ve herhangi bir özel değişkenle birlikte üstbilgi ve altbilgi içeriğini belirtir. Aşağıdaki örnek kodda kullanıcı "şablonum" adı verilen şablonunu kullanıyor.

Üstbilgi veya altbilgi için yeterince büyük bir üst veya alt kenar boşluğu yoksa, PDF'de görünmez. Aşağıdaki örnekte, çok fazla alan sağlamak için üst ve alt kenar boşluklarını 20 olarak ayarladık.

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 öğesini PDF'ye dönüştür

Doğrudan bir div veya span gibi bir HTML öğesini doğrudan dönüştürmek istiyorsanız intGrabzIt'ın Node.js kütüphanesiyle yapabilirsiniz. Geçmelisin CSS seçici dönüştürmek istediğiniz HTML öğesinin targetElement parametre.

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

Bu örnekte, yayındaki kimliği olan yayılma alanındaki tüm içeriği yakalamak istiyoruz. Articlebu nedenle bunu aşağıda gösterildiği gibi GrabzIt'e iletiyoruz.

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;
    }
});

Bir HTML öğesini hedeflerken bir PDF nasıl kırpılır? bu teknikleri kullanarak kontrol.