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

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

जावा एपीआई

HTML फाइल, वेब पेज या सादे HTML को पीडीएफ में कनवर्ट करते समय। GrabzIt के जावा एपीआई निम्नलिखित सुविधाएँ प्रदान करता है जो मदद करते हैं intपकड़ो intओ अपने सिस्टम को जितनी आसानी से संभव हो सके।

हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद URLToPDF, HTMLToPDF or FileToPDF तरीकों। या तो Save or SaveTo पीडीएफ स्क्रीनशॉट लेने या HTML को सीधे पीडीएफ में बदलने के लिए विधि को बुलाया जाना चाहिए।

मूल विकल्प

एक पीडीएफ स्क्रीनशॉट पूरे वेब पेज को कैप्चर करता है और इसे परिवर्तित करता है intoa पीडीएफ फाइल जिसमें कई पेज हो सकते हैं। लक्ष्य वेब पेज की लंबाई पर निर्भर करता है। वेब पेज को रूपांतरित करने के लिए केवल एक पैरामीटर की आवश्यकता होती है intoa पीडीएफ दस्तावेज़। या इसमें HTML को PDF में बदलें के रूप में नीचे दिखाया गया है.

grabzIt.URLToPDF("https://www.tesla.com");
//Then call the Save or SaveTo method
grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>");
//Then call the Save or SaveTo method
grabzIt.FileToPDF("example.html");
//Then call the Save or SaveTo method

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

आप एक कस्टम पहचानकर्ता को पास कर सकते हैं पीडीएफ नीचे दिखाए गए तरीके। यह मान तब आपके GrabzIt Java हैंडलर को वापस कर दिया जाता है। उदाहरण के लिए यह कस्टम पहचानकर्ता एक डेटाबेस पहचानकर्ता हो सकता है, जो स्क्रीनशॉट को किसी विशेष डेटाबेस रिकॉर्ड से जुड़ा होने की अनुमति देता है।

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setCustomId("123456");

grabzIt.URLToPDF("https://www.tesla.com", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setCustomId("123456");

grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setCustomId("123456");

grabzIt.FileToPDF("example.html", options);
//Then call the Save method
grabzIt.Save("http://www.example.com/handler");

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

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

यदि हेडर या फुटर के लिए क्रमशः एक बड़ा पर्याप्त शीर्ष या निचला मार्जिन नहीं है। यह पीडीएफ में दिखाई नहीं देगा। नीचे दिए गए उदाहरण में हमने बहुत सारे स्थान प्रदान करने के लिए 20 में शीर्ष और निचले मार्जिन को निर्धारित किया है।

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setMarginTop(20);
options.setMarginBottom(20);
options.setTemplateId("my template");

grabzIt.URLToPDF("https://www.tesla.com", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setMarginTop(20);
options.setMarginBottom(20);
options.setTemplateId("my template");

grabzIt.HTMLToPDF("<html><body><h1>Hello World!</h1></body></html>", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf");
GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setMarginTop(20);
options.setMarginBottom(20);
options.setTemplateId("my template");

grabzIt.FileToPDF("example.html", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf");

HTML एलिमेंट को पीडीएफ में कन्वर्ट करें

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

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

इस उदाहरण में, हम उस अवधि की सभी सामग्री को कैप्चर करना चाहते हैं जिसके पास आईडी है Article। तो हम इस आईडी को GrabzIt को पास करते हैं, जैसा कि नीचे दिखाया गया है।

GrabzItClient grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

PDFOptions options = new PDFOptions();
options.setTargetElement("#Article");

grabzIt.URLToPDF("http://www.bbc.co.uk/news", options);
//Then call the Save or SaveTo method
grabzIt.SaveTo("result.pdf");

HTML एलिमेंट को टारगेट करते समय PDF को कैसे क्रॉप किया जाता है इन तकनीकों का उपयोग करके नियंत्रित किया जाता है.