mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-01-18 19:51:24 +08:00
add doc comments, make point size internal until I can learn matrices, add test case for ascii 85 filter, add test case for document text
This commit is contained in:
@@ -41,7 +41,7 @@ O<DJ+*.@<*K0@<6L(Df-\0Ec5e;DffZ(EZee.Bl.9pF""AGXBPCsi + DGm >@3BB / F * &OCAfu2
|
||||
|
||||
Assert.Equal("Man \0\0\0\0is d", text);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ZInMiddleOf5CharacterSequenceThrows()
|
||||
{
|
||||
@@ -52,6 +52,16 @@ O<DJ+*.@<*K0@<6L(Df-\0Ec5e;DffZ(EZee.Bl.9pF""AGXBPCsi + DGm >@3BB / F * &OCAfu2
|
||||
Assert.Throws<InvalidOperationException>(action);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SingleCharacterLastThrows()
|
||||
{
|
||||
var bytes = Encoding.ASCII.GetBytes("9jqo^B");
|
||||
|
||||
Action action = () => filter.Decode(bytes, new PdfDictionary(), 1);
|
||||
|
||||
Assert.Throws<ArgumentOutOfRangeException>(action);
|
||||
}
|
||||
|
||||
private const string PdfContent = @"1 0 obj
|
||||
<< /Length 568 >>
|
||||
stream
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Xunit;
|
||||
|
||||
public class FontSizeTestFromGoogleChromeTests
|
||||
@@ -35,5 +36,18 @@
|
||||
Assert.Equal(842, page.Height);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetsCorrectPageTextIgnoringHiddenCharacters()
|
||||
{
|
||||
using (var document = PdfDocument.Open(GetFilename()))
|
||||
{
|
||||
var page = document.GetPage(1);
|
||||
|
||||
var text = string.Join(string.Empty, page.Letters.Select(x => x.Value));
|
||||
|
||||
Assert.Equal("Hello, this is 16ptHello, this is 16px", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
/// </summary>
|
||||
public string Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The lower-left position of the letter. Letters with descenders will extend below this point.
|
||||
/// </summary>
|
||||
public PdfPoint Location { get; }
|
||||
|
||||
/// <summary>
|
||||
@@ -17,9 +20,9 @@
|
||||
public decimal Width { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Size defined by the Tj operator prior to our possibly incorrect transformation.
|
||||
/// Size as defined in the PDF file. This is not equivalent to font size in points but is relative to other font sizes on the page.
|
||||
/// </summary>
|
||||
internal decimal FontSize { get; }
|
||||
public decimal FontSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the font.
|
||||
@@ -27,10 +30,13 @@
|
||||
public string FontName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The size of the font in points.
|
||||
/// The size of the font in points. This is not ready for public consumption as the calculation is incorrect.
|
||||
/// </summary>
|
||||
public decimal PointSize { get; }
|
||||
internal decimal PointSize { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a new letter to represent some text drawn by the Tj operator.
|
||||
/// </summary>
|
||||
internal Letter(string value, PdfPoint location, decimal width, decimal fontSize, string fontName, decimal pointSize)
|
||||
{
|
||||
Value = value;
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
namespace UglyToad.Pdf.Geometry
|
||||
{
|
||||
/// <summary>
|
||||
/// A point in a PDF file.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// PDF coordinates are defined with the origin at the lower left (0, 0).
|
||||
/// The Y-axis extends vertically upwards and the X-axis horizontally to the right.
|
||||
/// Unless otherwise specified on a per-page basis, units in PDF space are equivalent to a typographic point (1/72 inch).
|
||||
/// </remarks>
|
||||
public struct PdfPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// The origin of the coordinates system.
|
||||
/// </summary>
|
||||
public static PdfPoint Origin = new PdfPoint(0m, 0m);
|
||||
|
||||
/// <summary>
|
||||
/// The X coordinate for this point. (Horizontal axis).
|
||||
/// </summary>
|
||||
public decimal X { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Y coordinate of this point. (Vertical axis).
|
||||
/// </summary>
|
||||
public decimal Y { get; }
|
||||
|
||||
public PdfPoint(decimal x, decimal y)
|
||||
|
||||
Reference in New Issue
Block a user