Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1ec58e4
Update to 11.7 Apryse SDK (#171)
rchennafi Aug 20, 2025
a1f6c78
restore non Apple else code
rjsatpdftron Aug 7, 2025
ed14448
11.8 Release (#177)
rchennafi Oct 8, 2025
c112868
Update for 11.9 Release (#179)
rchennafi Nov 26, 2025
e3360ab
Fix issue with sample test having questionable logic.
rchennafi Jan 5, 2026
f581d82
Fix a typo in the ruby test fix.
rchennafi Jan 7, 2026
0cd3666
Merge pre_releease into master for release version 11.10.0
xodo-shared Jan 8, 2026
7809741
CAP-1609 Fixing failed Go samples
rogerk-apryse Jan 14, 2026
c00e98b
CAP-1609 Fixing failed Go samples
rogerk-apryse Jan 14, 2026
aae175a
CAP-1609 Fixing failed Go samples
rogerk-apryse Jan 14, 2026
4c3c093
CAP-1609 Fixing failed Go samples
rogerk-apryse Jan 15, 2026
493b14a
CAP-1609 Fixing failed Go samples
rogerk-apryse Jan 15, 2026
3ab1557
CAP-1609 Fixing failed samples
rogerk-apryse Jan 16, 2026
d1df4cd
Added missing PDFNet.Terminate() call to the OfficeTemplate tests
rogerk-apryse Jan 18, 2026
cf70a79
Adding missing Highlights test to wrappers
rogerk-apryse Jan 18, 2026
7a71b06
Added the HighlightsTest for Go
rogerk-apryse Jan 19, 2026
6e08e33
Removed unused code in the HighlightsTest for Python
rogerk-apryse Jan 19, 2026
453269e
Added the HighlightsTest for PHP
rogerk-apryse Jan 19, 2026
574099b
Added HighlightsTest for Ruby and removed removed code committed by m…
rogerk-apryse Jan 20, 2026
43c4681
Fixed the recently added Ruby Highlights test
rogerk-apryse Jan 20, 2026
0012c34
Merge branch 'next_release' into rogerk/CAP-1609-fixes-samples-go-lang
rogerk-apryse Jan 21, 2026
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
1 change: 1 addition & 0 deletions PDFNetPHP/PDFNetPHP.i
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ namespace std {
//%template(VectorString) vector<std::string>;
%template(VectorRedaction) vector<pdftron::PDF::Redaction>;
%template(VectorQuadPoint) vector<pdftron::PDF::QuadPoint>;
%template(VectorCharRange) vector<pdftron::PDF::CharRange>;
%template(VectorSeparation) vector<pdftron::PDF::Separation>;
%template(VectorDisallowedChange) vector<pdftron::PDF::DisallowedChange>;
%template(VectorAnnot) vector<pdftron::PDF::Annot>;
Expand Down
1 change: 1 addition & 0 deletions PDFNetPython/PDFNetPython.i
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ namespace std {
%template(VectorString) vector<std::string>;
%template(VectorRedaction) vector<pdftron::PDF::Redaction>;
%template(VectorQuadPoint) vector<pdftron::PDF::QuadPoint>;
%template(VectorCharRange) vector<pdftron::PDF::CharRange>;
%template(VectorSeparation) vector<pdftron::PDF::Separation>;
%template(VectorDisallowedChange) vector<pdftron::PDF::DisallowedChange>;
%template(VectorAnnot) vector<pdftron::PDF::Annot>;
Expand Down
1 change: 1 addition & 0 deletions PDFNetRuby/PDFNetRuby.i
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ namespace std {
%template(VectorString) vector<std::string>;
%template(VectorRedaction) vector<pdftron::PDF::Redaction>;
%template(VectorQuadPoint) vector<pdftron::PDF::QuadPoint>;
%template(VectorCharRange) vector<pdftron::PDF::CharRange>;
%template(VectorSeparation) vector<pdftron::PDF::Separation>;
%template(VectorDisallowedChange) vector<pdftron::PDF::DisallowedChange>;
%template(VectorAnnot) vector<pdftron::PDF::Annot>;
Expand Down
1 change: 1 addition & 0 deletions PDFTronGo/pdftron.i
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ namespace std {
%template(VectorString) vector<std::string>;
%template(VectorRedaction) vector<pdftron::PDF::Redaction>;
%template(VectorQuadPoint) vector<pdftron::PDF::QuadPoint>;
%template(VectorCharRange) vector<pdftron::PDF::CharRange>;
%template(VectorSeparation) vector<pdftron::PDF::Separation>;
%template(VectorDisallowedChange) vector<pdftron::PDF::DisallowedChange>;
%template(VectorAnnot) vector<pdftron::PDF::Annot>;
Expand Down
6 changes: 3 additions & 3 deletions Samples/DataExtractionTest/GO/DataExtraction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,14 @@ func GenericKeyValueTest() (err error) {
// Exclude the ad on page 2
// These coordinates are in PDF user space, with the origin at the bottom left corner of the page
// Coordinates rotate with the page, if it has rotation applied.
p2ExclusionZones.AddRect(NewRect(166, 47, 562, 222))
p2ExclusionZones.AddRect(NewRect(166.0, 47.0, 562.0, 222.0))
options.AddExclusionZonesForPage(p2ExclusionZones, 2)

p4InclusionZones := NewRectCollection()
p4ExclusionZones := NewRectCollection()
// Only include the article text for page 4, exclude ads and headings
p4InclusionZones.AddRect(NewRect(30, 432, 562, 684))
p4ExclusionZones.AddRect(NewRect(30, 657, 295, 684))
p4InclusionZones.AddRect(NewRect(30.0, 432.0, 562.0, 684.0))
p4ExclusionZones.AddRect(NewRect(30.0, 657.0, 295.0, 684.0))
options.AddInclusionZonesForPage(p4InclusionZones, 4)
options.AddExclusionZonesForPage(p4ExclusionZones, 4)

Expand Down
3 changes: 1 addition & 2 deletions Samples/EncTest/GO/Enc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ func TestEnc(t *testing.T){
for count < 3{
fmt.Println("A password required to open the document.")
var password string
fmt.Print("Please enter the password: \n")
fmt.Scanf("%s", &password)
password = userPassword
fmt.Println(password)

if doc.InitStdSecurityHandler(password, len(password)){
Expand Down
3 changes: 1 addition & 2 deletions Samples/EncTest/PHP/EncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@
for($count=0; $count<3;$count++)
{
echo "A password required to open the document.\n"
."Please enter the password:";

$password = trim(fgets(STDIN));
$password = "test";
if($doc->InitStdSecurityHandler($password, strlen($password)))
{
$success=true;
Expand Down
4 changes: 2 additions & 2 deletions Samples/EncTest/PYTHON/EncTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def main():
while count < 3:
print("A password required to open the document.")
if sys.version_info.major >= 3:
password = input("Please enter the password: \n")
password = "test"
else:
password = raw_input("Please enter the password: \n")
password = "test"

if doc.InitStdSecurityHandler(password, len(password)):
success = True
Expand Down
3 changes: 1 addition & 2 deletions Samples/EncTest/RUBY/EncTest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
count = 0
while count < 3 do
puts "A password required to open the document."
puts "Please enter the password:"
password = gets.chomp
password = "test"
if doc.InitStdSecurityHandler(password, password.length)
success = true
puts "The password is correct."
Expand Down
117 changes: 117 additions & 0 deletions Samples/HighlightsTest/GO/Highlights_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2026 by Apryse Software Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------

package main

import (
"flag"
"fmt"
"math"
"strings"
"testing"

. "github.com/pdftron/pdftron-go/v2"
)

var licenseKey string
var modulePath string

func init() {
flag.StringVar(&licenseKey, "license", "", "License key for Apryse SDK")
flag.StringVar(&modulePath, "modulePath", "", "Module path for Apryse SDK")
}

// ---------------------------------------------------------------------------------------
// This sample illustrates the basic text highlight capabilities of PDFNet.
// It simulates a full-text search engine that finds all occurrences of the word 'Federal'.
// It then highlights those words on the page.
//
// Note: The TextSearch class is the preferred solution for searching text within a single
// PDF file. TextExtractor provides search highlighting capabilities where a large number
// of documents are indexed using a 3rd party search engine.
// --------------------------------------------------------------------------------------

func TestHighlights(t *testing.T) {
// The first step in every application using PDFNet is to initialize the
// library and set the path to common PDF resources. The library is usually
// initialized only once, but calling Initialize() multiple times is also fine.
PDFNetInitialize(licenseKey)

// Relative path to the folder containing the test files.
inputPath := "../TestFiles/paragraphs_and_tables.pdf"
outputPath := "../TestFiles/Output/"

// Sample code showing how to use high-level text highlight APIs.
doc := NewPDFDoc(inputPath)
doc.InitSecurityHandler()

page := doc.GetPage(1)
if !page.IsValid() {
PDFNetTerminate()
t.Fatal("Page not found.")
}

txt := NewTextExtractor()
txt.Begin(page) // read the page

// Do not dehyphenate; that would interfere with character offsets
dehyphen := false

// Retrieve the page text
pageText := txt.GetAsText(dehyphen)

// Simulating a full-text search engine that finds all occurrences of the word 'Federal'.
// In a real application, plug in your own search engine here.
searchText := "Federal"

charRanges := NewVectorCharRange()
ofs := strings.Index(pageText, searchText)
for ofs != -1 {
cr := NewCharRange()
cr.SetIndex(ofs)
cr.SetLength(len(searchText))
charRanges.Add(cr)
next := strings.Index(pageText[ofs+1:], searchText)
if next == -1 {
break
}
ofs = ofs + 1 + next
}

// Retrieve Highlights object and apply annotations to the page
hlts := txt.GetHighlights(charRanges)
hlts.Begin(doc)

for hlts.HasNext() {
quads := hlts.GetCurrentQuads()
count := int(quads.Size())
for i := 0; i < count; i++ {
q := quads.Get(i)

// Each quad has 4 points: q.P1, q.P2, q.P3, q.P4
x1 := math.Min(math.Min(q.GetP1().GetX(), q.GetP2().GetX()), math.Min(q.GetP3().GetX(), q.GetP4().GetX()))
x2 := math.Max(math.Max(q.GetP1().GetX(), q.GetP2().GetX()), math.Max(q.GetP3().GetX(), q.GetP4().GetX()))
y1 := math.Min(math.Min(q.GetP1().GetY(), q.GetP2().GetY()), math.Min(q.GetP3().GetY(), q.GetP4().GetY()))
y2 := math.Max(math.Max(q.GetP1().GetY(), q.GetP2().GetY()), math.Max(q.GetP3().GetY(), q.GetP4().GetY()))

highlight := pdftron.HighlightAnnotCreate(
doc.GetSDFDoc(),
pdftron.NewRect(x1, y1, x2, y2),
)
highlight.RefreshAppearance()
page.AnnotPushBack(highlight)

fmt.Printf("[%.2f, %.2f, %.2f, %.2f]\n", x1, y1, x2, y2)
}

hlts.Next()
}
doc.Save(outputPath+"search_highlights.pdf", uint(SDFDocE_linearized))

doc.Close()

PDFNetTerminate()
fmt.Println("Done.")
}
109 changes: 109 additions & 0 deletions Samples/HighlightsTest/PHP/HighlightsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2026 by Apryse Software Inc. All Rights Reserved.
// Consult LICENSE.txt regarding license information.
//---------------------------------------------------------------------------------------
if(file_exists("../../../PDFNetC/Lib/PDFNetPHP.php"))
include("../../../PDFNetC/Lib/PDFNetPHP.php");
include("../../LicenseKey/PHP/LicenseKey.php");

// Relative path to the folder containing the test files.
$input_path = getcwd()."/../../TestFiles/paragraphs_and_tables.pdf";
$output_path = getcwd()."../../TestFiles/Output/";

//---------------------------------------------------------------------------------------
// This sample illustrates the basic text highlight capabilities of PDFNet.
// It simulates a full-text search engine that finds all occurrences of the word 'Federal'.
// It then highlights those words on the page.
//
// Note: The TextSearch class is the preferred solution for searching text within a single
// PDF file. TextExtractor provides search highlighting capabilities where a large number
// of documents are indexed using a 3rd party search engine.
// --------------------------------------------------------------------------------------

// The first step in every application using PDFNet is to initialize the
// library and set the path to common PDF resources. The library is usually
// initialized only once, but calling Initialize() multiple times is also fine.
PDFNet::Initialize($LicenseKey);

$example1_basic = false;
$example2_xml = false;
$example3_wordlist = false;
$example4_advanced = true;
$example5_low_level = false;

// Sample code showing how to use high-level text extraction APIs.
$doc = new PDFDoc($input_path);
$doc->InitSecurityHandler();

$page = $doc->GetPage(1);
if (!$page){
echo nl2br("Page not found.\n");
PDFNet::Terminate();
return;
}

$txt = new TextExtractor();
$txt->Begin($page); // Read the page.

// Do not dehyphenate; that would interfere with character offsets
$dehyphen = false;
# Retrieve the page text
$page_text = $txt->GetAsText($dehyphen);

// Simulating a full-text search engine that finds all occurrences of the word 'Federal'.
// In a real application, plug in your own search engine here.
$search_text = "Federal";
$char_ranges = [];

$ofs = strpos($page_text, $search_text);
while ($ofs !== false) {
$cr = new CharRange();
$cr->index = $ofs;
$cr->length = strlen($search_text);
$char_ranges[] = $cr;
$ofs = strpos($page_text, $search_text, $ofs + 1);
}

// Retrieve Highlights object and apply annotations to the page
$hlts = $txt->GetHighlights($char_ranges);
$hlts->Begin($doc);

while ($hlts->HasNext()) {

// In PHP bindings, quads are typically returned as an array
$quads = $hlts->GetCurrentQuads();
$quad_count = count($quads);

for ($i = 0; $i < $quad_count; $i++) {

// Each quad has 4 points: p1, p2, p3, p4
$q = $quads[$i];

$x1 = min($q->p1->x, $q->p2->x, $q->p3->x, $q->p4->x);
$x2 = max($q->p1->x, $q->p2->x, $q->p3->x, $q->p4->x);
$y1 = min($q->p1->y, $q->p2->y, $q->p3->y, $q->p4->y);
$y2 = max($q->p1->y, $q->p2->y, $q->p3->y, $q->p4->y);

$highlight = HighlightAnnot::Create(
$doc->GetSDFDoc(),
new Rect($x1, $y1, $x2, $y2)
);

$highlight->RefreshAppearance();
$page->AnnotPushBack($highlight);

printf("[%.2f, %.2f, %.2f, %.2f]\n", $x1, $y1, $x2, $y2);
}

$hlts->Next();
}

// Output highlighted PDF doc
$doc->Save($output_path . "search_highlights.pdf", SDFDoc::e_linearized);

$doc->Close();
echo nl2br("Done.\n");

PDFNet::Terminate();
?>
6 changes: 6 additions & 0 deletions Samples/HighlightsTest/PHP/RunTest.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo off
setlocal
set TEST_NAME=HighlightsTest
set PATH=..\..\..\PDFNetC\Lib;%PATH%
php.exe %TEST_NAME%.php
endlocal
4 changes: 4 additions & 0 deletions Samples/HighlightsTest/PHP/RunTest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
TEST_NAME=HighlightsTest
export LD_LIBRARY_PATH=../../../PDFNetC/Lib
php -d extension="../../../PDFNetC/Lib/PDFNetPHP.so" $TEST_NAME.php
Loading