converter

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Author:TruthHun Email:TruthHun@QQ.COM Date:2018-01-21

Author:TruthHun Email:TruthHun@QQ.COM Date:2018-01-21

Index

Constants

This section is empty.

Variables

View Source
var MediaType = map[string]string{
	".jpeg":  "image/jpeg",
	".png":   "image/png",
	".jpg":   "image/jpeg",
	".gif":   "image/gif",
	".ico":   "image/x-icon",
	".bmp":   "image/bmp",
	".html":  "application/xhtml+xml",
	".xhtml": "application/xhtml+xml",
	".htm":   "application/xhtml+xml",
	".otf":   "application/x-font-opentype",
	".ttf":   "application/x-font-ttf",
	".js":    "application/x-javascript",
	".ncx":   "x-dtbncx+xml",
	".txt":   "text/plain",
	".xml":   "text/xml",
	".css":   "text/css",
}

media-type

Functions

func GetFooterOrHeaderParams added in v0.7.3

func GetFooterOrHeaderParams(v string) string

func GetMediaType

func GetMediaType(ext string) string

根据文件扩展名,获取media-type

Types

type Config

type Config struct {
	Charset      string   `json:"charset"`       //字符编码,默认utf-8编码
	Cover        string   `json:"cover"`         //封面图片,或者封面html文件
	Timestamp    string   `json:"date"`          //时间日期,如“2018-01-01 12:12:21”,其实是time.Time格式,但是直接用string就好
	Description  string   `json:"description"`   //摘要
	Footer       string   `json:"footer"`        //pdf的footer
	Header       string   `json:"header"`        //pdf的header
	Identifier   string   `json:"identifier"`    //即uuid,留空即可
	Language     string   `json:"language"`      //语言,如zh、en、zh-CN、en-US等
	Creator      string   `json:"creator"`       //作者,即author
	Publisher    string   `json:"publisher"`     //出版单位
	Contributor  string   `json:"contributor"`   //同Publisher
	Title        string   `json:"title"`         //文档标题
	Format       []string `json:"format"`        //导出格式,可选值:pdf、epub、mobi
	FontSize     string   `json:"font_size"`     //默认的pdf导出字体大小
	PaperSize    string   `json:"paper_size"`    //页面大小
	MarginLeft   string   `json:"margin_left"`   //PDF文档左边距,写数字即可,默认72pt
	MarginRight  string   `json:"margin_right"`  //PDF文档左边距,写数字即可,默认72pt
	MarginTop    string   `json:"margin_top"`    //PDF文档左边距,写数字即可,默认72pt
	MarginBottom string   `json:"margin_bottom"` //PDF文档左边距,写数字即可,默认72pt
	More         []string `json:"more"`          //更多导出选项[PDF导出选项,具体参考:https://manual.calibre-ebook.com/generated/en/ebook-convert.html#pdf-output-options]
	Toc          []Toc    `json:"toc"`           //目录
	///////////////////////////////////////////
	Order []string `json:"-"` //这个不需要赋值
}

config.json文件解析结构

type Converter

type Converter struct {
	BasePath       string
	Config         Config
	Debug          bool
	GeneratedCover string
}

func NewConverter

func NewConverter(configFile string, debug ...bool) (converter *Converter, err error)

接口文档 https://manual.calibre-ebook.com/generated/en/ebook-convert.html#table-of-contents 根据json配置文件,创建文档转化对象

func (*Converter) Convert

func (this *Converter) Convert() (err error)

执行文档转换

type Toc

type Toc struct {
	Id    int    `json:"id"`
	Link  string `json:"link"`
	Pid   int    `json:"pid"`
	Title string `json:"title"`
}

目录结构

Jump to

Keyboard shortcuts

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