Skip to content

Commit

Permalink
Merge pull request #63 from klippa-app/feature/update-to-pdfium-5378
Browse files Browse the repository at this point in the history
Feature/update to pdfium 5378
  • Loading branch information
jerbob92 authored Oct 24, 2022
2 parents 618cc01 + d539e39 commit 81222d6
Show file tree
Hide file tree
Showing 20 changed files with 682 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
go: [ 1.16, 1.17, 1.18 ]
pdfium: [ 4849, 4874, 4929, 5038, 5079, 5254 ]
pdfium: [ 4849, 4874, 4929, 5038, 5079, 5254, 5378 ]
env:
PDFIUM_EXPERIMENTAL_VERSION: 5254
PDFIUM_EXPERIMENTAL_VERSION: 5378
PDFIUM_EXPERIMENTAL_GO_VERSION: 1.18
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pdfium-windows.pc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ includedir=D:/opt/pdfium/include

Name: PDFium
Description: PDFium
Version: 5254
Version: 5378
Requires:

Libs: -L${libdir} -lpdfium
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pdfium.pc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ includedir=/opt/pdfium/include

Name: PDFium
Description: PDFium
Version: 5254
Version: 5378
Requires:

Libs: -L${libdir} -lpdfium
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ includedir={path}/include
Name: PDFium
Description: PDFium
Version: 5254
Version: 5378
Requires:
Libs: -L${libdir} -lpdfium
Expand Down
9 changes: 9 additions & 0 deletions enums/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,12 @@ const (
FWL_VKEY_OEM_Clear FWL_VKEYCODE = 0xFE
FWL_VKEY_Unknown FWL_VKEYCODE = 0
)

type FPDF_ANNOT_AACTION int

const (
FPDF_ANNOT_AACTION_KEY_STROKE FPDF_ANNOT_AACTION = 12
FPDF_ANNOT_AACTION_FORMAT FPDF_ANNOT_AACTION = 13
FPDF_ANNOT_AACTION_VALIDATE FPDF_ANNOT_AACTION = 14
FPDF_ANNOT_AACTION_CALCULATE FPDF_ANNOT_AACTION = 15
)
87 changes: 87 additions & 0 deletions internal/commons/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 70 additions & 0 deletions internal/implementation/fpdf_annot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,41 @@ func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldAtPoint(request *requests.F
}, nil
}

// FPDFAnnot_GetFormAdditionalActionJavaScript returns the JavaScript of an event of the annotation's additional actions.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormAdditionalActionJavaScript(request *requests.FPDFAnnot_GetFormAdditionalActionJavaScript) (*responses.FPDFAnnot_GetFormAdditionalActionJavaScript, error) {
p.Lock()
defer p.Unlock()

formHandle, err := p.getFormHandleHandle(request.FormHandle)
if err != nil {
return nil, err
}

annotationHandle, err := p.getAnnotationHandle(request.Annotation)
if err != nil {
return nil, err
}

// First get the value length
length := C.FPDFAnnot_GetFormAdditionalActionJavaScript(formHandle.handle, annotationHandle.handle, C.int(request.Event), nil, 0)
if uint64(length) == 0 {
return nil, errors.New("could not get form additional action JavaScript")
}

charData := make([]byte, length)
C.FPDFAnnot_GetFormAdditionalActionJavaScript(formHandle.handle, annotationHandle.handle, C.int(request.Event), (*C.ushort)(unsafe.Pointer(&charData[0])), C.ulong(len(charData)))

transformedText, err := p.transformUTF16LEToUTF8(charData)
if err != nil {
return nil, err
}

return &responses.FPDFAnnot_GetFormAdditionalActionJavaScript{
FormAdditionalActionJavaScript: transformedText,
}, nil
}

// FPDFAnnot_GetFormFieldName returns the name of the given annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldName(request *requests.FPDFAnnot_GetFormFieldName) (*responses.FPDFAnnot_GetFormFieldName, error) {
Expand Down Expand Up @@ -1129,6 +1164,41 @@ func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldName(request *requests.FPDF
}, nil
}

// FPDFAnnot_GetFormFieldAlternateName returns the alternate name of an annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldAlternateName(request *requests.FPDFAnnot_GetFormFieldAlternateName) (*responses.FPDFAnnot_GetFormFieldAlternateName, error) {
p.Lock()
defer p.Unlock()

formHandle, err := p.getFormHandleHandle(request.FormHandle)
if err != nil {
return nil, err
}

annotationHandle, err := p.getAnnotationHandle(request.Annotation)
if err != nil {
return nil, err
}

// First get the value length
length := C.FPDFAnnot_GetFormFieldAlternateName(formHandle.handle, annotationHandle.handle, nil, 0)
if uint64(length) == 0 {
return nil, errors.New("could not get form field alternate name")
}

charData := make([]byte, length)
C.FPDFAnnot_GetFormFieldAlternateName(formHandle.handle, annotationHandle.handle, (*C.ushort)(unsafe.Pointer(&charData[0])), C.ulong(len(charData)))

transformedText, err := p.transformUTF16LEToUTF8(charData)
if err != nil {
return nil, err
}

return &responses.FPDFAnnot_GetFormFieldAlternateName{
FormFieldAlternateName: transformedText,
}, nil
}

// FPDFAnnot_GetFormFieldType returns the form field type of the given annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldType(request *requests.FPDFAnnot_GetFormFieldType) (*responses.FPDFAnnot_GetFormFieldType, error) {
Expand Down
12 changes: 12 additions & 0 deletions internal/implementation/fpdf_annot_no_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,24 @@ func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldAtPoint(request *requests.F
return nil, pdfium_errors.ErrExperimentalUnsupported
}

// FPDFAnnot_GetFormAdditionalActionJavaScript returns the JavaScript of an event of the annotation's additional actions.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormAdditionalActionJavaScript(request *requests.FPDFAnnot_GetFormAdditionalActionJavaScript) (*responses.FPDFAnnot_GetFormAdditionalActionJavaScript, error) {
return nil, pdfium_errors.ErrExperimentalUnsupported
}

// FPDFAnnot_GetFormFieldName returns the name of the given annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldName(request *requests.FPDFAnnot_GetFormFieldName) (*responses.FPDFAnnot_GetFormFieldName, error) {
return nil, pdfium_errors.ErrExperimentalUnsupported
}

// FPDFAnnot_GetFormFieldAlternateName returns the alternate name of an annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldAlternateName(request *requests.FPDFAnnot_GetFormFieldAlternateName) (*responses.FPDFAnnot_GetFormFieldAlternateName, error) {
return nil, pdfium_errors.ErrExperimentalUnsupported
}

// FPDFAnnot_GetFormFieldType returns the form field type of the given annotation, which is an interactive form annotation.
// Experimental API.
func (p *PdfiumImplementation) FPDFAnnot_GetFormFieldType(request *requests.FPDFAnnot_GetFormFieldType) (*responses.FPDFAnnot_GetFormFieldType, error) {
Expand Down
22 changes: 22 additions & 0 deletions internal/implementation/fpdf_text_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,25 @@ func (p *PdfiumImplementation) FPDFLink_GetTextRange(request *requests.FPDFLink_
CharCount: int(charCount),
}, nil
}

// FPDFText_IsGenerated returns whether a character in a page is generated by PDFium.
// Experimental API.
func (p *PdfiumImplementation) FPDFText_IsGenerated(request *requests.FPDFText_IsGenerated) (*responses.FPDFText_IsGenerated, error) {
p.Lock()
defer p.Unlock()

textPageHandle, err := p.getTextPageHandle(request.TextPage)
if err != nil {
return nil, err
}

isGenerated := C.FPDFText_IsGenerated(textPageHandle.handle, C.int(request.Index))
if int(isGenerated) == -1 {
return nil, errors.New("could not get whether text is generated")
}

return &responses.FPDFText_IsGenerated{
Index: request.Index,
IsGenerated: int(isGenerated) == 1,
}, nil
}
6 changes: 6 additions & 0 deletions internal/implementation/fpdf_text_no_experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ func (p *PdfiumImplementation) FPDFText_GetMatrix(request *requests.FPDFText_Get
func (p *PdfiumImplementation) FPDFLink_GetTextRange(request *requests.FPDFLink_GetTextRange) (*responses.FPDFLink_GetTextRange, error) {
return nil, pdfium_errors.ErrExperimentalUnsupported
}

// FPDFText_IsGenerated returns whether a character in a page is generated by PDFium.
// Experimental API.
func (p *PdfiumImplementation) FPDFText_IsGenerated(request *requests.FPDFText_IsGenerated) (*responses.FPDFText_IsGenerated, error) {
return nil, pdfium_errors.ErrExperimentalUnsupported
}
24 changes: 24 additions & 0 deletions multi_threaded/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 81222d6

Please sign in to comment.