Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ jobs:
exit 1
fi

- name: Enforce semantic import versioning
run: |
VERSION="${{ inputs.version }}"
MAJOR="${VERSION#v}"
MAJOR="${MAJOR%%.*}"
MODULE_PATH=$(awk '/^module / {print $2; exit}' go.mod)
if [ "$MAJOR" -ge 2 ]; then
EXPECTED_SUFFIX="/v${MAJOR}"
case "$MODULE_PATH" in
*"$EXPECTED_SUFFIX")
;;
*)
echo "ERROR: releasing $VERSION but go.mod module path is '$MODULE_PATH'."
echo "Go's semantic import versioning requires the path to end in '$EXPECTED_SUFFIX' for major version $MAJOR."
echo "Update go.mod and rewrite internal imports before releasing."
exit 1
;;
esac
else
case "$MODULE_PATH" in
*/v[0-9]*)
echo "ERROR: releasing $VERSION but go.mod module path '$MODULE_PATH' has a /vN suffix."
echo "Only major versions >= 2 should carry a /vN suffix."
exit 1
;;
esac
fi

- uses: actions/setup-go@v5
with:
go-version: '1.22'
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pdfer is a pure Go PDF library with zero external dependencies. The codebase fol
Most operations are available directly from the root package:

```go
import "github.com/benedoc-inc/pdfer"
import "github.com/benedoc-inc/pdfer/v2"

// Encrypt / decrypt
out, err := pdfer.EncryptPDF(pdfBytes, []byte("password"), nil, false)
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

Pure Go PDF processing library — zero CGO, zero external dependencies.

[![Go Reference](https://pkg.go.dev/badge/github.com/benedoc-inc/pdfer.svg)](https://pkg.go.dev/github.com/benedoc-inc/pdfer)
[![Go Report Card](https://goreportcard.com/badge/github.com/benedoc-inc/pdfer)](https://goreportcard.com/report/github.com/benedoc-inc/pdfer)
[![Go Reference](https://pkg.go.dev/badge/github.com/benedoc-inc/pdfer/v2.svg)](https://pkg.go.dev/github.com/benedoc-inc/pdfer/v2)
[![Go Report Card](https://goreportcard.com/badge/github.com/benedoc-inc/pdfer/v2)](https://goreportcard.com/report/github.com/benedoc-inc/pdfer/v2)

## Installation

```bash
go get github.com/benedoc-inc/pdfer
go get github.com/benedoc-inc/pdfer/v2
```

## Quick start

```go
import "github.com/benedoc-inc/pdfer"
import "github.com/benedoc-inc/pdfer/v2"

// Merge two PDFs
out, err := pdfer.MergePDFs([][]byte{a, b}, nil, false)
Expand Down Expand Up @@ -248,7 +248,7 @@ if !vr.Conformant {
## Creating PDFs from scratch

```go
import "github.com/benedoc-inc/pdfer/core/write"
import "github.com/benedoc-inc/pdfer/v2/core/write"

builder := write.NewSimplePDFBuilder()
page := builder.AddPage(write.PageSizeLetter)
Expand Down Expand Up @@ -308,7 +308,7 @@ layout.BalanceColumns() // align cursors to the lowest column
## Parsing PDFs directly

```go
import "github.com/benedoc-inc/pdfer/core/parse"
import "github.com/benedoc-inc/pdfer/v2/core/parse"

pdf, err := parse.OpenWithOptions(pdfBytes, parse.ParseOptions{
Password: []byte("secret"),
Expand Down
16 changes: 8 additions & 8 deletions api.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package pdfer

import (
"github.com/benedoc-inc/pdfer/content/extract"
"github.com/benedoc-inc/pdfer/core/compare"
"github.com/benedoc-inc/pdfer/core/manipulate"
"github.com/benedoc-inc/pdfer/core/sign"
"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/forms"
"github.com/benedoc-inc/pdfer/forms/acroform"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/content/extract"
"github.com/benedoc-inc/pdfer/v2/core/compare"
"github.com/benedoc-inc/pdfer/v2/core/manipulate"
"github.com/benedoc-inc/pdfer/v2/core/sign"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/forms"
"github.com/benedoc-inc/pdfer/v2/forms/acroform"
"github.com/benedoc-inc/pdfer/v2/types"
)

// --- Type aliases -----------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strconv"
"strings"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/v2/core/parse"
)

// FileAttachment holds a file to be embedded in the exported PDF.
Expand Down
6 changes: 3 additions & 3 deletions cmd/pdfer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"log"
"os"

encrypt "github.com/benedoc-inc/pdfer/core/encrypt"
"github.com/benedoc-inc/pdfer/forms/xfa"
"github.com/benedoc-inc/pdfer/types"
encrypt "github.com/benedoc-inc/pdfer/v2/core/encrypt"
"github.com/benedoc-inc/pdfer/v2/forms/xfa"
"github.com/benedoc-inc/pdfer/v2/types"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions content/extract/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"regexp"
"strings"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

var uriInActionPattern = regexp.MustCompile(`/URI\s*\(([^)]*)\)`)
Expand Down
4 changes: 2 additions & 2 deletions content/extract/annotations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package extract
import (
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/types"
)

func TestExtractAnnotations_Link(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

const benchmarkDir = "../../tests/resources/benchmark"
Expand Down
4 changes: 2 additions & 2 deletions content/extract/bookmarks.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package extract

import (
"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ExtractBookmarks extracts bookmarks/outlines from a PDF
Expand Down
4 changes: 2 additions & 2 deletions content/extract/content_extraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path/filepath"
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/types"
)

func TestExtractText_TjOperator(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/content_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strconv"
"strings"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

// parseContentStream parses a PDF content stream and extracts text, graphics, and images
Expand Down
4 changes: 2 additions & 2 deletions content/extract/directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"os"
"path/filepath"

"github.com/benedoc-inc/pdfer/forms"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/forms"
"github.com/benedoc-inc/pdfer/v2/types"
)

// DirectoryOutput represents the result of extracting a PDF to a directory
Expand Down
4 changes: 2 additions & 2 deletions content/extract/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"encoding/json"
"fmt"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ExtractContent extracts all content from a PDF into a ContentDocument
Expand Down
2 changes: 1 addition & 1 deletion content/extract/extract_from_disk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

func TestExtractFromDisk_Fonts(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/v2/core/write"
)

func TestExtractFromGeneratedPDF(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions content/extract/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"strconv"
"strings"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// extractImageData extracts actual image binary data from an image XObject
Expand Down
4 changes: 2 additions & 2 deletions content/extract/images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package extract
import (
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/types"
)

func TestExtractImages_JPEG(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sort"
"strings"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ---- Intermediate types (package-internal) ----
Expand Down
4 changes: 2 additions & 2 deletions content/extract/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ExtractMetadata extracts document metadata
Expand Down
4 changes: 2 additions & 2 deletions content/extract/metadata_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package extract
import (
"fmt"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// GetMetadata parses pdfBytes and returns document metadata without requiring
Expand Down
4 changes: 2 additions & 2 deletions content/extract/pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"
"strings"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ExtractPages extracts all pages from a PDF
Expand Down
4 changes: 2 additions & 2 deletions content/extract/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strconv"
"strings"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/types"
)

// extractResources extracts resources from a Resources dictionary
Expand Down
2 changes: 1 addition & 1 deletion content/extract/resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/v2/core/write"
)

func TestExtractResources_Fonts(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/semantic.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"unicode"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

type textPos struct {
Expand Down
4 changes: 2 additions & 2 deletions content/extract/semantic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package extract
import (
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/types"
)

func TestSemanticAnalysis_BasicParagraphs(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion content/extract/tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sort"
"strings"

"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/types"
)

// detectTables finds table structures from graphic lines and maps text into cells.
Expand Down
6 changes: 3 additions & 3 deletions content/extract/test_helpers.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package extract

import (
"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/core/parse"
"github.com/benedoc-inc/pdfer/v2/core/write"
"github.com/benedoc-inc/pdfer/v2/types"
)

// CreateTestPDFWithText creates a simple PDF with known text content for testing extraction
Expand Down
2 changes: 1 addition & 1 deletion content/extract/text_extraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"testing"

"github.com/benedoc-inc/pdfer/core/parse"
"github.com/benedoc-inc/pdfer/v2/core/parse"
)

func TestTextExtraction_510kSummary(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions core/compare/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"reflect"

"github.com/benedoc-inc/pdfer/content/extract"
"github.com/benedoc-inc/pdfer/forms"
"github.com/benedoc-inc/pdfer/types"
"github.com/benedoc-inc/pdfer/v2/content/extract"
"github.com/benedoc-inc/pdfer/v2/forms"
"github.com/benedoc-inc/pdfer/v2/types"
)

// ComparisonResult represents the result of comparing two PDFs
Expand Down
2 changes: 1 addition & 1 deletion core/compare/compare_moved_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package compare
import (
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/v2/core/write"
)

func TestCompareImages_MovedOnSamePage(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion core/compare/compare_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package compare
import (
"testing"

"github.com/benedoc-inc/pdfer/core/write"
"github.com/benedoc-inc/pdfer/v2/core/write"
)

func TestCompareOptions_TextTolerance(t *testing.T) {
Expand Down
Loading
Loading