Commit Graph

1564 Commits

Author SHA1 Message Date
Arnaud TAMAILLON
4f2a0976e3 Fix parsing of hexadecimal strings with odd number of characters 2024-09-01 09:02:37 +01:00
Arnaud TAMAILLON
05e6a894d0 Fix reading encryption byte strings 2024-09-01 08:54:20 +01:00
Arnaud TAMAILLON
b824fb2b14 Support trailer info to be a dictionary instead of an indirect reference 2024-08-31 09:26:43 +01:00
BobLd
b4649758c6 Restore checking for correct image size in PngFromPdfImageFactory 2024-08-20 19:18:31 +01:00
BobLd
a8684984eb Fix DoubleComparer precision in tests 2024-08-20 19:17:45 +01:00
BobLd
56baa3592b Simplify PdfRectangle width and height computation and fix tests 2024-08-20 19:17:45 +01:00
BobLd
a99c0d25bf Fix GeometryExtensions.Contains() when rectangle area is 0 2024-07-20 21:43:16 +01:00
BobLd
65c644f150 Minor performance optimisations in GeometryExtensions 2024-07-01 18:34:13 +01:00
BobLd
bac00e475b Improve KdTree creation performance 2024-06-27 23:20:16 +02:00
BobLd
b05dfac672 Further performance improvements in DocstrumBoundingBoxes 2024-06-27 23:19:55 +02:00
BobLd
14e7024545 Reduce memory allocation in DocstrumBoundingBoxes 2024-06-25 15:01:30 +02:00
davebrokit
dc933aede9 Fix issues in Advanced Example in README.md 2024-06-24 12:14:41 +02:00
BobLd
d2cae7985c Tidy up documentation 2024-06-11 18:20:28 +01:00
BobLd
d96ec7a9af Make DirectObjectFinder public 2024-06-11 18:20:28 +01:00
BobLd
531e00e9c9 Make DictionaryTokenExtensions and ArrayTokenExtensions public 2024-06-11 18:20:28 +01:00
BobLd
affc1ed8b5
Seal and update IFilters to return ReadOnlyMemory<byte> (#843)
* Avoid ToArray() in memoryFactory

* Seal and update IFilters to return ReadOnlyMemory<byte>

* Fix filter tests

* Seal and update IFilters to return ReadOnlyMemory<byte>
2024-06-08 06:16:09 +01:00
Sylvain Bruyere
65a18b200f
Improve TryReadStream with simplification & fix of Stream Invalid Length cutting off Streams (#838)
* Improve TryReadStream with simplification & fix of Stream Invalid Length cutting off Streams

- Fix of Stream invalid Length issue causing stream data being cut off: fix https://github.com/UglyToad/PdfPig/issues/809

- Improve Stream Token read performance by:
  -  simplifying TryReadStream(), avoiding use of MemoryStream, with benefice of already existing Memory Span of "inputBytes"
  - removing the unecessary List<>

* Add Stream with Invalid Length unit test

* Use of Memory<> instead of direct Span to avoid byte array allocation .ToArray.
Suggestion from (4153e4a1b4 (r1619509165))
2024-05-31 07:16:56 +01:00
davebrokit
d7e434edaa
#836 Fix UnsupervisedReadingOrder orders 2 blocks on the same row out of order (#841)
* #836 Fix UnsupervisedReadingOrder orders 2 blocks on the same row out of order
Add images for documentation

* Update Documentation: Additional example, Reference to wiki

* Change code formating to C# on documentation

* Fix link in documentation

* Fix Spelling

---------

Co-authored-by: David <David@david>
2024-05-29 22:16:05 +01:00
Richard Webb
d86c2f44f0
Use a fixed list of operations in ReflectionGraphicsStateOperationFac… (#832)
* Use a fixed list of operations in ReflectionGraphicsStateOperationFactory rather than searching via reflection.

* Add a unit test to check that ReflectionGraphicsStateOperationFactory.operations contains all supported graphics operations
2024-05-09 06:57:14 +01:00
BobLd
5a8e6179da Add AndroidSystemFontLister 2024-05-08 19:13:36 +01:00
Richard Webb
995f287e0d
Update the dependencies in UglyToad.PdfPig.Package (#835) 2024-05-07 20:21:04 +01:00
Richard Webb
937793bec7 Update Github actions in the CI build 2024-05-06 17:38:00 +01:00
Richard Webb
2cf8762128 Conditionalize the formatter based serialization bits in InvalidFontFormatException 2024-05-06 17:37:15 +01:00
Jason Nelson
c6a7a2d0a2
Improve Code Quality (#831)
* Introduce globals

* Spanify TransformationMatrix.FromArray

* Eliminate allocation in GeometryExtensions.ParametricPerpendicularProjection

* Eliminate allocation in CrossReferenceTablePart.Parse

* Optimize Adam7 (eliminate virtual calls)

* Spanify QuadPointsQuadrilateral.Points to eliminate virtual calls

* Eliminate allocation in PdfRectangle.Normalize

* Format TransformMatrix

* Pass TransformationMatrix  by reference in TransformationMatrix.Multiply

* Seal NoTextTokenWriter
2024-05-06 07:38:06 +01:00
Richard Webb
b6e0305a1c Fix a compile error in the Examples project 2024-05-05 11:01:28 +01:00
Jason Nelson
da44e1a540
Improve code quality (#825)
* Avoid encoding ASCII in more cases

* Make Space a const

* Use WriteWhiteSpace extension to eliminate possible virtual call

* Use ASCII when encoding constrained character subset

* Simplify pragmas

* Revert Whitespace rename

* Fix using statement order

* Remove obsolete serialization support on .NET

* Remove obsolete serialization support on .NET (part 2)
2024-05-03 07:36:19 +01:00
Jason Nelson
7f42a8d60c
Reduce Allocations (#821)
* Introduce ValueStringBuilder

* Make NumericTokenizer and PlanTextTokenizer thread-safe

* Replace ListPool with ArrayPoolBufferWriter

* Seal ITokenizer classes

* Eliminate array allocation in Type1ArrayTokenizer

* Eliminate array allocation in AcroFormFactory

* Eliminate StringBuilder allocation in Page.GetText

* Optimize PdfSubpath.ToLines

* Eliminate various allocations when parsing CompactFontFormat

* Remove unused FromOctalInt helper

* Ensure Pdf.Content is not null

* Write ASCII values directly to stream (avoiding allocations)

* Avoid encoding additional ASCII values

* Eliminate allocations in TokenWriter.WriteName

* Eliminate allocation in TokenWriter.WriteNumber

* Add System.Memory reference to Fonts
2024-04-28 18:55:58 +01:00
Jason Nelson
1ef2e127a6
Improve Code Quality (#818)
* Make AdobeFontMetricsLigature a struct

* Make AdobeFontMetricsCharacterSize a struct

* Eliminate allocation in CompactFontFormatData

* Pass TransformationMatrix  by reference

* Seal Encoding classes

* Make SubTableHeaderEntry a readonly struct

* Introduce StringSplitter and eliminate various allocations in GlyphListFactory

* Eliminate a few substring allocations

* Use char overload on StringBuilder

* Eliminate virtual calls on stringIndex

* Optimize ReadHelper ReadLong and ReadInt methods

* Add additional readonly annotations to PdfRectangle

* Optimize NameTokenizer

* Eliminate allocation in TrueTypeGlyphTableSubsetter

* Use empty arrays

* Eliminate allocations in OperationWriteHelper.WriteHex

* Use simplified DecryptCbc method on .NET 6+

* Fix windows-1252 encoding not working on net6.0 and 8.0

* Update int buffers to exact unsigned max length and eliminate additional byte allocation

* Fix typo

* Remove unused constant
2024-04-18 19:58:40 +01:00
Jason Nelson
0f7077b257 Improve stream overrides 2024-04-12 07:42:19 +01:00
Jason Nelson
90e07bc639 Eliminate allocations in PatternParser, PdfFunctionParser, and ShadingParser 2024-04-12 07:42:19 +01:00
Jason Nelson
c3a2e8c08f Rename TryGetMemory -> TryGetBytesAsMemory 2024-04-12 07:42:19 +01:00
Jason Nelson
fc1a41ffbb Remove unused StreamHelper methods 2024-04-12 07:42:19 +01:00
Jason Nelson
a5e9b438cc Eliminate allocation in BasePageFactory 2024-04-12 07:42:19 +01:00
Jason Nelson
215e12543c Format ImageHeader 2024-04-12 07:42:19 +01:00
Jason Nelson
a68febfa95 React to IPdfImage change 2024-04-12 07:42:19 +01:00
Jason Nelson
49c155cca2 Add IPdfImage.RawBytes 2024-04-12 07:42:19 +01:00
Jason Nelson
bd95adf4bc Optimize RunLengthFilter 2024-04-12 07:42:19 +01:00
Jason Nelson
b498f5a076 Eliminate allocation in AsciiHexDecodeFilter 2024-04-12 07:42:19 +01:00
Jason Nelson
d85ea4f95d Update Filters to operate over Spans 2024-04-12 07:42:19 +01:00
Jason Nelson
0efa68a8e4 Optimize Crc32 calculations 2024-04-12 07:42:19 +01:00
Jason Nelson
4ad6bfc74e [Fonts] Add Encoding.GetString(ReadOnlySpan<byte>) polyfill 2024-04-12 07:42:19 +01:00
Jason Nelson
ce5dc7c1a1 Eliminate byte[] allocation in RC4 2024-04-12 07:42:19 +01:00
Jason Nelson
fba5b60718 [Fonts] Add Stream.Write(Span<byte>) polyfill 2024-04-12 07:42:19 +01:00
Jason Nelson
e01bf5e849 Spanify IInputBytes 2024-04-12 07:42:19 +01:00
Jason Nelson
775d1343ae Spanify PngBuilder 2024-04-12 07:42:19 +01:00
Jason Nelson
435da86a25 Make QuadPointsQuadrilateral a readonly struct 2024-04-12 07:42:19 +01:00
Jason Nelson
8babdfdda5 Reduce ColorSpaceDetails virtual calls 2024-04-12 07:42:19 +01:00
Jason Nelson
4fcc5c6c57 Eliminate a few allocations in ColorSpace transformers 2024-04-12 07:42:19 +01:00
Jason Nelson
6d54355754 Spanify filters 2024-04-12 07:42:19 +01:00
BobLd
2d6cb1aa0c Properly implement Quadtratic and Cubic bezier-curves and use Quadtratic in CalculatePath to fix #625 2024-04-05 11:33:59 +01:00