नि:शुल्क C++ API के द्वारा डायनेमिक Word DOCX फ़ाइल निर्माण
एक प्रमुख ओपन-सोर्स नि:शुल्क C++ Word प्रोसेसिंग लाइब्रेरी प्रोग्रामेटिकली Word DOCX फ़ाइलें बनाना, संपादित करना, मर्ज करना और रूपांतरित करना संभव बनाती है। बारकोड, चार्ट, टेक्स्ट, इमेज जोड़ें और फ़ॉर्मेटिंग लागू करें।
MiniDocx क्या है?
DocxFactory एक शक्तिशाली, क्रॉस‑प्लेटफ़ॉर्म ओपन‑सोर्स C++ लाइब्रेरी है, जो टेम्प्लेट‑आधारित दस्तावेज़ निर्माण के माध्यम से Microsoft Word DOCX फ़ाइलें (OpenXML फ़ॉर्मेट) जनरेट करने के लिए डिज़ाइन की गई है। यह मुफ्त लाइब्रेरी C#, Java, Python, और Progress 4GL सहित कई प्रोग्रामिंग भाषाओं के लिए रैपर्स और कमांड‑लाइन टूल्स के साथ आती है। DocxFactory को अलग बनाता है इसका टेम्प्लेट‑ड्रिवेन अप्रोच, जो डेवलपर्स को जटिल OpenXML फ़ाइल फ़ॉर्मेट को समझने की जरूरत नहीं पड़ती। लाइब्रेरी विभिन्न महत्वपूर्ण वर्ड प्रोसेसिंग सुविधाओं का समर्थन करती है, जैसे टेम्प्लेट‑आधारित दस्तावेज़ जनरेशन, पैराग्राफ या चित्र जोड़ना/हटाना, टेक्स्ट फ़ॉर्मेटिंग, टेबल्स के साथ काम करना, सेल्स को मर्ज या स्प्लिट करना, लिस्ट्स को मैनेज करना, मल्टी‑लैंग्वेज सपोर्ट, व्यापक बारकोड सपोर्ट, कई आउटपुट फ़ॉर्मेट सपोर्ट आदि।
MiniDocx एक परिपक्व, मुक्त, क्रॉस‑प्लेटफ़ॉर्म C/C++ लाइब्रेरी (बहु‑भाषा रैपर्स के साथ) है जो Microsoft Word .docx फ़ाइलों के साथ काम को सरल बनाती है। यह लाइब्रेरी विभिन्न प्रमुख ऑपरेटिंग सिस्टम (Windows, UNIX/Linux) पर सहजता से काम करती है, जिससे सर्वर, डेस्कटॉप या एम्बेडेड सिस्टम पर डिप्लॉयमेंट में लचीलापन मिलता है। यह Apache 2.0 लाइसेंस के तहत लाइसेंस प्राप्त है, जिससे यह निजी और वाणिज्यिक दोनों उपयोगों के लिए पूरी तरह से मुफ्त है, बिना किसी फीचर प्रतिबंध या समय सीमा के। चाहे आप एंटरप्राइज रिपोर्टिंग सिस्टम, स्वचालित दस्तावेज़ वर्कफ़्लो या सरल मेल मर्ज एप्लिकेशन बना रहे हों, MiniDocx कुशलता से पेशेवर दस्तावेज़ जनरेट करने के लिए आवश्यक टूल्स प्रदान करता है।
MiniDocx के साथ शुरू करना
DocxFactory को इंस्टॉल करने का अनुशंसित तरीका GitHub के माध्यम से है। कृपया सुगम इंस्टॉलेशन के लिए निम्न कमांड का उपयोग करें।
GitHub के माध्यम से DocxFactory इंस्टॉल करें
git clone git@github.com:totravel/minidocx.git
cd minidocx You can also download it directly from Aspose product page.C++ के माध्यम से टेम्प्लेट-आधारित दस्तावेज़ निर्माण
DocxFactory का मूल दर्शन सरलता पर आधारित है। प्रोग्रामेटिकली तत्व‑दर‑तत्व दस्तावेज़ बनाने के बजाय, आप Microsoft Word में एक टेम्प्लेट बनाते हैं—एक सामान्य DOCX फ़ाइल जिसमें प्लेसहोल्डर होते हैं—और अपने डेटा को उसमें मर्ज करते हैं। यह एप्रोच कई लाभ देता है, जैसे तेज़ विकास, WYSIWYG एडिटिंग आदि। यहाँ एक उपयोगी उदाहरण है जो दर्शाता है कि कैसे C++ लाइब्रेरी का उपयोग करके एक टेम्प्लेट से नए World दस्तावेज़ उत्पन्न किए जा सकते हैं।
C++ लाइब्रेरी के माध्यम से टेम्प्लेट से नया दस्तावेज़ कैसे बनाएं?
#include "minidocx/minidocx.hpp"
#include
int main()
{
using namespace md;
try {
Document doc;
SectionPointer sect = doc.addSection();
ParagraphPointer para = sect->addParagraph();
para->prop_.align_ = Alignment::Centered;
RichTextPointer rich = para->addRichText("Happy Chinese New Year!");
rich->prop_.fontSize_ = 32;
rich->prop_.color_ = "FF0000";
doc.saveAs("a.docx");
}
catch (const Exception& ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}
Word फ़ाइलों में टेबलें जोड़ें
Open source DocxFactory लाइब्रेरी 1D और 2D बारकोड की विस्तृत रेंज को सपोर्ट करती है, जिसमें Code39, Code128, EAN, UPC, ISBN, Databar, पोस्टल कोड, PDF417, Data Matrix, QR Code और Maxi Code शामिल हैं। बारकोड टेम्प्लेट्स में फ़ील्ड के रूप में डाले जाते हैं और आपके द्वारा प्रदान किए गए डेटा के आधार पर स्वचालित रूप से रेंडर होते हैं। यह इन्वेंट्री मैनेजमेंट सिस्टम, शिपिंग और लॉजिस्टिक्स एप्लिकेशन, प्रोडक्ट लेबलिंग समाधान, दस्तावेज़ ट्रैकिंग सिस्टम, रिटेल पॉइंट‑ऑफ़‑सेल इंटीग्रेशन आदि के लिए आदर्श है।
C++ लाइब्रेरी के माध्यम से Word दस्तावेज़ों में उन्नत फ़ॉर्मेटिंग और स्टाइल कैसे लागू करें?
#include "minidocx/minidocx.hpp"
int main()
{
using namespace md;
try {
Document doc;
SectionPointer sect = doc.addSection();
// Create a table with 3 rows and 2 columns
TablePointer table = sect->addTable(3, 2);
// Access and populate cells
// First row - header
auto cell00 = table->cell(0, 0);
auto para00 = cell00->addParagraph();
auto text00 = para00->addRichText("Name");
text00->prop_.bold_ = true;
auto cell01 = table->cell(0, 1);
auto para01 = cell01->addParagraph();
auto text01 = para01->addRichText("Age");
text01->prop_.bold_ = true;
// Second row
auto cell10 = table->cell(1, 0);
auto para10 = cell10->addParagraph();
para10->addRichText("Alice");
auto cell11 = table->cell(1, 1);
auto para11 = cell11->addParagraph();
para11->addRichText("25");
// Third row
auto cell20 = table->cell(2, 0);
auto para20 = cell20->addParagraph();
para20->addRichText("Bob");
auto cell21 = table->cell(2, 1);
auto para21 = cell21->addParagraph();
para21->addRichText("30");
doc.saveAs("table_document.docx");
}
catch (const Exception& ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}
Word DOCX फ़ाइल में चित्र और फ़ोटो डालें
DocxFactory लाइब्रेरी डायनेमिक रूप से चार्ट डेटा को पॉपुलेट कर सकती है, जिससे आप डेटा‑ड्रिवेन विज़ुअलाइज़ेशन बना सकते हैं। आपके टेम्प्लेट में परिभाषित चार्ट डेटा सीरीज़ को प्रोग्रामेटिकली अपडेट किया जा सकता है, जिससे एग्जीक्यूटिव डैशबोर्ड और एनालिटिकल रिपोर्ट्स बनाना संभव हो जाता है। लाइब्रेरी ने Microsoft Word में उपलब्ध 70 से अधिक चार्ट प्रकारों (जैसे Column, Line, Pie, Bar, Area, Scatter, Stock, Surface, Doughnut, Bubble, Radar आदि) को सपोर्ट किया है। यह फीचर रीयल‑टाइम डेटा विज़ुअलाइज़ेशन के साथ डायनेमिक वित्तीय रिपोर्ट, सांख्यिकीय विश्लेषण दस्तावेज़, बिजनेस इंटेलिजेंस डैशबोर्ड, वैज्ञानिक अनुसंधान रिपोर्ट, परफ़ॉर्मेंस ट्रैकिंग डॉक्यूमेंटेशन आदि को सक्षम बनाता है।
How to Insert an Image into a Word Document via C++ library?
#include "minidocx/minidocx.hpp"
int main()
{
using namespace md;
try {
Document doc;
SectionPointer sect = doc.addSection();
// Add a paragraph before the image
ParagraphPointer para1 = sect->addParagraph();
para1->addRichText("Below is an important diagram:");
// Add a paragraph containing the image
ParagraphPointer para2 = sect->addParagraph();
para2->prop_.align_ = Alignment::Centered;
// Insert the picture
PicturePointer pic = para2->addPicture("path/to/image.png");
pic->prop_.width_ = 400;
pic->prop_.height_ = 300;
// Add a paragraph after the image
ParagraphPointer para3 = sect->addParagraph();
para3->addRichText("Figure 1: Important visualization");
doc.saveAs("document_with_image.docx");
}
catch (const Exception& ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}
दस्तावेज़ सेक्शन और पेज लेआउट
Open source DocxFactory लाइब्रेरी Word के नेटिव फ़ॉर्मेटिंग को बनाए रखती है जबकि C++ एप्लिकेशन्स में स्टाइल्स को डायनेमिक रूप से एडजस्ट करती है। इसमें फ़ॉन्ट स्टाइल, साइज, रंग, पैराग्राफ अलाइनमेंट और स्पेसिंग, कस्टम बॉर्डर वाले टेबल, हेडर और फुटर, पेज नंबर और सेक्शन ब्रेक, कस्टम स्टाइल और थीम आदि जैसे विभिन्न फ़ॉर्मेटिंग फ़ीचर शामिल हैं। जनरेट किया गया दस्तावेज़ टेम्प्लेट की सभी फ़ॉर्मेटिंग को संरक्षित रखता है, जिससे ब्रांडिंग लगातार बनी रहती है और पेशेवर लुक मिलता है। निम्न कोड उदाहरण दिखाता है कि डेवलपर्स C++ ऐप्स में डेटा के आधार पर कंडीशनल फ़ॉर्मेटिंग कैसे लागू कर सकते हैं।
How to Work with Multiple Sections of Word Documents via C++ Library?
#include "minidocx/minidocx.hpp"
int main()
{
using namespace md;
try {
Document doc;
// First section with portrait orientation
SectionPointer sect1 = doc.addSection();
sect1->prop_.orientation_ = Orientation::Portrait;
sect1->prop_.pageWidth_ = 8.5 * 1440; // Letter size in twips
sect1->prop_.pageHeight_ = 11 * 1440;
ParagraphPointer para1 = sect1->addParagraph();
para1->addRichText("This is content in portrait orientation.");
// Second section with landscape orientation
SectionPointer sect2 = doc.addSection();
sect2->prop_.orientation_ = Orientation::Landscape;
sect2->prop_.pageWidth_ = 11 * 1440;
sect2->prop_.pageHeight_ = 8.5 * 1440;
ParagraphPointer para2 = sect2->addParagraph();
para2->addRichText("This content appears in landscape orientation.");
doc.saveAs("multi_section_document.docx");
}
catch (const Exception& ex) {
std::cerr << ex.what() << std::endl;
}
return 0;
}