htmlPDF

package module
v0.0.0-...-c2b2b54 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: MIT Imports: 7 Imported by: 0

README

Package for create pdf from html

Implement series article Let's build a toy browser engine!

Install:

go get github.com/janczer/htmlPDF
go get github.com/jung-kurt/gofpdf

Exemple: First you need create 3 files. With html tags, css style and Go code:

first.html:

<div class="a">
    <div class="b">
        <div class="c">
            <div class="d">
                <div class="e">
                    <div class="f">
                        <div class="g">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

style.css:

* { display: block; padding: 5px; }
.a { background: #ff0000; }
.b { background: #ffa500; }
.c { background: #ffff00; }
.d { background: #008000; }
.e { background: #0000ff; }
.f { background: #4b0082; }
.g { background: #800080; }

main.go:

package main

import "github.com/janczer/htmlPDF"

func main() {
    htmlPDF.Generate("first.html", "style.css", "hello.pdf")
}

render

Todo:


  • Add support Anonymous block
  • Add support Inline block
  • Add use CSS from style tag <style></style>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(html string, css string, out string)

func GenerateFromString

func GenerateFromString(html string, css string, out string)

func GetTotalFrom

func GetTotalFrom(ml, mr, bl, br, pl, pr Value) float64

Types

type AnonymousBlock

type AnonymousBlock struct{}

type BlockNode

type BlockNode struct{}

type Color

type Color struct {
	// contains filtered or unexported fields
}

type Declaration

type Declaration struct {
	// contains filtered or unexported fields
}

type Dimensions

type Dimensions struct {
	// contains filtered or unexported fields
}

type DisplayCommand

type DisplayCommand struct {
	// contains filtered or unexported fields
}

type EdgeSizes

type EdgeSizes struct {
	// contains filtered or unexported fields
}

type ElementData

type ElementData struct {
	// contains filtered or unexported fields
}

type InlineNode

type InlineNode struct{}

type LayoutBox

type LayoutBox struct {
	// contains filtered or unexported fields
}

func NewLayoutBox

func NewLayoutBox(boxType interface{}, style StyleNode) *LayoutBox

type Length

type Length struct {
	// contains filtered or unexported fields
}

type MatchedRule

type MatchedRule struct {
	// contains filtered or unexported fields
}

type Node

type Node struct {
	// contains filtered or unexported fields
}

Struct for Node tree

func ParseHtml

func ParseHtml(source string) *Node

Parse an HTML document and return the *Node

type NodeType

type NodeType struct {
	// contains filtered or unexported fields
}

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

func CssParser

func CssParser(source string) *Parser

Parse a whole CSS stylesheet

type Rect

type Rect struct {
	// contains filtered or unexported fields
}

type Rule

type Rule struct {
	// contains filtered or unexported fields
}

type SimpleSelector

type SimpleSelector struct {
	// contains filtered or unexported fields
}

type SolidColor

type SolidColor struct {
	// contains filtered or unexported fields
}

type SortBySpec

type SortBySpec map[int]MatchedRule

func (SortBySpec) Len

func (a SortBySpec) Len() int

func (SortBySpec) Less

func (a SortBySpec) Less(i, j int) bool

func (SortBySpec) Swap

func (a SortBySpec) Swap(i, j int)

type Specificity

type Specificity struct {
	// contains filtered or unexported fields
}

type StyleNode

type StyleNode struct {
	// contains filtered or unexported fields
}

type Stylesheet

type Stylesheet struct {
	// contains filtered or unexported fields
}

type Text

type Text struct {
	// contains filtered or unexported fields
}

type Value

type Value struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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