Fix linting errors
This commit is contained in:
@@ -11,7 +11,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/digitorus/pdf"
|
||||
|
||||
"golang.org/x/text/encoding/unicode"
|
||||
"golang.org/x/text/transform"
|
||||
)
|
||||
@@ -19,7 +18,6 @@ import (
|
||||
func findFirstPage(parent pdf.Value) (pdf.Value, error) {
|
||||
value_type := parent.Key("Type").String()
|
||||
if value_type == "/Pages" {
|
||||
|
||||
for i := 0; i < parent.Key("Kids").Len(); i++ {
|
||||
recurse_parent, recurse_err := findFirstPage(parent.Key("Kids").Index(i))
|
||||
if recurse_err == nil {
|
||||
|
@@ -25,7 +25,8 @@ var testFiles = []struct {
|
||||
expectedCatalogs: map[CertType]string{
|
||||
CertificationSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n",
|
||||
UsageRightsSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 1 >> >>\nendobj\n",
|
||||
ApprovalSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n"},
|
||||
ApprovalSignature: "17 0 obj\n<< /Type /Catalog /Pages 9 0 R /Names 6 0 R /AcroForm << /Fields [16 0 R] /NeedAppearances false /SigFlags 3 >> >>\nendobj\n",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
@@ -43,7 +43,6 @@ func (context *SignContext) createSignaturePlaceholder() (dssd string, byte_rang
|
||||
signature_buffer.Write(bytes.Repeat([]byte("0"), int(context.SignatureMaxLength)))
|
||||
signature_buffer.WriteString(">\n")
|
||||
|
||||
//if context.SignData.Signature.CertType != ApprovalSignature {
|
||||
switch context.SignData.Signature.CertType {
|
||||
case CertificationSignature, UsageRightsSignature:
|
||||
signature_buffer.WriteString(" /Reference [\n") // start array of signature reference dictionaries
|
||||
@@ -51,7 +50,6 @@ func (context *SignContext) createSignaturePlaceholder() (dssd string, byte_rang
|
||||
}
|
||||
|
||||
switch context.SignData.Signature.CertType {
|
||||
|
||||
// Certification signature (also known as an author signature)
|
||||
case CertificationSignature:
|
||||
signature_buffer.WriteString(" /TransformMethod /DocMDP\n")
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"github.com/digitorus/pdf"
|
||||
)
|
||||
|
||||
// Define annotation flag constants
|
||||
// Define annotation flag constants.
|
||||
const (
|
||||
AnnotationFlagInvisible = 1 << 0
|
||||
AnnotationFlagHidden = 1 << 1
|
||||
@@ -78,7 +78,7 @@ func (context *SignContext) createVisualSignature(visible bool, pageNumber int,
|
||||
}
|
||||
|
||||
// Define the annotation flags for the signature field (132)
|
||||
//annotationFlags := AnnotationFlagPrint | AnnotationFlagNoZoom | AnnotationFlagNoRotate | AnnotationFlagReadOnly | AnnotationFlagLockedContents
|
||||
// annotationFlags := AnnotationFlagPrint | AnnotationFlagNoZoom | AnnotationFlagNoRotate | AnnotationFlagReadOnly | AnnotationFlagLockedContents
|
||||
visual_signature += fmt.Sprintf(" /F %d", 132)
|
||||
// Define the field type as a signature.
|
||||
visual_signature += " /FT /Sig"
|
||||
@@ -104,7 +104,7 @@ func (context *SignContext) createVisualSignature(visible bool, pageNumber int,
|
||||
return visual_signature, nil
|
||||
}
|
||||
|
||||
// Helper function to find a page by its number
|
||||
// Helper function to find a page by its number.
|
||||
func findPageByNumber(pages pdf.Value, pageNumber int) (pdf.Value, error) {
|
||||
if pages.Key("Type").Name() == "Pages" {
|
||||
kids := pages.Key("Kids")
|
||||
|
@@ -32,6 +32,8 @@ func (context *SignContext) writeXref() error {
|
||||
}
|
||||
|
||||
// writeXrefTable writes the cross-reference table to the output buffer.
|
||||
//
|
||||
//nolint:unused
|
||||
func (context *SignContext) writeXrefTable() error {
|
||||
// Seek to the start of the xref table
|
||||
if _, err := context.InputFile.Seek(context.PDFReader.XrefInformation.StartPos, io.SeekStart); err != nil {
|
||||
|
@@ -9,7 +9,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/digitorus/pdfsign/revocation"
|
||||
|
||||
"golang.org/x/crypto/ocsp"
|
||||
)
|
||||
|
||||
|
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/digitorus/pdf"
|
||||
"github.com/digitorus/pdfsign/revocation"
|
||||
"github.com/digitorus/pkcs7"
|
||||
|
||||
"github.com/mattetti/filebuffer"
|
||||
)
|
||||
|
||||
@@ -202,7 +201,6 @@ func (context *SignContext) SignPDF() error {
|
||||
|
||||
// If not a timestamp signature
|
||||
if context.SignData.Signature.CertType != TimeStampSignature {
|
||||
|
||||
switch context.SignData.Certificate.SignatureAlgorithm.String() {
|
||||
case "SHA1-RSA":
|
||||
case "ECDSA-SHA1":
|
||||
@@ -268,7 +266,7 @@ func (context *SignContext) SignPDF() error {
|
||||
}
|
||||
|
||||
// Create visual signature (visible or invisible based on CertType)
|
||||
//visible := context.SignData.Signature.CertType == CertificationSignature
|
||||
// visible := context.SignData.Signature.CertType == CertificationSignature
|
||||
// Example usage: passing page number and default rect values
|
||||
visual_signature, err := context.createVisualSignature(false, 1, [4]float64{0, 0, 0, 0})
|
||||
if err != nil {
|
||||
|
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/digitorus/pdf"
|
||||
"github.com/digitorus/pdfsign/revocation"
|
||||
"github.com/digitorus/pdfsign/verify"
|
||||
|
||||
"github.com/mattetti/filebuffer"
|
||||
)
|
||||
|
||||
@@ -124,7 +123,7 @@ func TestReaderCanReadPDF(t *testing.T) {
|
||||
|
||||
func TestSignPDF(t *testing.T) {
|
||||
_ = os.RemoveAll("../testfiles/failed/")
|
||||
_ = os.MkdirAll("../testfiles/failed/", 0777)
|
||||
_ = os.MkdirAll("../testfiles/failed/", 0o777)
|
||||
|
||||
files, err := os.ReadDir("../testfiles/")
|
||||
if err != nil {
|
||||
@@ -169,7 +168,6 @@ func TestSignPDF(t *testing.T) {
|
||||
RevocationData: revocation.InfoArchival{},
|
||||
RevocationFunction: DefaultEmbedRevocationStatusFunction,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
st.Fatalf("%s: %s", f.Name(), err.Error())
|
||||
}
|
||||
@@ -209,7 +207,6 @@ func TestSignPDFFileUTF8(t *testing.T) {
|
||||
Signer: pkey,
|
||||
Certificate: cert,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", originalFileName, err.Error())
|
||||
}
|
||||
@@ -269,7 +266,6 @@ func BenchmarkSignPDF(b *testing.B) {
|
||||
CertificateChains: certificateChains,
|
||||
RevocationData: revocation.InfoArchival{},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
b.Fatalf("%s: %s", "testfile20.pdf", err.Error())
|
||||
}
|
||||
@@ -305,7 +301,6 @@ func TestSignPDFWithTwoApproval(t *testing.T) {
|
||||
Signer: pkey,
|
||||
Certificate: cert,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", "testfile20.pdf", err.Error())
|
||||
}
|
||||
@@ -343,7 +338,6 @@ func TestSignPDFWithCertificationApprovalAndTimeStamp(t *testing.T) {
|
||||
Signer: pkey,
|
||||
Certificate: cert,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", filepath.Base(tbsFile), err.Error())
|
||||
}
|
||||
@@ -376,7 +370,6 @@ func TestSignPDFWithCertificationApprovalAndTimeStamp(t *testing.T) {
|
||||
Signer: pkey,
|
||||
Certificate: cert,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", filepath.Base(tbsFile), err.Error())
|
||||
}
|
||||
@@ -426,7 +419,6 @@ func TestTimestampPDFFile(t *testing.T) {
|
||||
URL: "http://timestamp.entrust.net/TSS/RFC3161sha2TS",
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %s", "testfile20.pdf", err.Error())
|
||||
}
|
||||
|
Reference in New Issue
Block a user