वेब पर कब्जा और परिवर्तित करने के लिए उपकरण

वेबपेज और पीडीएफ को पीडीएफ में बदलें

Node.js एपीआई

वेबपेज और HTML को पीडीएफ में कनवर्ट करते समय GrabzIt की Node.js एपीआई निम्नलिखित सुविधाएँ प्रदान करता है जो मदद करते हैं intपकड़ो intओ अपने सिस्टम को जितनी आसानी से संभव हो सके। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद url_to_pdf, html_to_pdf or file_to_pdf तरीके save or save_to पीडीएफ स्क्रीनशॉट लेने या HTML को सीधे पीडीएफ में बदलने के लिए विधि को बुलाया जाना चाहिए।

मूल विकल्प

वेब पेज को रूपांतरित करने के लिए केवल एक पैरामीटर की आवश्यकता होती है intoa PDF डॉक्यूमेंट या 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

कस्टम पहचानकर्ता

आप एक कस्टम पहचानकर्ता को पास कर सकते हैं पीडीएफ नीचे दिखाए गए तरीके, यह मान तब आपके 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;
    }
});

शीर्षलेख और पाद लेख

जब आप एक पीडीएफ स्क्रीनशॉट बनाते हैं तो आप अनुरोध कर सकते हैं कि आप किसी विशेष को लागू करना चाहते हैं टेम्पलेट उत्पन्न पीडीएफ के लिए। यह टेम्पलेट होना चाहिए saveडी अग्रिम में और किसी विशेष चर के साथ हेडर और फुटर की सामग्री को निर्दिष्ट करेगा। उपयोगकर्ता के नीचे के उदाहरण कोड में उनके टेम्पलेट का उपयोग किया जाता है जिसे "मेरा टेम्पलेट" कहा जाता है।

यदि हेडर या फुटर के लिए क्रमशः एक बड़ा पर्याप्त शीर्ष या निचला मार्जिन नहीं है, तो यह पीडीएफ में दिखाई नहीं देगा। नीचे के उदाहरण में हमने काफी जगह प्रदान करने के लिए 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 एलिमेंट को पीडीएफ में कन्वर्ट करें

यदि आप किसी HTML एलिमेंट जैसे डिव या स्पैन को सीधे कन्वर्ट करना चाहते हैं intoa PDF दस्तावेज़ आप GrabzIt's Node.js लाइब्रेरी के साथ कर सकते हैं। आपको पास होना चाहिए सीएसएस चयनकर्ता जिस HTML एलिमेंट को आप कन्वर्ट करना चाहते हैं targetElement पैरामीटर।

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

इस उदाहरण में, हम उस अवधि की सभी सामग्री को कैप्चर करना चाहते हैं जिसके पास आईडी है 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 को कैसे क्रॉप किया जाता है इन तकनीकों का उपयोग करके नियंत्रित किया जाता है.