Skip to content

Commit

Permalink
Merge pull request #47 from klippa-app/feature/implement-fpdf_edit
Browse files Browse the repository at this point in the history
Implement fpdf_edit
  • Loading branch information
jerbob92 authored Feb 25, 2022
2 parents 28fd36d + a5ff335 commit 64a5186
Show file tree
Hide file tree
Showing 37 changed files with 13,437 additions and 1,081 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

* Option between single-threaded and multi-threaded (through subprocesses), while keeping the same interface
* This library will handle all complicated cgo gymnastics for you
* The goal is to implement all PDFium public API methods (including [experimental](#experimental)), current progress: 50%
* The goal is to implement all PDFium public API methods (including [experimental](#experimental)), current progress: 75%
* Current PDFium methods exposed, no cgo required
* PDFium instance configuration (sandbox policy, fonts)
* Document loading (from bytes, path or io.ReadSeeker)
Expand All @@ -40,8 +40,8 @@
* Progressive rendering
* Document loading through data availability (loading data as needed)
* Struct trees
* Page/Page object editing
* Methods to be implemented:
* Page/Page object editing (fpdf_edit.h)
* Form filling (fpdf_formfill.h)
* Annotations (fpdf_annot.h)
* Methods that won't be implemented for now:
Expand Down
12 changes: 12 additions & 0 deletions code_generation/templates/multi_threaded.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ func (i *pdfiumInstance) {{ $method.Name }}(request *requests.{{ $method.Input }
return nil, errors.New("using a file-writer is not supported on multi-threaded usage")
}

return i.worker.plugin.{{ $method.Name }}(request)
{{- else if eq $method.Name "FPDFImageObj_LoadJpegFile" -}}
if request.FileReader != nil {
return nil, errors.New("using a file-reader is not supported on multi-threaded usage")
}

return i.worker.plugin.{{ $method.Name }}(request)
{{- else if eq $method.Name "FPDFImageObj_LoadJpegFileInline" -}}
if request.FileReader != nil {
return nil, errors.New("using a file-reader is not supported on multi-threaded usage")
}

return i.worker.plugin.{{ $method.Name }}(request)
{{- else -}}
return i.worker.plugin.{{ $method.Name }}(request)
Expand Down
90 changes: 90 additions & 0 deletions enums/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,93 @@ const (
PDF_FILEAVAIL_FORM_AVAIL PDF_FILEAVAIL_FORM = 1
PDF_FILEAVAIL_FORM_NOTEXIST PDF_FILEAVAIL_FORM = 2
)

type PDF_BLEND_MODE string

const (
PDF_BLEND_MODE_COLOR PDF_BLEND_MODE = "Color"
PDF_BLEND_MODE_COLOR_BURN PDF_BLEND_MODE = "ColorBurn"
PDF_BLEND_MODE_COLOR_DODGE PDF_BLEND_MODE = "ColorDodge"
PDF_BLEND_MODE_DARKEN PDF_BLEND_MODE = "Darken"
PDF_BLEND_MODE_DIFFERENCE PDF_BLEND_MODE = "Difference"
PDF_BLEND_MODE_EXCLUSION PDF_BLEND_MODE = "Exclusion"
PDF_BLEND_MODE_HARD_LIGHT PDF_BLEND_MODE = "HardLight"
PDF_BLEND_MODE_HUE PDF_BLEND_MODE = "Hue"
PDF_BLEND_MODE_LIGHTEN PDF_BLEND_MODE = "Lighten"
PDF_BLEND_MODE_LUMINOSITY PDF_BLEND_MODE = "Luminosity"
PDF_BLEND_MODE_MULTIPLY PDF_BLEND_MODE = "Multiply"
PDF_BLEND_MODE_NORMAL PDF_BLEND_MODE = "Normal"
PDF_BLEND_MODE_OVERLAY PDF_BLEND_MODE = "Overlay"
PDF_BLEND_MODE_SATURATION PDF_BLEND_MODE = "Saturation"
PDF_BLEND_MODE_SCREEN PDF_BLEND_MODE = "Screen"
PDF_BLEND_MODE_SOFT_LIGHT PDF_BLEND_MODE = "SoftLight"
)

type FPDF_FILLMODE int

const (
FPDF_FILLMODE_NONE FPDF_FILLMODE = 0
FPDF_FILLMODE_ALTERNATE FPDF_FILLMODE = 1
FPDF_FILLMODE_WINDING FPDF_FILLMODE = 2
)

type FPDF_FONT int

const (
FPDF_FONT_TYPE1 FPDF_FONT = 1
FPDF_FONT_TRUETYPE FPDF_FONT = 2
)

type FPDF_PAGEOBJ int

const (
FPDF_PAGEOBJ_UNKNOWN FPDF_PAGEOBJ = 0
FPDF_PAGEOBJ_TEXT FPDF_PAGEOBJ = 1
FPDF_PAGEOBJ_PATH FPDF_PAGEOBJ = 2
FPDF_PAGEOBJ_IMAGE FPDF_PAGEOBJ = 3
FPDF_PAGEOBJ_SHADING FPDF_PAGEOBJ = 4
FPDF_PAGEOBJ_FORM FPDF_PAGEOBJ = 5
)

type FPDF_LINEJOIN int

const (
FPDF_LINEJOIN_MITER FPDF_LINEJOIN = 0
FPDF_LINEJOIN_ROUND FPDF_LINEJOIN = 1
FPDF_LINEJOIN_BEVEL FPDF_LINEJOIN = 2
)

type FPDF_LINECAP int

const (
FPDF_LINECAP_BUTT FPDF_LINECAP = 0
FPDF_LINECAP_ROUND FPDF_LINECAP = 1
FPDF_LINECAP_PROJECTING_SQUAR FPDF_LINECAP = 2
)

type FPDF_SEGMENT int

const (
FPDF_SEGMENT_UNKNOWN FPDF_SEGMENT = -1
FPDF_SEGMENT_LINETO FPDF_SEGMENT = 0
FPDF_SEGMENT_BEZIERTO FPDF_SEGMENT = 1
FPDF_SEGMENT_MOVETO FPDF_SEGMENT = 2
)

// Refer to PDF Reference version 1.7 table 4.12 for all color space families.
type FPDF_COLORSPACE int

const (
FPDF_COLORSPACE_UNKNOWN FPDF_COLORSPACE = 0
FPDF_COLORSPACE_DEVICEGRAY FPDF_COLORSPACE = 1
FPDF_COLORSPACE_DEVICERGB FPDF_COLORSPACE = 2
FPDF_COLORSPACE_DEVICECMYK FPDF_COLORSPACE = 3
FPDF_COLORSPACE_CALGRAY FPDF_COLORSPACE = 4
FPDF_COLORSPACE_CALRGB FPDF_COLORSPACE = 5
FPDF_COLORSPACE_LAB FPDF_COLORSPACE = 6
FPDF_COLORSPACE_ICCBASED FPDF_COLORSPACE = 7
FPDF_COLORSPACE_SEPARATION FPDF_COLORSPACE = 8
FPDF_COLORSPACE_DEVICEN FPDF_COLORSPACE = 9
FPDF_COLORSPACE_INDEXED FPDF_COLORSPACE = 10
FPDF_COLORSPACE_PATTERN FPDF_COLORSPACE = 11
)
Loading

0 comments on commit 64a5186

Please sign in to comment.