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

Unable to figure out how to set page margins on document #165

Closed
srinathh opened this issue Mar 1, 2018 · 3 comments
Closed

Unable to figure out how to set page margins on document #165

srinathh opened this issue Mar 1, 2018 · 3 comments

Comments

@srinathh
Copy link
Contributor

srinathh commented Mar 1, 2018

Description

I am unable to figure out how to set page margins on document. I would like to set margins of the generated document to 0.5 inch

I managed to follow the rabbit hole of XML down to doc.X().Body.SectPr.PgMar.TopAttr but then there's a pointer to an int64 which i'm not able to set. When I try to retrieve the object, I get a null pointer error.

@tbaliance
Copy link
Contributor

@srinathh I'll add this to my TODO to make a helper method, but for now you'll need to create the int64 yourself. Look at this AddTabStop method for reference gooxml.Int64 just creates a pointer to an int64, and the measurement stuff is used for translating distance units.

  // AddTabStop adds a tab stop to the paragraph.
  func (p ParagraphStyleProperties) AddTabStop(position measurement.Distance, justificaton wml.ST_TabJc, leader w  ml.ST_TabTlc) {
          if p.x.Tabs == nil {
                  p.x.Tabs = wml.NewCT_Tabs()
          }
          tab := wml.NewCT_TabStop()
          tab.LeaderAttr = leader
          tab.ValAttr = justificaton
          tab.PosAttr.Int64 = gooxml.Int64(int64(position / measurement.Twips))
          p.x.Tabs.Tab = append(p.x.Tabs.Tab, tab)
  }

@srinathh
Copy link
Contributor Author

srinathh commented Mar 2, 2018

Thanks! I've created a helper function to set margins based on your code & sent a pull request.

@tbaliance
Copy link
Contributor

Great, thanks! I'll merge it soon.

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

No branches or pull requests

2 participants