/pdf-by-text

create complex pdf from text file

Primary LanguageGo

pdf-by-text

create complex pdf from text file.

日本語の説明はこちら

This program is executable file for windows, mac or linux.
Any language which create text file and execute child process can use this program.

This program use github.com/signintech/gopdf for pdf generation.

First part of following Simple report is as follows.

Columns must be separated by tab(\t).

P	mm	A4	L
F	IPAexG		14
C1	50.00	15.00	Sales Report
F	IPAexG		12
C1	240.00	20.00	page
C1	260.00	20.00	1
C1	15.00	23.00	D No
C1	30.00	23.00	Dept
C1	60.00	23.00	Order
C1	90.00	23.00	Stock
C1	120.00	23.00	Name
CR	135.00	23.00	25.00	Unit Price
CR	160.00	23.00	20.00	Qty
CR	190.00	23.00	20.00	Amount

Simple report sample Simple1
text pdf

Medium report sample Medium1

text pdf

Complex report sample Complex1

text pdf

Complex2

text pdf

Execution

pdf-by-text(.exe) -f fontfile -o outputfile -e encoding inputfile

-f -o -e are optional
fontfile default is font.yml
outputfile default is inputfile name with file extension changed to pdf
encoding default is UTF8. Accept ShiftJIS, EUCJP.

Download

windows 386
windows amd64
mac 386
mac amd64
linux 386
linux amd64

concept

  • Simple command to draw object
  • Support unit of mm(millimeter), pt(point) and in(Inch).
  • Line can be used as gray fill pattern.

font file

-
  name:IPAexG
  file:ttf\ipaexg.ttf
-
  name:MPBOLD
  file:ttf\mplus-1p-bold.ttf

Draw commands

Elements must be separated by tab(\t).

  • Page Setup

  • Predefined page
    A {unit} {size} {orientation}
    //unit mm(millimeter), pt(point), in(Inch)
    //size A4 or LTR
    //orientation P(portrate) or L(Landscape)

  • Frexible Page
    A1 {unit} {width} {height}

  • New Page
    NP

  • Font setting

  • Font face F {fontname} {size} {style}
    //style U for underline

  • Text Color
    TC {red} {green} {blue}
    //color 255 - 0

  • Text Gray Scale
    GF {scale}
    // scale 100 - 0

  • Text Draw

  • Normal text
    C1 {x} {y} {content}

  • Right Jusify text
    CR {x} {y} {width} {content}

  • Line Draw

  • Line Type
    LT {linetype} {width}
    //lineType "dashed" ,"dotted","straight". "" = "straight"

  • Gray Stroke (Gray Scale)
    GS {scale}
    // scale 100 - 0

  • Horizontal Line
    LH {x1} {y} {x2}

  • Vertical Line
    LV {x} {y1} {y2}

  • Line
    L {x1} {y1} {x2} {y2}

  • Shape Draw

    • Rectangle
      R {x1} {y1} {x2} {y2}
    • Oval
      O {x1} {y1} {x2} {y2}
  • Image Draw
    I {path} {x1} {y1} {x2} {y2}

Limitation

  • Font style not allow B(bold) and I(italic).
  • Line, Rect and Oval are Black and Gray only.
  • Image file format is jpeg only.