html2docx

package module
v0.0.0-...-8bfad2e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 4 Imported by: 0

README

Introduction

Convert HTML to DOCX

Install

go get github.com/ainilili/html2docx

Usage

package main

import (
	"github.com/ainilili/html2docx"
	"log"
	"os"
)

func main() {
	source := `<!DOCTYPE html>
<html>
<head>
	<title>我的网页</title>
</head>
<body>
	<h1>欢迎来到我的网页</h1>
	<p>这是一个简单的HTML文档。</p>
</body>
</html>`
	dist, err := html2docx.Convert([]byte(source))
	if err != nil {
		log.Fatalln(err)
	}
	err = os.WriteFile("test.docx", dist, 0666)
	if err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(source []byte, opts ...Option) ([]byte, error)

Types

type DocxFile

type DocxFile struct {
	Name   string
	Source []byte
}

type DocxHeader

type DocxHeader struct {
	Width   int
	Height  int
	Orient  string
	Margins DocxHeaderMargins
}

type DocxHeaderMargins

type DocxHeaderMargins struct {
	Top    int
	Right  int
	Bottom int
	Left   int
	Header int
	Footer int
	Gutter int
}

type Option

type Option func(data map[string]interface{})

func WithHeight

func WithHeight(height int) Option

func WithMarginsBottom

func WithMarginsBottom(bottom int) Option

func WithMarginsFooter

func WithMarginsFooter(footer int) Option

func WithMarginsGutter

func WithMarginsGutter(gutter int) Option

func WithMarginsHeader

func WithMarginsHeader(header int) Option

func WithMarginsLeft

func WithMarginsLeft(left int) Option

func WithMarginsRight

func WithMarginsRight(right int) Option

func WithMarginsTop

func WithMarginsTop(top int) Option

func WithOrient

func WithOrient(orient string) Option

func WithWidth

func WithWidth(width int) Option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL