unidoc / unioffice

Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents
https://unidoc.io/unioffice/
Other
4.36k stars 473 forks source link

Unable to save after manipulating a document with embedded image #452

Closed Trimeego closed 2 years ago

Trimeego commented 3 years ago

Description

I am trying to use unioffice to open an existing document with and embedded image in the header and perform a mail merge and save, however, the after performing the merge, I am unable to save the document with the following returned error.

unsupported image source: {_cgd:<nil> _bgdf:{_bgfb:<nil>} _ebf:{Size:{X:0 Y:0} Format: Path: Data:<nil>} _agb: _eca:word/media/image2.}

The document is viewable in Word. Given the error above, it would seem that the image is getting embedded but is losing the file extension.

If I remove the image in the header, the document processes normally.

Expected Behavior

I would expect the document to be able to load, as Word does.

Actual Behavior

Using the attached file above:


err := license.SetLicenseKey(licenseKey, customerName)
if err != nil {
    panic(err)
}

doc, err := document.Open(filePath)
if err != nil {
    panic(err)
}

    doc.MailMerge(context) // context is a valid map[string]string

err = doc.TemplateDocument.Save(writer)
    if err != nil {
    panic(err) // Error returned here.
}

US_Foods_Vendor_Agreement.docx

I am able to control the documents, so if there is a remediation that can be done in word, that would be fine.

github-actions[bot] commented 3 years ago

Welcome! Thanks for posting your first issue. The way things work here is that while customer issues are prioritized, other issues go into our backlog where they are assessed and fitted into the roadmap when suitable. If you need to get this done, consider buying a license which also enables you to use it in your commercial products. More information can be found on https://unidoc.io/

Trimeego commented 3 years ago

Upon further investigation, the issue is limited to images in the header. Using the same image as a source, when inserted in the body of the document, no error is encountered when performing a mail merge. With the same image inserted into the header, the error is encountered, even though Word clearly has the proper imageref.

gunnsth commented 2 years ago

This was fixed in release v1.14.0.