Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Conversation

TBouder
Copy link

@TBouder TBouder commented Sep 6, 2019

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

@CLAassistant
Copy link

CLAassistant commented Sep 6, 2019

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link

codecov bot commented Sep 6, 2019

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%) ⬆️

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.

Copy link
Contributor

@zgordan-vv zgordan-vv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok

go.mod Outdated Show resolved Hide resolved
Copy link
Contributor

@gunnsth gunnsth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove go.mod file

@gunnsth
Copy link
Contributor

gunnsth commented Nov 18, 2019

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

@gunnsth gunnsth added the pending Awaiting feedback label Nov 18, 2019
@gunnsth
Copy link
Contributor

gunnsth commented Dec 4, 2019

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

@ahall
Copy link

ahall commented Dec 12, 2019

@TBouder have you had a chance to finish this?

@JamesBlackman-SLG
Copy link

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

@sampila
Copy link
Collaborator

sampila commented Jan 20, 2023

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

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Jan 20, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Jan 20, 2023

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")

}

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Jan 20, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Jan 20, 2023 via email

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Jan 20, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Jan 20, 2023

Hi @JamesBlackman-SLG,

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

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Jan 20, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Jan 21, 2023

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

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Jan 23, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Jan 31, 2023

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?

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Feb 1, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Feb 4, 2023

Hi @JamesBlackman-SLG,

Have you tried to solution that we replied in email?

@JamesBlackman-SLG
Copy link

JamesBlackman-SLG commented Feb 6, 2023 via email

@sampila
Copy link
Collaborator

sampila commented Feb 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending Awaiting feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants