Closed sagar-kalburgi-ripcord closed 12 months 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/
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.
Thanks for the clarification! I'll try this out and respond
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?
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)
}
}
Oh I see my bad, makes sense thanks!
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.
Description
demo.docx
I want to be able to get the page size of a word doc using Unidoc.
Expected Behavior
This code is supposed to print the page size of the document.
Note: Please find the demo.docx attached.
Actual Behavior
The code above returns nil for page size. In fact, it returns a nil for each and every field in the struct https://apidocs.unidoc.io/unioffice/v1.21.0/github.com/unidoc/unioffice/schema/soo/wml/#CT_SectPr