แก้ไขไฟล์ Word หรือ PDF ใน Go SDK

ใช้ REST API เพื่อแก้ไขไฟล์ใน Go โดยทางโปรแกรม

เมื่อนักพัฒนาแก้ไขเอกสารด้วยโซลูชัน Go ที่กำหนด สิ่งที่กำลังแก้ไขจริงๆ คือ Document Object Model (DOM) ดังนั้น การเปลี่ยนแปลงเกือบทั้งหมดในเอกสารที่แสดงเป็น DOM ด้วย Go SDK ที่มีให้ นักพัฒนาสามารถแก้ไขเอกสารได้อย่างง่ายดาย เช่น แก้ไขข้อความ อัปเดตตาราง เพิ่มรูปภาพ และอื่นๆ เพียงโหลด Word, PDF หรือไฟล์ของคุณในรูปแบบการโหลดที่รองรับ ทำการเปลี่ยนแปลงที่จำเป็นโดยทางโปรแกรม และส่งออกผลลัพธ์ไปยังรูปแบบบันทึกที่รองรับ

ดูข้อมูลโค้ด

แก้ไขเอกสารใน Go โดยใช้ REST API

ไลบรารี Go ของเราช่วยให้นักพัฒนาสามารถแก้ไขเอกสารได้โดยตรงโดยการแก้ไข Document Object Model (DOM) ซึ่งหมายความว่าไม่จำเป็นต้องติดตั้งซอฟต์แวร์เพิ่มเติม

สิ่งสำคัญคือต้องรู้ว่าเมื่อใช้โซลูชัน Go นี้ คุณสามารถแก้ไขเอกสารในรูปแบบที่รองรับได้ ตัวอย่างเช่น คุณสามารถโหลดไฟล์ในรูปแบบ PDF, DOCX, DOC, RTF, ODT, EPUB, HTML และรูปแบบอื่นๆ จากนั้นแก้ไขไฟล์นี้และบันทึกในรูปแบบเดียวกันหรือในรูปแบบอื่นๆ ที่รองรับ

แก้ไขข้อความใน Go

กรณีที่นิยมที่สุดในการแก้ไข Word, PDF หรือเอกสารอื่นๆ คือการแก้ไขข้อความ ด้วยโซลูชันซอฟต์แวร์ที่ให้มา คุณสามารถเพิ่ม แก้ไข หรือลบข้อความโดยใช้ Go ภายในเอกสารได้

แก้ไขตารางใน Go

ตัวเลือกการแก้ไขเอกสารยอดนิยมอีกอย่างหนึ่งคือการแก้ไขตาราง Go SDK ของเราช่วยให้คุณทำงานกับตารางและข้อความในเซลล์ตารางได้

นักพัฒนา Go สามารถเพิ่มหรือลบตารางและเซลล์ตาราง ตลอดจนเพิ่ม แก้ไข และลบข้อความภายใน

เพิ่มรูปภาพลงในเอกสารโดยใช้ Go

นอกจากการแก้ไขข้อความและตารางแล้ว ยังมีตัวเลือกทั่วไปอีกตัวเลือกหนึ่ง ได้แก่ การเพิ่มรูปภาพลงในเอกสารใน Go นักพัฒนา Go ยังสามารถเพิ่มรูปภาพลงในไฟล์โดยใช้ DOM

แก้ไขเอกสารออนไลน์

ลองใช้ Go SDK อันทรงพลังนี้และประเมินตัวเลือกบางอย่างในการแก้ไขเอกสาร ใช้ตัวอย่างต่อไปนี้ โหลดเอกสารของคุณ และทำการเปลี่ยนแปลงบางอย่าง: เพิ่มข้อความ เพิ่มตารางและเซลล์ตารางที่มีข้อความ หรือแทรกรูปภาพลงในเอกสาร:

อัปโหลดเอกสารที่คุณต้องการแก้ไข
รันโค้ด
อัปโหลดรูปภาพที่คุณต้องการแทรก
เลือกรูปแบบเป้าหมายจากรายการ
import (
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)

config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

requestDocument, _ := os.Open("Input.docx")
requestParagraph := models.ParagraphInsert{
    Text: ToStringPointer("Morbi enim nunc faucibus a."),
}

insertParagraphOnlineOptions := map[string]interface{}{}
insertParagraphRequest := &models.InsertParagraphOnlineRequest{
    Document: requestDocument,
    Paragraph: &requestParagraph,
    Optionals: insertParagraphOnlineOptions,
}
insertParagraph := wordsApi.InsertParagraphOnline(ctx, insertParagraphRequest)

convertOptions := map[string]interface{}{}
convertRequest := &models.ConvertDocumentRequest{
    Document: insertParagraph.Document.Values[0],
    Format: ToStringPointer("docx"),
    Optionals: convertOptions,
}
convert := wordsApi.ConvertDocument(ctx, convertRequest)
import (
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)

config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

requestDocument, _ := os.Open("Input.docx")
requestTable := models.TableInsert{
    ColumnsCount: ToInt32Pointer(int32(1)),
    RowsCount: ToInt32Pointer(int32(2)),
}

insertTableOnlineOptions := map[string]interface{}{"nodePath": "",}
insertTableRequest := &models.InsertTableOnlineRequest{
    Document: requestDocument,
    Table: &requestTable,
    Optionals: insertTableOnlineOptions,
}
insertTable := wordsApi.InsertTableOnline(ctx, insertTableRequest)

convertOptions := map[string]interface{}{}
convertRequest := &models.ConvertDocumentRequest{
    Document: insertTable.Document.Values[0],
    Format: ToStringPointer("docx"),
    Optionals: convertOptions,
}
convert := wordsApi.ConvertDocument(ctx, convertRequest)
import (
    "os"
    "github.com/aspose-words-cloud/aspose-words-cloud-go/dev/api/models"
)

config, _ := models.NewConfiguration("config.json")
wordsApi, ctx, _ := api.CreateWordsApi(config)

requestDocument, _ := os.Open("Input1.docx")
requestDrawingObject := models.DrawingObjectInsert{
    Height: ToFloat64Pointer(0),
    Left: ToFloat64Pointer(0),
    Top: ToFloat64Pointer(0),
    Width: ToFloat64Pointer(0),
    RelativeHorizontalPosition: ToStringPointer("Margin"),
    RelativeVerticalPosition: ToStringPointer("Margin"),
    WrapType: ToStringPointer("Inline"),
}

requestImageFile, _ := os.Open("Input2.docx")
insertDrawingObjectOnlineOptions := map[string]interface{}{"nodePath": "sections/0",}
insertDrawingObjectRequest := &models.InsertDrawingObjectOnlineRequest{
    Document: requestDocument,
    DrawingObject: &requestDrawingObject,
    ImageFile: requestImageFile,
    Optionals: insertDrawingObjectOnlineOptions,
}
insertDrawingObject := wordsApi.InsertDrawingObjectOnline(ctx, insertDrawingObjectRequest)

convertOptions := map[string]interface{}{}
convertRequest := &models.ConvertDocumentRequest{
    Document: insertDrawingObject.Document.Values[0],
    Format: ToStringPointer("docx"),
    Optionals: convertOptions,
}
convert := wordsApi.ConvertDocument(ctx, convertRequest)
รันโค้ด
  
คัดลอกรหัส Go ไปยังคลิปบอร์ด

วิธีแก้ไขไฟล์ใน Go

  1. ติดตั้ง 'Aspose.Words Cloud สำหรับ Go'
  2. เพิ่มการอ้างอิงไลบรารี (นำเข้าไลบรารี) ไปยัง Go โครงการของคุณ
  3. โหลดเอกสารเพื่อแก้ไขใน Go
  4. แทรกเนื้อหาที่จุดเริ่มต้นของเอกสาร
  5. ดาวน์โหลดเอกสารผลลัพธ์จากที่เก็บข้อมูลบนคลาวด์

Go ห้องสมุดเพื่อใช้แก้ไขเอกสาร

เรียกใช้ go get -v github.com/aspose-words-cloud/aspose-words-cloud-go/2007/api เพื่อติดตั้ง Aspose.Words Cloud SDK for Go คุณสามารถรับข้อมูลที่เป็นประโยชน์มากมายเกี่ยวกับวิธีการติดตั้งอื่นๆ ได้จากส่วน "How to use SDK"

โคลน Aspose.Words Cloud SDK for Go จาก GitHub และใช้ในโครงการของคุณ โปรดปฏิบัติตาม Instructions เหล่านี้เพื่อรับข้อมูลประจำตัวด้านความปลอดภัยที่จำเป็นอย่างรวดเร็วและเข้าถึง REST API ของเรา

ความต้องการของระบบ

อ้างถึง Repository Documentation เพื่อดูรายละเอียด

รูปแบบที่นิยมมากที่สุดสำหรับการดำเนินการแก้ไข

5%

สมัครสมาชิก Aspose Product Updates

รับจดหมายข่าวและข้อเสนอรายเดือนที่ส่งตรงถึงกล่องจดหมายของคุณ