Code Monkey home page Code Monkey logo

Comments (4)

fran-worley avatar fran-worley commented on July 24, 2024 1

This list is not comprehensive or tested, but I have looked through the source code, and readme and come up with the following:

Page formatting options:

Check out: https://github.com/karnov/htmltoword/blob/master/lib/htmltoword/xslt/base.xslt

Page Break (included in readme)

<div class="-page-break"></div>

Returns a page break

Highlighting (included in readme)

<span class="h" data-style="chosen-color">Highlighted Text Here</span>

Will highlight text

As per: http://www.schemacentral.com/sc/ooxml/t-w_ST_HighlightColor.html these are your color choices

Valid value Description
black Black Highlighting Color
blue Blue Highlighting Color
cyan Cyan Highlighting Color
green Green Highlighting Color
magenta Magenta Highlighting Color
red Red Highlighting Color
yellow Yellow Highlighting Color
white White Highlighting Color
darkBlue Dark Blue Highlighting Color
darkCyan Dark Cyan Highlighting Color
darkGreen Dark Green Highlighting Color
darkMagenta Dark Magenta Highlighting Color
darkRed Dark Red Highlighting Color
darkYellow Dark Yellow Highlighting Color
darkGray Dark Gray Highlighting Color
lightGray Light Gray Highlighting Color
none No Text Highlighting

Text Align (not in readme)

It looks like adding the following classes will align text in your word document appropriately.

  • left
  • right
  • center
  • justify

HTML tags

There is also support for the following HTML tags:

  • div
  • p
  • ul/ol, li
  • b/strong
  • i/em
  • u
  • br
  • pre
  • h1...h6

Images

It appears that at this time images are not supported see #27

External links

It appears that this isn't supported either yet, though there is an open pull request to add the functionality see #30

Table formatting options

As per this: https://github.com/karnov/htmltoword/blob/master/lib/htmltoword/xslt/tables.xslt

There is basic support for tables.

You can use the following HTML tags:

  • thead
  • tbody
  • tr
  • th
  • td
  • h1...h6

And the following classes:

  • Text alignment: (as above)
  • Table borders: 'table-bordered' (Not configurable, the default is a black, single line border with a weight of 6)
  • Cell borders: 'ms-border-[location]-[value]-[color - default is 000000]-[size - default is 1]'
  • Cell fill: 'ms-fill-[color]'

The following are documented here: http://officeopenxml.com/WPtableCellProperties-Borders.php I do not know exactly how much of these options work in the gem, but it should at least point you in the right direction

[location]

Specifies where to apply the border (see Elements table in officeopenxml docs above)

Element Description
top Specifies the border displayed at the top of the cell.
bottom Specifies the border displayed at the bottom of a cell.
start Specifies the border displayed on the leading edge of the cell (left for left-to-right tables and right for right-to-left tables). Note: In the previous version of the standard, this element was left.
end Specifies the border displayed on the trailing edge of the cell (right for left-to-right tables and left for right-to-left tables). Note: In the previous version of the standard, this element was right.
insideH Specifies the border to be displayed on all interior horizontal edges of the cell. Note that this is mostly useless in the case of individual cells, as there is no concept of interior edge for individual cells. However, it is used to determine cell borders to apply to a specific group of cells as part of table conditional formatting in a table style, e.g., the inside edges on the set of cells in the first column.
insideV Specifies the border to be displayed on all interior vertical edges of the cell. Note that this is mostly useless in the case of individual cells, as there is no concept of interior edge for individual cells. However, it is used to determine cell borders to apply to a specific group of cells as part of table conditional formatting in a table style, e.g., the inside edges on the set of cells in the first column.
tl2br Specifies the border to be displayed on the top left side to bottom right diagonal within the cell.
tr2bl Specifies the border to be displayed on the top right to bottom left diagonal within the cell.

[value]

Specifies the style of the border. Possible values a per open XML docs are:

Value Description
single a single line
dashDotStroked a line with a series of alternating thin and thick strokes
dashed a dashed line
dashSmallGap a dashed line with small gaps
dotDash a line with alternating dots and dashes
dotDotDash a line with a repeating dot - dot - dash sequence
dotted a dotted line
double a double line
doubleWave a double wavy line
inset an inset set of lines
nil no border
none no border
outset an outset set of lines
thick a single line
thickThinLargeGap a thick line contained within a thin line with a large-sized intermediate gap
thickThinMediumGap a thick line contained within a thin line with a medium-sized intermediate gap
thickThinSmallGap a thick line contained within a thin line with a small intermediate gap
thinThickLargeGap a thin line contained within a thick line with a large-sized intermediate gap
thinThickMediumGap a thick line contained within a thin line with a medium-sized intermediate gap
thinThickSmallGap a thick line contained within a thin line with a small intermediate gap
thinThickThinLargeGap a thin-thick-thin line with a large gap
thinThickThinMediumGap a thin-thick-thin line with a medium gap
thinThickThinSmallGap a thin-thick-thin line with a small gap
threeDEmboss a three-staged gradient line, getting darker towards the paragraph
threeDEngrave a three-staged gradient like, getting darker away from the paragraph
triple a triple line
wave a wavy line

[color]

Specifies the color of the border. Values are given as hex values (in RRGGBB format). No #, unlike hex values in HTML/CSS. E.g., color="FFFF00". A value of auto is also permitted and will allow the consuming word processor to determine the color.

[size]

Specifies the width of the border.
The gem seems to multiply whatever value you supply by 6. I nothing or 0 is entered then it uses 6.

from htmltoword.

BigMcLargeHuge avatar BigMcLargeHuge commented on July 24, 2024

@fran-worley nicely done, thanks!

from htmltoword.

fran-worley avatar fran-worley commented on July 24, 2024

Any time! I'm looking to start using it myself and wanted to see where the gaps are.
I think the comment might be better placed in the Wiki so that it doesn't get lost when this issue is closed, though I'll have to test what I've put to ensure that it actually works.

from htmltoword.

anitsirc avatar anitsirc commented on July 24, 2024

Thanks @fran-worley! I've added it as is to the wiki and will review it, soon...

from htmltoword.

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.