Code Monkey home page Code Monkey logo

Comments (7)

github-actions avatar github-actions commented on July 26, 2024

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/

from unioffice.

sampila avatar sampila commented on July 26, 2024

Hi @sagar-kalburgi-ripcord,

You need to use function document.Open instead the document.OpenTemplate, as the document.OpenTemplate will maintain the styles that being used.

from unioffice.

sagar-kalburgi-ripcord avatar sagar-kalburgi-ripcord commented on July 26, 2024

Thanks for the clarification! I'll try this out and respond

from unioffice.

sagar-kalburgi-ripcord avatar sagar-kalburgi-ripcord commented on July 26, 2024

Hi @sampila

Thanks, your suggestion worked. I have a question, so this program works

 
doc, err := document.OpenTemplate("demo.docx")
if err != nil {
log.Fatalf("error opening document template: %s", err)
}

fmt.Println("Size: ", doc.BodySection().X().PgSz)

And the output it prints is

Size: &{12240 15840 <nil>}

I suppose 12240 is the width of any page of the document in twips and 15840 is the height of any page in the document in twips?

But if I try to print doc.BodySection().X().PgSz.WAttr.ST_UnsignedDecimalNumber it prints a hexadecimal number 0x140002f68f0. How is this value related to 12240?

from unioffice.

sampila avatar sampila commented on July 26, 2024

Hi @sagar-kalburgi-ripcord,

the when you are print the doc.BodySection().X().PgSz.WAttr.ST_UnsignedDecimalNumber and it is showing hexadecimal number, that's actually the address value, as it is pointer, to print the integer value, you can use

if pgSize := doc.BodySection().X().PgSz; pgSize != nil {
	if pgSize.WAttr != nil && pgSize.WAttr.ST_UnsignedDecimalNumber != nil {
		fmt.Println("Size: ", *pgSize.WAttr.ST_UnsignedDecimalNumber)
	}
}

from unioffice.

sagar-kalburgi-ripcord avatar sagar-kalburgi-ripcord commented on July 26, 2024

Oh I see my bad, makes sense thanks!

from unioffice.

sampila avatar sampila commented on July 26, 2024

You are welcome.
Looks like this issue solved, we closing this issue now, you can re-open this issue if you are still having problem with this issue.

from unioffice.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.