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

Added the ability to add a content to the header #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brutu33
Copy link

@brutu33 brutu33 commented Dec 21, 2018

Added the ability to add to the header all the same as in the body of the document except for pagebreak
Calling from code same as simple other commands, but through header object :

docx.header.img ......
docx.header.hr ....
docx.header.h1 .....

Example:

Caracal::Document.render(filename) do |docx|
  docx.header.h1 'Page 1 Header'
  docx.header.img "http://example.com/image.png" do
    width  60
    height 60
    align :right
  end

  docx.header.p "skdanflksamlkdfmlaksd"

  docx.header.table [['11', '1213', '14'], ['21', '22', '23', '24']] do
    cell_style rows[0][0], rowspan: 2
    cell_style rows[0][1], colspan: 2
    cell_style rows[0][2], rowspan: 2
  end

  docx.header.p do
    text 'Here is a sentence with a '
    link 'link', 'https://www.google.com'
    text ' to something awesome', font: 'Courier New', color: '555555', size: 32, bold: true, italic: true, underline: true, bgcolor: 'cccccc'
    text '.'
    br
    text 'This text follows a line break and uses a character style instead of overrides.', style: 'MyCharStyle'
    page
  end

  docx.header.ol do
    li 'First item'
    li do
      text 'Second item with a '
      link 'link', "http://example.com/image.png"
      text '.'
      br
      text 'This sentence follows a line break.'
    end
  end

  docx.header.hr
end

@jdugan
Copy link
Contributor

jdugan commented Dec 30, 2018

Hei! Thanks for this.

I'm on holiday right now, so I haven't had a chance to look at your commit closely (or even quickly, if I'm being honest), but your description is in line with the thoughts I outlined in the pending issue, so I'll be interested to review the changes when I'm back at my desk.

I'll be in touch.

@allomov
Copy link

allomov commented Jul 3, 2019

Hey, @jdugan. Could you please take a look on this PR and give you feedback? Thank you.

@Passerby
Copy link

+1

@benjaminketron
Copy link

Hi @jdugan, :)

Is there anything i can do to help this PR along?

goulvench pushed a commit to goulvench/caracal that referenced this pull request Mar 24, 2020
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

Successfully merging this pull request may close these issues.

5 participants