Skip to content

Commit

Permalink
[RELEASE] iText pdfOCR 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
iText-CI committed Jan 30, 2024
2 parents eead8fd + e6b9ac2 commit 7657d96
Show file tree
Hide file tree
Showing 146 changed files with 1,217 additions and 190 deletions.
2 changes: 1 addition & 1 deletion doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "pdfOCR 3.0.1 API"
PROJECT_NAME = "pdfOCR 3.0.2 API"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand Down
8 changes: 4 additions & 4 deletions itext.tests/itext.pdfocr.api.tests/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Apryse Group NV")]
[assembly: AssemblyProduct("iText")]
[assembly: AssemblyCopyright ("Copyright (c) 1998-2023 Apryse Group NV")]
[assembly: AssemblyCopyright("Copyright (c) 1998-2024 Apryse Group NV")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]

[assembly: Guid("d6a6ea97-1f23-448f-b700-eff62971d234")]

[assembly: AssemblyVersion("3.0.1.0")]
[assembly: AssemblyFileVersion("3.0.1.0")]
[assembly: AssemblyInformationalVersion("3.0.1")]
[assembly: AssemblyVersion("3.0.2.0")]
[assembly: AssemblyFileVersion("3.0.2.0")]
[assembly: AssemblyInformationalVersion("3.0.2")]
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj')" />
<PackageReference Include="itext.pdftest" Version="8.0.2" Condition="!Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj')" />
<PackageReference Include="itext.pdftest" Version="8.0.3" Condition="!Exists('..\..\..\itextcore\itext\itext.pdftest\itext.pdftest.csproj')" />
<ProjectReference Include="..\..\..\itextcore\itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj" Condition="Exists('..\..\..\itextcore\itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj')" />
<PackageReference Include="itext.bouncy-castle-adapter" Version="8.0.2" Condition="!Exists('..\..\..\itextcore\itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj')" />
<PackageReference Include="itext.bouncy-castle-adapter" Version="8.0.3" Condition="!Exists('..\..\..\itextcore\itext\itext.bouncy-castle-adapter\itext.bouncy-castle-adapter.csproj')" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
Expand Down
34 changes: 33 additions & 1 deletion itext.tests/itext.pdfocr.api.tests/itext/pdfocr/ApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down Expand Up @@ -30,7 +30,9 @@ You should have received a copy of the GNU Affero General Public License
using iText.Kernel.Font;
using iText.Kernel.Geom;
using iText.Kernel.Pdf;
using iText.Kernel.Utils;
using iText.Pdfa;
using iText.Pdfocr.Exceptions;
using iText.Pdfocr.Helpers;
using iText.Pdfocr.Logs;
using iText.Test;
Expand Down Expand Up @@ -193,6 +195,36 @@ public virtual void TestImageRotationHandlerForTiff() {
;
}

[NUnit.Framework.Test]
public virtual void TestTableStructureTree() {
String pdfPath = PdfHelper.GetTargetDirectory() + "tableStructureTree.pdf";
// Image doesn't really matter here
String input = PdfHelper.GetImagesTestDirectory() + "numbers_01.jpg";
IOcrEngine ocrEngine = new TestStructureDetectionOcrEngine();
OcrPdfCreatorProperties creatorProperties = new OcrPdfCreatorProperties();
creatorProperties.SetTextColor(DeviceRgb.RED);
creatorProperties.SetTagged(true);
OcrPdfCreator pdfCreator = new OcrPdfCreator(ocrEngine, creatorProperties);
TestProcessProperties processProperties = new TestProcessProperties(5, 6, 50, 15, 100, 200);
using (PdfWriter pdfWriter = PdfHelper.GetPdfWriter(pdfPath)) {
pdfCreator.CreatePdf(JavaCollectionsUtil.SingletonList<FileInfo>(new FileInfo(input)), pdfWriter, new DocumentProperties
(), processProperties).Close();
}
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(pdfPath, PdfHelper.TEST_DIRECTORY + "cmp_tableStructureTree.pdf"
, PdfHelper.GetTargetDirectory(), "diff_"));
}

[NUnit.Framework.Test]
[LogMessage(PdfOcrExceptionMessageConstant.CANNOT_CREATE_PDF_DOCUMENT, LogLevel = LogLevelConstants.ERROR)]
public virtual void TestTaggingNotSupported() {
String input = PdfHelper.GetImagesTestDirectory() + "numbers_01.jpg";
String pdfPath = PdfHelper.GetTargetDirectory() + "taggingNotSupported.pdf";
Exception e = NUnit.Framework.Assert.Catch(typeof(PdfOcrException), () => PdfHelper.CreatePdf(pdfPath, new
FileInfo(input), new OcrPdfCreatorProperties().SetTagged(true)));
NUnit.Framework.Assert.AreEqual(MessageFormatUtil.Format(PdfOcrExceptionMessageConstant.CANNOT_CREATE_PDF_DOCUMENT
, PdfOcrExceptionMessageConstant.TAGGING_IS_NOT_SUPPORTED), e.Message);
}

internal class NotImplementedImageRotationHandler : IImageRotationHandler {
public virtual ImageData ApplyRotation(ImageData imageData) {
throw new Exception("applyRotation is not implemented");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using iText.Pdfocr;

namespace iText.Pdfocr.Helpers {
public class TestProcessProperties : IOcrProcessProperties {
private float cellWidth;

private float cellHeight;

private float startX;

private float startY;

private int rowCount;

private int columnCount;

public TestProcessProperties(int rowCount, int columnCount, float cellWidth, float cellHeight, float startX
, float startY) {
this.rowCount = rowCount;
this.columnCount = columnCount;
this.cellWidth = cellWidth;
this.cellHeight = cellHeight;
this.startX = startX;
this.startY = startY;
}

public virtual int GetRowCount() {
return rowCount;
}

public virtual int GetColumnCount() {
return columnCount;
}

public virtual float GetCellWidth() {
return cellWidth;
}

public virtual float GetCellHeight() {
return cellHeight;
}

public virtual float GetStartX() {
return startX;
}

public virtual float GetStartY() {
return startY;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
For commercial licensing, contact us at https://itextpdf.com/sales. For AGPL licensing, see below.
AGPL licensing:
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System.Collections.Generic;
using System.IO;
using iText.Kernel.Geom;
using iText.Pdfocr;
using iText.Pdfocr.Structuretree;

namespace iText.Pdfocr.Helpers {
public class TestStructureDetectionOcrEngine : IOcrEngine {
public TestStructureDetectionOcrEngine() {
}

public virtual IDictionary<int, IList<TextInfo>> DoImageOcr(FileInfo input) {
return null;
}

public virtual IDictionary<int, IList<TextInfo>> DoImageOcr(FileInfo input, OcrProcessContext ocrProcessContext
) {
TestProcessProperties processProperties = (TestProcessProperties)ocrProcessContext.GetOcrProcessProperties
();
IList<TextInfo> textItems = new List<TextInfo>();
TableTreeItem table = new TableTreeItem();
float cellWidth = processProperties.GetCellWidth();
float cellHeight = processProperties.GetCellHeight();
float startX = processProperties.GetStartX();
float startY = processProperties.GetStartY();
float x = startX;
float y = startY;
for (int i = 0; i < processProperties.GetRowCount(); ++i) {
TableRowTreeItem row = null;
if (i > 0) {
row = new TableRowTreeItem();
table.AddRow(row);
}
for (int j = 0; j < processProperties.GetColumnCount(); ++j) {
TextInfo textInfo = new TextInfo(i + " " + j, new Rectangle(x, y, cellWidth, cellHeight));
// Mark the 1st row item as artifacts
if (i == 0) {
textInfo.SetLogicalStructureTreeItem(ArtifactItem.GetInstance());
}
else {
TableCellTreeItem cell = new TableCellTreeItem();
row.AddCell(cell);
ParagraphTreeItem paragraph = new ParagraphTreeItem();
cell.AddChild(paragraph);
SpanTreeItem span = new SpanTreeItem();
paragraph.AddChild(span);
textInfo.SetLogicalStructureTreeItem(span);
}
textItems.Add(textInfo);
x += cellWidth;
}
x = startX;
y -= cellHeight;
}
IDictionary<int, IList<TextInfo>> result = new Dictionary<int, IList<TextInfo>>();
result.Put(1, textItems);
return result;
}

public virtual void CreateTxtFile(IList<FileInfo> inputImages, FileInfo txtFile) {
}

public virtual void CreateTxtFile(IList<FileInfo> inputImages, FileInfo txtFile, OcrProcessContext ocrProcessContext
) {
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
This file is part of the iText (R) project.
Copyright (c) 1998-2023 Apryse Group NV
Copyright (c) 1998-2024 Apryse Group NV
Authors: Apryse Software.
This program is offered under a commercial and under the AGPL license.
Expand Down
Loading

0 comments on commit 7657d96

Please sign in to comment.