unioffice icon indicating copy to clipboard operation
unioffice copied to clipboard

Fix "Found Unreadable Content" issue when adding an image in the header

Open TBouder opened this issue 6 years ago • 21 comments

Hi !

When you try to add an image in the header, this error appear.

Capture d’écran 2019-09-06 à 21 21 23

We need to ensure the formats for the images


This change is Reviewable

TBouder avatar Sep 06 '19 19:09 TBouder

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Sep 06 '19 19:09 CLAassistant

Codecov Report

Merging #321 into master will increase coverage by 0.01%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #321      +/-   ##
==========================================
+ Coverage    54.7%   54.71%   +0.01%     
==========================================
  Files         199      199              
  Lines       16918    16923       +5     
==========================================
+ Hits         9255     9260       +5     
  Misses       6871     6871              
  Partials      792      792
Impacted Files Coverage Δ
document/header.go 62.9% <100%> (+3.25%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dc34147...e1514c4. Read the comment docs.

codecov[bot] avatar Sep 06 '19 19:09 codecov[bot]

@TBouder Can you please address the comments (removing changed go.mod) file?

gunnsth avatar Nov 18 '19 21:11 gunnsth

@TBouder Sorry. What I ment was not to delete/remove it, but undo the changes made to it (go.mod).

gunnsth avatar Dec 04 '19 18:12 gunnsth

@TBouder have you had a chance to finish this?

ahall avatar Dec 12 '19 17:12 ahall

Any update on this? I'm getting the error "Word found unreadable content..." when putting an image in the header.

JamesBlackman-SLG avatar Jan 19 '23 14:01 JamesBlackman-SLG

Any update on this? I'm getting the error "Word found unreadable content..." when putting an image in the header.

Hi @JamesBlackman-SLG, Could you share a runnable code snippet for this issue?

Best regards, Alip

sampila avatar Jan 20 '23 09:01 sampila

Thanks for getting back to me so quickly.

Code example below. Variables for filePath and templatePath can just be set to “./” for this example. I’ve not shared my key for obvious reasons 😊

This works on my local environment (windows) and works when I run through Docker on my local Docker for Windows instance. Only fails when I run on Azure Docker. It creates a test.docx file locally which is 111KB but on my Azure Docker it creates a test.docx file which is only 5,913 bytes and will not open…

No errors appear about the document location / file location so really stumped?

Running go 1.19 in both environments.

Thanks

/*

  • This example showcases PDF generation from docx document with UniOffice package. */

package main

import ( "fmt" "log" "os"

"github.com/unidoc/unioffice/common"
"github.com/unidoc/unioffice/common/license"
"github.com/unidoc/unioffice/document"
"github.com/unidoc/unioffice/measurement"
"github.com/unidoc/unioffice/schema/soo/wml"

)

var ( filePath, _ = os.LookupEnv("FILEPATH") templatePath, _ = os.LookupEnv("TEMPLATE_PATH") key, _ = os.LookupEnv("KEY") ) var filename = "test"

func main() { // This example requires both for unioffice and unipdf. err := license.SetMeteredKey(key) if err != nil { fmt.Printf("ERROR: Failed to set metered key: %v\n", err) fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\nhttps://cloud.unidoc.io/n") fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\nhttps://cloud.unidoc.io/n") panic(err) } exportEstimateToWordTest() }

func exportEstimateToWordTest() { doc := document.New() defer doc.Close()

img, err := common.ImageFromFile(templatePath + "/logo.png")
if err != nil {
    log.Fatalf("unable to create image: %s", err)
}

hdr := doc.AddHeader()
iref, err := hdr.AddImage(img)
if err != nil {
    log.Fatalf("unable to to add image to document: %s", err)
}
section := doc.BodySection()
section.SetPageSizeAndOrientation(measurement.Inch*8.3, measurement.Inch*11.7, wml.ST_PageOrientationPortrait)
para := hdr.AddParagraph()

imgInl, _ := para.AddRun().AddDrawingInline(iref)

imgInl.SetSize(8*measurement.Inch, 1.27*measurement.Inch)

doc.BodySection().SetPageMargins(
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0.2*measurement.Inch),
    measurement.Distance(0*measurement.Inch),
)
doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)

para = doc.AddParagraph()
run := para.AddRun()

run.Properties().SetBold(true)
run.Properties().SetFontFamily("Montserrat")
run.Properties().SetSize(13)
run.AddText("Some body text")

// Save the document
doc.SaveToFile(filePath + "/" + filename + ".docx")

}

From: Alip Sulistio @.> Sent: 20 January 2023 09:01 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Any update on this? I'm getting the error "Word found unreadable content..." when putting an image in the header.

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG, Could you share a runnable code snippet for this issue?

Best regards, Alip

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1398092163, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6FL4OY7OOWWD3RV2L3WTJH6FANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Jan 20 '23 12:01 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

I tried the code locally and couldn't reproduce the issue. Also on local, did you use same image file that exists on server? Probably can try to set the logger for UniOffice and see if there's an information about it.

For using the logger simply use like this

// Set UniOffice logger.
logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

Full code

/*
 * This example showcases PDF generation from docx document with UniOffice package.
 */

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/unidoc/unioffice/common"
	"github.com/unidoc/unioffice/common/license"
	"github.com/unidoc/unioffice/common/logger"
	"github.com/unidoc/unioffice/document"
	"github.com/unidoc/unioffice/measurement"
	"github.com/unidoc/unioffice/schema/soo/wml"
)

var (
    filePath, _     = os.LookupEnv("FILEPATH")
    templatePath, _ = os.LookupEnv("TEMPLATE_PATH")
    key, _          = os.LookupEnv("KEY")
)
var filename = "test"

func main() {
	// This example requires both for unioffice and unipdf.
	err := license.SetMeteredKey(key)
	if err != nil {
		fmt.Printf("ERROR: Failed to set metered key: %v\n", err)
		fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n<https://cloud.unidoc.io/n>")
		fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n<https://cloud.unidoc.io/n>")
		panic(err)
	}

	// Set UniOffice logger.
	logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

	exportEstimateToWordTest()
}

func exportEstimateToWordTest() {
	doc := document.New()
	defer doc.Close()

	img, err := common.ImageFromFile(templatePath + "/logo.png")
	if err != nil {
		log.Fatalf("unable to create image: %s", err)
	}

	hdr := doc.AddHeader()
	iref, err := hdr.AddImage(img)
	if err != nil {
		log.Fatalf("unable to to add image to document: %s", err)
	}
	section := doc.BodySection()
	section.SetPageSizeAndOrientation(measurement.Inch*8.3, measurement.Inch*11.7, wml.ST_PageOrientationPortrait)
	para := hdr.AddParagraph()

	imgInl, _ := para.AddRun().AddDrawingInline(iref)

	imgInl.SetSize(8*measurement.Inch, 1.27*measurement.Inch)

	doc.BodySection().SetPageMargins(
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0.2*measurement.Inch),
		measurement.Distance(0*measurement.Inch),
	)
	doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)

	para = doc.AddParagraph()
	run := para.AddRun()

	run.Properties().SetBold(true)
	run.Properties().SetFontFamily("Montserrat")
	run.Properties().SetSize(13)
	run.AddText("Some body text")

	// Save the document
	doc.SaveToFile(filePath + "/" + filename + ".docx")

}

sampila avatar Jan 20 '23 13:01 sampila

Yes it’s the same .png file being used in both environments.

I’ve enabled the logger – nothing is being reported to the console.

From: Alip Sulistio @.> Sent: 20 January 2023 13:05 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

I tried the code locally and couldn't reproduce the issue. Also on local, did you use same image file that exists on server? Probably can try to set the logger for UniOffice and see if there's an information about it.

For using the logger simply use like this

// Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

Full code

/*

  • This example showcases PDF generation from docx document with UniOffice package.

*/

package main

import (

    "fmt"

    "log"

    "os"



    "github.com/unidoc/unioffice/common"

    "github.com/unidoc/unioffice/common/license"

    "github.com/unidoc/unioffice/common/logger"

    "github.com/unidoc/unioffice/document"

    "github.com/unidoc/unioffice/measurement"

    "github.com/unidoc/unioffice/schema/soo/wml"

)

var (

filePath, _     = os.LookupEnv("FILEPATH")

templatePath, _ = os.LookupEnv("TEMPLATE_PATH")

key, _          = os.LookupEnv("KEY")

)

var filename = "test"

func main() {

    // This example requires both for unioffice and unipdf.

    err := license.SetMeteredKey(key)

    if err != nil {

           fmt.Printf("ERROR: Failed to set metered key: %v\n", err)

           fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n<https://cloud.unidoc.io/n<https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

           fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n<https://cloud.unidoc.io/n<https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

           panic(err)

    }



    // Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

    exportEstimateToWordTest()

}

func exportEstimateToWordTest() {

    doc := document.New()

    defer doc.Close()



    img, err := common.ImageFromFile(templatePath + "/logo.png")

    if err != nil {

           log.Fatalf("unable to create image: %s", err)

    }



    hdr := doc.AddHeader()

    iref, err := hdr.AddImage(img)

    if err != nil {

           log.Fatalf("unable to to add image to document: %s", err)

    }

    section := doc.BodySection()

section.SetPageSizeAndOrientation(measurement.Inch8.3, measurement.Inch11.7, wml.ST_PageOrientationPortrait)

    para := hdr.AddParagraph()



    imgInl, _ := para.AddRun().AddDrawingInline(iref)



    imgInl.SetSize(8*measurement.Inch, 1.27*measurement.Inch)



    doc.BodySection().SetPageMargins(

            measurement.Distance(0.2*measurement.Inch),

            measurement.Distance(0.2*measurement.Inch),

            measurement.Distance(0.2*measurement.Inch),

            measurement.Distance(0.2*measurement.Inch),

            measurement.Distance(0.2*measurement.Inch),

            measurement.Distance(0.2*measurement.Inch),

           measurement.Distance(0*measurement.Inch),

    )

    doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)



    para = doc.AddParagraph()

    run := para.AddRun()



    run.Properties().SetBold(true)

    run.Properties().SetFontFamily("Montserrat")

    run.Properties().SetSize(13)

    run.AddText("Some body text")



    // Save the document

    doc.SaveToFile(filePath + "/" + filename + ".docx")

}

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1398349043, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6GX3NK3OQXQPTU7II3WTKEOHANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Jan 20 '23 14:01 JamesBlackman-SLG

Could you share the logo file and results from your azure server?

On Fri, Jan 20, 2023, 9:27 PM JamesBlackman-SLG @.***> wrote:

Yes it’s the same .png file being used in both environments.

I’ve enabled the logger – nothing is being reported to the console.

From: Alip Sulistio @.> Sent: 20 January 2023 13:05 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

I tried the code locally and couldn't reproduce the issue. Also on local, did you use same image file that exists on server? Probably can try to set the logger for UniOffice and see if there's an information about it.

For using the logger simply use like this

// Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

Full code

/*

  • This example showcases PDF generation from docx document with UniOffice package.

*/

package main

import (

"fmt"

"log"

"os"

"github.com/unidoc/unioffice/common"

"github.com/unidoc/unioffice/common/license"

"github.com/unidoc/unioffice/common/logger"

"github.com/unidoc/unioffice/document"

"github.com/unidoc/unioffice/measurement"

"github.com/unidoc/unioffice/schema/soo/wml"

)

var (

filePath, _ = os.LookupEnv("FILEPATH")

templatePath, _ = os.LookupEnv("TEMPLATE_PATH")

key, _ = os.LookupEnv("KEY")

)

var filename = "test"

func main() {

// This example requires both for unioffice and unipdf.

err := license.SetMeteredKey(key)

if err != nil {

fmt.Printf("ERROR: Failed to set metered key: %v\n", err)

fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n< https://cloud.unidoc.io/n< https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n<https://cloud.unidoc.io/n< https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

panic(err)

}

// Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

exportEstimateToWordTest()

}

func exportEstimateToWordTest() {

doc := document.New()

defer doc.Close()

img, err := common.ImageFromFile(templatePath + "/logo.png")

if err != nil {

log.Fatalf("unable to create image: %s", err)

}

hdr := doc.AddHeader()

iref, err := hdr.AddImage(img)

if err != nil {

log.Fatalf("unable to to add image to document: %s", err)

}

section := doc.BodySection()

section.SetPageSizeAndOrientation(measurement.Inch8.3, measurement.Inch11.7, wml.ST_PageOrientationPortrait)

para := hdr.AddParagraph()

imgInl, _ := para.AddRun().AddDrawingInline(iref)

imgInl.SetSize(8measurement.Inch, 1.27measurement.Inch)

doc.BodySection().SetPageMargins(

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0*measurement.Inch),

)

doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)

para = doc.AddParagraph()

run := para.AddRun()

run.Properties().SetBold(true)

run.Properties().SetFontFamily("Montserrat")

run.Properties().SetSize(13)

run.AddText("Some body text")

// Save the document

doc.SaveToFile(filePath + "/" + filename + ".docx")

}

— Reply to this email directly, view it on GitHub< https://github.com/unidoc/unioffice/pull/321#issuecomment-1398349043>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/AUAUN6GX3NK3OQXQPTU7II3WTKEOHANCNFSM4IUMJB3Q>.

You are receiving this because you were mentioned.Message ID: @.@.>>

— Reply to this email directly, view it on GitHub https://github.com/unidoc/unioffice/pull/321#issuecomment-1398468417, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZYNI4JISSUSZ3DDQUCQOLWTKOFXANCNFSM4IUMJB3Q . You are receiving this because you commented.Message ID: @.***>

sampila avatar Jan 20 '23 14:01 sampila

Attached is the document created on production which is corrupted and the logo file.

From: Alip Sulistio @.> Sent: 20 January 2023 14:32 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Could you share the logo file and results from your azure server?

On Fri, Jan 20, 2023, 9:27 PM JamesBlackman-SLG @.***mailto:***@***.***> wrote:

Yes it’s the same .png file being used in both environments.

I’ve enabled the logger – nothing is being reported to the console.

From: Alip Sulistio @.mailto:***@***.***> Sent: 20 January 2023 13:05 To: unidoc/unioffice @.mailto:***@***.***> Cc: James Blackman @.mailto:***@***.***>; Mention @.mailto:***@***.***> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

I tried the code locally and couldn't reproduce the issue. Also on local, did you use same image file that exists on server? Probably can try to set the logger for UniOffice and see if there's an information about it.

For using the logger simply use like this

// Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

Full code

/*

  • This example showcases PDF generation from docx document with UniOffice package.

*/

package main

import (

"fmt"

"log"

"os"

"github.com/unidoc/unioffice/common"

"github.com/unidoc/unioffice/common/license"

"github.com/unidoc/unioffice/common/logger"

"github.com/unidoc/unioffice/document"

"github.com/unidoc/unioffice/measurement"

"github.com/unidoc/unioffice/schema/soo/wml"

)

var (

filePath, _ = os.LookupEnv("FILEPATH")

templatePath, _ = os.LookupEnv("TEMPLATE_PATH")

key, _ = os.LookupEnv("KEY")

)

var filename = "test"

func main() {

// This example requires both for unioffice and unipdf.

err := license.SetMeteredKey(key)

if err != nil {

fmt.Printf("ERROR: Failed to set metered key: %v\n", err)

fmt.Printf("Make sure to get a valid key from https://cloud.unidoc.io\n<https://cloud.unidoc.io/n%3c https://cloud.unidoc.io/n<https://cloud.unidoc.io/n%3c https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

fmt.Printf("If you don't have one - Grab one in the Free Tier at https://cloud.unidoc.io\n<https://cloud.unidoc.io/n<https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n%3c https://cloud.unidoc.io/n%3chttps:/cloud.unidoc.io/n>>")

panic(err)

}

// Set UniOffice logger.

logger.SetLogger(logger.NewConsoleLogger(logger.LogLevelDebug))

exportEstimateToWordTest()

}

func exportEstimateToWordTest() {

doc := document.New()

defer doc.Close()

img, err := common.ImageFromFile(templatePath + "/logo.png")

if err != nil {

log.Fatalf("unable to create image: %s", err)

}

hdr := doc.AddHeader()

iref, err := hdr.AddImage(img)

if err != nil {

log.Fatalf("unable to to add image to document: %s", err)

}

section := doc.BodySection()

section.SetPageSizeAndOrientation(measurement.Inch8.3, measurement.Inch11.7, wml.ST_PageOrientationPortrait)

para := hdr.AddParagraph()

imgInl, _ := para.AddRun().AddDrawingInline(iref)

imgInl.SetSize(8measurement.Inch, 1.27measurement.Inch)

doc.BodySection().SetPageMargins(

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0.2*measurement.Inch),

measurement.Distance(0*measurement.Inch),

)

doc.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)

para = doc.AddParagraph()

run := para.AddRun()

run.Properties().SetBold(true)

run.Properties().SetFontFamily("Montserrat")

run.Properties().SetSize(13)

run.AddText("Some body text")

// Save the document

doc.SaveToFile(filePath + "/" + filename + ".docx")

}

— Reply to this email directly, view it on GitHub< https://github.com/unidoc/unioffice/pull/321#issuecomment-1398349043>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/AUAUN6GX3NK3OQXQPTU7II3WTKEOHANCNFSM4IUMJB3Q>.

You are receiving this because you were mentioned.Message ID: @.@.mailto:***@***.******@***.***>>

— Reply to this email directly, view it on GitHub https://github.com/unidoc/unioffice/pull/321#issuecomment-1398468417, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADZYNI4JISSUSZ3DDQUCQOLWTKOFXANCNFSM4IUMJB3Q . You are receiving this because you commented.Message ID: @.***mailto:***@***.***>

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1398473250, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6CQC5KUE4YY3MVXGMDWTKOVLANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Jan 20 '23 14:01 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

I am unable to find the attached file, probably can send it into email [email protected] for the files?

sampila avatar Jan 20 '23 16:01 sampila

Thanks – I’ve emailed the file to this address.

From: Alip Sulistio @.> Sent: 20 January 2023 16:20 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

I am unable to find the attached file, probably can send it into email @.@.> for the files?

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1398622158, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6H4A7XV4YZGDMETO4DWTK3MXANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Jan 20 '23 17:01 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

When I inspecting your DOCX file, looks like the image is broken, can you try to download the image from server and see if the image is not broken? or try to use another image on server and see if the results is correct.

Screenshot 2023-01-21 at 16 33 41

sampila avatar Jan 21 '23 09:01 sampila

I’ve checked the file, have even added an http method which reads the file and returns it successfully :

Just seems to be an issue when adding it to the header of the doc?

func main() { http.HandleFunc("/fs/pdf_download", handlePdfDownload) http.HandleFunc("/fs/logo_download", handleLogoDownload) http.ListenAndServe(":8087", nil) }

func handleLogoDownload(w http.ResponseWriter, req *http.Request) { fmt.Println(templatePath) file, err := os.Open(templatePath + "/logo.png") if err != nil { http.Error(w, "Error opening file", http.StatusInternalServerError) return } defer file.Close()

w.Header().Set("Content-Type", "image/png")
io.Copy(w, file)

}

From: Alip Sulistio @.> Sent: 21 January 2023 09:36 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

When I inspecting your DOCX file, looks like the image are broken, can you try to download the image from server and see if the image is not broken? or try to use another image on server and see if the results is correct.

[Screenshot 2023-01-21 at 16 33 41]https://user-images.githubusercontent.com/15959715/213861078-46b0d38a-f039-4e49-b319-6a1259405343.png

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1399216969, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6BYHMFPIL3QJALVCIDWTOUZJANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Jan 23 '23 09:01 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

Yes, it is unable to add the correct content types of image as the image is broken when being added to DOCX. Could you share the image that you use and the correct DOCX that you are generated locally?

sampila avatar Jan 31 '23 16:01 sampila

Hi, Attached are the two docx files – one on my local windows environment (32) and the other running in Docker on a linux container (33).

I’ve switched to using the gophercolor.png as supplied in your examples folder. Still doesn’t work so this is not related to the image file.

I can only think that it’s something to do with accessing the file but go would complain and trigger error if that was the case?

My client is now starting to doubt if this is the right solution, as we are now on a pay as you go arrangement I really need to get this working or will have to try something else.

p.s. I have noticed another issue when converting this docx to a pdf using unipdf. The contents of the document (the body containing all of the tables) does not get included in the pdf?

Regards,

James

From: Alip Sulistio @.> Sent: 31 January 2023 16:08 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

Yes, it is unable to add the correct content types of image as the image is broken when being added to DOCX. Could you share the image that you use and the correct DOCX that you are generated locally?

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1410656466, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6AWEU5Z24S7EVHEAS3WVE2EPANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Feb 01 '23 09:02 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

Have you tried to solution that we replied in email?

sampila avatar Feb 04 '23 18:02 sampila

Hi Alip,

Success 😊

The different approach has worked. Thanks for this.

My last issue is related to converting the docx file to a pdf using unidoc library as below.

github.com/unidoc/unioffice/document/convert

When I do this, the PDF document only has the logo – nothing else appears in the document at all.

    wordDocFile, err := document.Open(filePath + "/" + filename + ".docx")
    if err != nil {
        log.Fatalf("error opening document: %s", err)
    }
    defer wordDocFile.Close()
    outputPath := fmt.Sprintf("%s/%s.pdf", filePath, filename)
    c := convert.ConvertToPdf(wordDocFile)

    err = c.WriteToFile(outputPath)
    if err != nil {
        log.Fatalf("error converting document: %s", err)
    }

    pdfFile, err := ioutil.ReadFile(outputPath)
    if err != nil {
        log.Fatalf("error opening document: %s", err)
    }
    w.Write(pdfFile)

See screenshot showing both documents side by side. The word doc is multiple pages, whereas the pdf is only one page with the header image and no content. @.*** From: Alip Sulistio @.> Sent: 04 February 2023 18:01 To: unidoc/unioffice @.> Cc: James Blackman @.>; Mention @.> Subject: Re: [unidoc/unioffice] Fix "Found Unreadable Content" issue when adding an image in the header (#321)

Hi @JamesBlackman-SLGhttps://github.com/JamesBlackman-SLG,

Have you tried to solution that we replied in email?

— Reply to this email directly, view it on GitHubhttps://github.com/unidoc/unioffice/pull/321#issuecomment-1416813349, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AUAUN6FTBUIYMTUTCBJ6OXTWV2KODANCNFSM4IUMJB3Q. You are receiving this because you were mentioned.Message ID: @.@.>>

JamesBlackman-SLG avatar Feb 06 '23 11:02 JamesBlackman-SLG

Hi @JamesBlackman-SLG,

Glad to hear that.

Could you share the DOCX file that you are trying to convert into PDF and the PDF convert results? You can send it to email [email protected] Thanks

sampila avatar Feb 06 '23 11:02 sampila