Skip to content

Commit

Permalink
Add TextLines methods, samples, CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
iAJTin committed Aug 3, 2022
1 parent a1a36db commit a978620
Show file tree
Hide file tree
Showing 73 changed files with 575 additions and 27 deletions.
73 changes: 70 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,83 @@

All notable changes to this project will be documented in this file.

## 1.0.4 -
## [1.0.4] - 2022-08-04

### Fixes
### Added

1. Add **TextLines** method to **PdfInput** class, for get the lines of text for an **PdfInput**, optionally you can set both the start and end pages and a value indicating whether blank lines are included in the result or uses a predicate for filtering

```csharp
// Creates pdf file reference
var doc = new PdfInput
{
Input = "~/Resources/Sample-24/file-sample.pdf"
};

### Added
// Extract text lines (Remove empty lines)
try
{
var textLines = doc.TextLines();

logger.Info(" > Document lines (Remove empty lines)");
logger.Info($" > Count: {textLines.Count()}");
}
catch
{
logger.Info(" > Error while extract text lines");
}

// Extract text lines (Include empty lines)
try
{
var textLines = doc.TextLines(removeEmptyLines: false);

logger.Info(" > Document lines (Include empty lines)");
logger.Info($" > Count: {textLines.Count()}");
}
catch
{
logger.Info(" > Error while extract text lines");
}

// Extract text lines (predicate)
try
{
var textLines = doc.TextLines(line => line.Text.Trim() == "#TITLE#");

logger.Info(" > Document lines (Predicate)");
logger.Info($" > Count: {textLines.Count()}");
}
catch
{
logger.Info(" > Error while extract text lines");
}
```

### Changed

- Library versions for this version

| Library | Version | Description |
|:------|:------|:----------|
| iTin.Core | 2.0.0.4 | Base library containing various extensions, helpers, common constants |
| iTin.Core.Drawing | 1.0.0.2 | Drawing objects, extension, helpers, common constants |
| iTin.Core.Hardware.Common | 1.0.0.3 | Common Hardware Infrastructure |
| iTin.Core.Hardware.Linux.Devices.Graphics.Font | 1.0.0.0 | Linux Hardware Infrastructure |
| iTin.Core.Hardware.MacOS.Devices.Graphics.Font | 1.0.0.0 | MacOS Hardware Infrastructure |
| iTin.Core.Hardware.Windows.Devices.Graphics.Font | 1.0.0.0 | Windows Hardware Infrastructure |
| iTin.Core.IO | 1.0.0.2 | Common I/O calls |
| iTin.Core.IO.Compression | 1.0.0.2 | Compression library |
| iTin.Core.Interop.Shared | 1.0.0.2 | Generic Shared Interop Definitions |
| iTin.Core.Interop.Windows.Devices | 1.0.0.0 | Win32 Generic Interop Calls |
| iTin.Core.Models | 1.0.0.2 | Data models base |
| iTin.Core.Models.Design.Charting | 1.0.0.2 | Base charting models |
| iTin.Core.Models.Design.Styling | 1.0.0.2 | Base styling models |
| iTin.Logging | 1.0.0.1 | Logging library |
| iTin.Hardware.Abstractions.Devices.Graphics.Font | 1.0.0.0 | Generic Common Hardware Abstractions |
| iTin.Registry.Windows | 1.0.0.2 | Windows registry access |
| iTin.Utilities.Pdf.Design | **1.0.0.4** | Pdf design objects |
| iTin.Utilities.Pdf.Writer | **1.0.0.3** | Pdf Writer |

## [1.0.3] - 2022-08-03

Expand Down
48 changes: 47 additions & 1 deletion README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,55 @@ iPdfWriter is a lightweight implementation that allows modifying a pdf document
Changes in this version 1.0.4
=============================

· Fixes
· Added
-----

- Add TextLines method to PdfInput class for get the lines of text for an PdfInput, optionally you can set both the start and end pages and a value indicating whether blank lines are included in the result
or uses a predicate for filtering.


· Changed
-------

•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| Library Version Description |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core 2.0.0.4 Base library containing various extensions, helpers, common constants |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Drawing 1.0.0.2 Drawing objects, extension, helpers, common constants |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Hardware.Common 1.0.0.3 Common Hardware Infrastructure |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Hardware.Linux.Devices.Graphics.Font 1.0.0.0 Linux Hardware Infrastructure |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Hardware.MacOS.Devices.Graphics.Font 1.0.0.0 MacOS Hardware Infrastructure |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Hardware.Windows.Devices.Graphics.Font 1.0.0.0 Windows Hardware Infrastructure |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.IO 1.0.0.1 Common I/O calls |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.IO.Compression 1.0.0.1 Compression library |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Interop.Shared 1.0.0.2 Generic Shared Interop Definitions |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Interop.Windows.Devices 1.0.0.0 Win32 Generic Interop Calls |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Models 1.0.0.2 Data models base |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Models.Design.Charting 1.0.0.2 Base charting models |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Core.Models.Design.Styling 1.0.0.2 Base styling models |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Logging 1.0.0.1 Logging library |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Hardware.Abstractions.Devices.Graphics.Font 1.0.0.0 Generic Common Hardware Abstractions |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Registry.Windows 1.0.0.2 Windows registry acces |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Utilities.Pdf.Design 1.0.0.4 Pdf design elements |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•
| iTin.Utilities.Pdf.Writer 1.0.0.3 Pdf writer |
•———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————•

v1.0.3
======
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

namespace iTin.Utilities.Pdf.Design.Text
{
/// <summary>
/// Defines a <b>pdf</b> text line object.
/// </summary>
public sealed class PdfTextLine
{
#region constructor/s

#region [private] PdfText(string, int): Initializes a new instance of the class with a native pdf table reference
/// <summary>
/// Initializes a new instance of the <see cref="PdfText"/> class.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="page">The page.</param>
public PdfTextLine(string text, int page)
{
Text = text;
Page = page;
}
#endregion

#endregion

#region public properties

#region [public] (string) Text: Gets or sets the text
/// <summary>
/// Gets or sets the text.
/// </summary>
/// <value>
/// The text.
/// </value>
public string Text { get; set; }
#endregion

#region [public] (int) Page: Gets or sets the page
/// <summary>
/// Gets or sets the page.
/// </summary>
/// <value>
/// The page.
/// </value>
public int Page { get; set; }
#endregion

#endregion

#region public override methods

#region [public] {override} (string) ToString(): Returns a string than represents the current object.
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>A <see cref="string" /> that represents this instance.</returns>
public override string ToString() => $"Text=\"{Text}\", Page={Page}";
#endregion

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
<Version>1.0.0.3</Version>
<Version>1.0.0.4</Version>
<Description>Pdf design elements</Description>
<Copyright>Copyright © 2020</Copyright>
<PackageProjectUrl></PackageProjectUrl>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@

using System;
using System.Collections.Generic;
using System.IO;

using iTin.Core.ComponentModel;
using iTin.Core.ComponentModel.Results;

using iTin.Utilities.Pdf.Design.Text;
using iTin.Utilities.Pdf.Writer.ComponentModel.Input;
using iTin.Utilities.Pdf.Writer.ComponentModel.Result.Insert;
using iTin.Utilities.Pdf.Writer.ComponentModel.Result.Output;
Expand Down Expand Up @@ -129,6 +132,27 @@ public interface IInput
/// </returns>
IResult SaveToFile(string outputPath, SaveOptions options = null);

/// <summary>
/// Gets the lines of text for this <see cref="PdfInput"/>, filtered values based on a predicate.
/// </summary>
/// <param name="predicate">A function to test each element for a condition.</param>
/// <returns></returns>
/// <exception cref="ArgumentException">If document has no pages</exception>
/// <exception cref="ArgumentNullException">If <paramref name="predicate"/> is <see langword="null"/></exception>
IEnumerable<PdfTextLine> TextLines(Func<PdfTextLine, bool> predicate);

/// <summary>
/// Gets the lines of text for this <see cref="PdfInput"/>, optionally you can set both the start and end pages and a value indicating whether blank lines are included in the result.
/// </summary>
/// <param name="fromPage">Defines start page. If a value is not set, it will default to 1</param>
/// <param name="toPage">Defines end page. If a value is not set, it will default to total document pages</param>
/// <param name="removeEmptyLines">Indicates whether blank lines are included in the result. By default they are not included</param>
/// <returns></returns>
/// <exception cref="ArgumentException">If document has no pages</exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="fromPage"/> is less than one or is greater than the total number of pages of the document</exception>
/// <exception cref="ArgumentOutOfRangeException">If <paramref name="toPage"/> is less than one or is greater than the total number of pages of the document</exception>
IEnumerable<PdfTextLine> TextLines(int? fromPage = null, int? toPage = null, bool removeEmptyLines = true);

/// <summary>
/// Convert this input into a stream object.
/// </summary>
Expand Down
Loading

0 comments on commit a978620

Please sign in to comment.