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

URL और HTML को DOCX में बदलें

पीएचपी एपीआई

HTML या वेब पृष्ठों को परिवर्तित करने की क्षमता जोड़ना into आपके एप्लिकेशन के लिए Word दस्तावेज़ कभी भी आसान नहीं रहे हैं GrabzIt's PHP API। हालांकि इससे पहले कि आप याद रखें कि कॉल करने के बाद URLToDOCX, HTMLToDOCX or FileToDOCX तरीकों। Save or SaveTo विधि को वास्तव में DOCX बनाने के लिए कहा जाना चाहिए।

मूल विकल्प

DOCX के रूप में वेब पेज कैप्चर करना पूरे वेब पेज को कनवर्ट करता है intoa वर्ड डॉक्यूमेंट जिसमें कई पेज हो सकते हैं। नीचे दिए गए उदाहरणों में PHP HTML को DOCX में कनवर्ट करता है और एक वेब पेज intoa वर्ड डॉक्यूमेंट, केवल एक आवश्यक पैरामीटर के साथ।

$grabzIt->URLToDOCX("https://www.tesla.com");
//Then call the Save or SaveTo method
$grabzIt->HTMLToDOCX("<html><body><h1>Hello World!</h1></body></html>");
//Then call the Save or SaveTo method
$grabzIt->FileToDOCX("example.html");
//Then call the Save or SaveTo method

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

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

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setCustomId(123456);

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setCustomId(123456);

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setCustomId(123456);

$grabzIt->FileToDOCX("example.html", $options);
//Then call the Save method
$grabzIt->Save("http://www.example.com/handler.php");

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

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

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setTemplateId("my template");

$grabzIt->URLToDOCX("https://www.tesla.com", $options);
//Then call the Save or SaveTo method
$grabzIt->SaveTo("result.docx");
$grabzIt = new \GrabzIt\GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret");

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setTemplateId("my template");

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setTemplateId("my template");

$grabzIt->FileToDOCX("example.html", $options);
//Then call the Save or SaveTo method
$grabzIt->SaveTo("result.docx");

HTML तत्व को DOCX में बदलें

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

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

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

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

$options = new \GrabzIt\GrabzItDOCXOptions();
$options->setTargetElement("#Article");

$grabzIt->URLToDOCX("http://www.bbc.co.uk/news", $options);
//Then call the Save or SaveTo method
$grabzIt->SaveTo("result.docx");

इससे कोई फर्क नहीं पड़ता कि आप URL को Word में रूपांतरित कर रहे हैं जैसा कि उदाहरण में HTML या Word को दिखाया गया है। दोनों HTML तत्वों को बिल्कुल उसी तरह से लक्षित करते हैं।