สวัสดีโลก!
“สวัสดีโลก!“รหัสมักจะเป็นตัวอย่างง่ายๆครั้งแรกที่จะเขียนโดยตรง"Aspose.WordsสำหรับC++“และก็ยังสามารถนำมาใช้เป็นการทดสอบสติเพื่อให้แน่ใจว่าซอฟต์แวร์ที่มีวัตถุประสงค์เพื่.
“Aspose.WordsสำหรับC++“ห้องสมุดช่วยให้นักพัฒนาเข้าถึงโดยตรงในการสร้างแก้ไขผสานแปลงเปรียบเทียบคำและเ PDF, DOCX, DOC, RTF, ODT, EPUB, HTML และรูปแบบไฟล์อื่นๆอีกมากมาย รองรับ.
เป็นlow codeตัวอย่างทำตามขั้นตอนเหล่านี้:
- สร้างใหม่ว่างเปล่าDocument
- เริ่มใช้งานคลาสDocumentBuilder
- แทรกข้อความลงในเอกสารเริ่มด้วยวิธีง่ายๆWrite
- เปิดDocumentที่มีอยู่จากแฟ้ม ตรวจหารูปแบบไฟล์โดยอัตโนมัติ
- Appendเอกสาร"A"ไปยังและของเอกสาร"B”
- Saveผลลัพธ์เป็นPDF
ข้อมูลโค้ดต่อไปนี้คือ"สวัสดีโลก!“ตัวอย่างการจัดแสดงการทำงานของ"Aspose.WordsสำหรับC++” API:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C.git. | |
auto docA = MakeObject<Document>(); | |
auto builder = MakeObject<DocumentBuilder>(docA); | |
// Insert text to the document start. | |
builder->MoveToDocumentStart(); | |
builder->Write(u"First Hello World paragraph"); | |
auto docB = MakeObject<Document>(MyDir + u"Document.docx"); | |
// Add document B to the and of document A, preserving document B formatting. | |
docA->AppendDocument(docB, ImportFormatMode::KeepSourceFormatting); | |
docA->Save(ArtifactsDir + u"HelloWorld.SimpleHelloWorld.pdf"); |