diff --git a/src/UglyToad.PdfPig.Tests/Integration/MultiplePageMortalityStatisticsTests.cs b/src/UglyToad.PdfPig.Tests/Integration/MultiplePageMortalityStatisticsTests.cs index 901a6d95..addc0709 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/MultiplePageMortalityStatisticsTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/MultiplePageMortalityStatisticsTests.cs @@ -30,7 +30,7 @@ { using (var document = PdfDocument.Open(GetFilename())) { - Assert.Equal(1.7m, document.Version); + Assert.Equal(1.7, document.Version); } } diff --git a/src/UglyToad.PdfPig.Tests/Integration/SwedishTouringCarChampionshipTests.cs b/src/UglyToad.PdfPig.Tests/Integration/SwedishTouringCarChampionshipTests.cs index 29b98354..ed842a81 100644 --- a/src/UglyToad.PdfPig.Tests/Integration/SwedishTouringCarChampionshipTests.cs +++ b/src/UglyToad.PdfPig.Tests/Integration/SwedishTouringCarChampionshipTests.cs @@ -25,7 +25,7 @@ { using (var document = PdfDocument.Open(GetFilename())) { - Assert.Equal(1.4m, document.Version); + Assert.Equal(1.4, document.Version); } } diff --git a/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs b/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs index 33fc5187..22418c4b 100644 --- a/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs +++ b/src/UglyToad.PdfPig.Tests/Parser/Parts/FileHeaderParserTests.cs @@ -50,7 +50,7 @@ var result = FileHeaderParser.Parse(scanner.scanner, scanner.bytes, false, log); - Assert.Equal(1.2m, result.Version); + Assert.Equal(1.2, result.Version); Assert.Equal(TestEnvironment.IsSingleByteNewLine(input) ? 7 : 9, result.OffsetInFile); } @@ -73,7 +73,7 @@ var result = FileHeaderParser.Parse(scanner.scanner, scanner.bytes, false, log); - Assert.Equal(1.2m, result.Version); + Assert.Equal(1.2, result.Version); Assert.Equal(TestEnvironment.IsSingleByteNewLine(input) ? 12 : 13, result.OffsetInFile); } @@ -86,7 +86,7 @@ var result = FileHeaderParser.Parse(scanner.scanner, scanner.bytes, true, log); - Assert.Equal(1.7m, result.Version); + Assert.Equal(1.7, result.Version); Assert.Equal(TestEnvironment.IsSingleByteNewLine(input) ? 12 : 13, result.OffsetInFile); } @@ -100,7 +100,7 @@ three %PDF-1.6"; var result = FileHeaderParser.Parse(scanner.scanner, scanner.bytes, true, log); - Assert.Equal(1.6m, result.Version); + Assert.Equal(1.6, result.Version); Assert.Equal(TestEnvironment.IsSingleByteNewLine(s) ? 14 : 15, result.OffsetInFile); } @@ -131,7 +131,7 @@ three %PDF-1.6"; var result = FileHeaderParser.Parse(scanner.scanner, scanner.bytes, true, log); - Assert.Equal(1.4m, result.Version); + Assert.Equal(1.4, result.Version); } [Fact] @@ -156,7 +156,7 @@ three %PDF-1.6"; var result = FileHeaderParser.Parse(scanner, bytes, false, log); - Assert.Equal(1.7m, result.Version); + Assert.Equal(1.7, result.Version); } [Fact] @@ -175,7 +175,7 @@ three %PDF-1.6"; Assert.Equal(0, scanner.scanner.CurrentPosition); Assert.Equal(128, result.OffsetInFile); - Assert.Equal(1.1m, result.Version); + Assert.Equal(1.1, result.Version); Assert.Equal("PDF-1.1", result.VersionString); } } diff --git a/src/UglyToad.PdfPig.Tests/Writer/PdfMergerTests.cs b/src/UglyToad.PdfPig.Tests/Writer/PdfMergerTests.cs index 62901ade..ad6d34f9 100644 --- a/src/UglyToad.PdfPig.Tests/Writer/PdfMergerTests.cs +++ b/src/UglyToad.PdfPig.Tests/Writer/PdfMergerTests.cs @@ -56,7 +56,7 @@ Assert.Equal(2, document.NumberOfPages); if (checkVersion) { - Assert.Equal(1.5m, document.Version); + Assert.Equal(1.5, document.Version); } var page1 = document.GetPage(1); diff --git a/src/UglyToad.PdfPig/Content/HeaderVersion.cs b/src/UglyToad.PdfPig/Content/HeaderVersion.cs index fc09b4e0..fd61a898 100644 --- a/src/UglyToad.PdfPig/Content/HeaderVersion.cs +++ b/src/UglyToad.PdfPig/Content/HeaderVersion.cs @@ -4,7 +4,7 @@ internal class HeaderVersion { - public decimal Version { get; } + public double Version { get; } public string VersionString { get; } @@ -13,7 +13,7 @@ /// public long OffsetInFile { get; } - public HeaderVersion(decimal version, string versionString, long offsetInFile) + public HeaderVersion(double version, string versionString, long offsetInFile) { Version = version; VersionString = versionString; diff --git a/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderParser.cs b/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderParser.cs index b2e979b9..050dd103 100644 --- a/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderParser.cs +++ b/src/UglyToad.PdfPig/Parser/FileStructure/FileHeaderParser.cs @@ -69,9 +69,9 @@ return HandleMissingVersion(comment, isLenientParsing, log); } - const int toDecimalStartLength = 4; + const int toDoubleStartLength = 4; - if (!decimal.TryParse(comment.Data.Substring(toDecimalStartLength), + if (!double.TryParse(comment.Data.Substring(toDoubleStartLength), NumberStyles.Number, CultureInfo.InvariantCulture, out var version)) @@ -120,7 +120,7 @@ if (actualIndex >= 0 && content.Length - actualIndex >= versionLength) { var numberPart = content.Substring(actualIndex + 5, 3); - if (decimal.TryParse( + if (double.TryParse( numberPart, NumberStyles.Number, CultureInfo.InvariantCulture, @@ -152,7 +152,7 @@ { log.Warn($"Did not find a version header of the correct format, defaulting to 1.4 since lenient. Header was: {comment.Data}."); - return new HeaderVersion(1.4m, "PDF-1.4", 0); + return new HeaderVersion(1.4, "PDF-1.4", 0); } throw new PdfDocumentFormatException($"The comment which should have provided the version was in the wrong format: {comment.Data}."); diff --git a/src/UglyToad.PdfPig/PdfDocument.cs b/src/UglyToad.PdfPig/PdfDocument.cs index 65826986..19ca1247 100644 --- a/src/UglyToad.PdfPig/PdfDocument.cs +++ b/src/UglyToad.PdfPig/PdfDocument.cs @@ -52,7 +52,7 @@ public DocumentInformation Information { get; } /// - /// Access to the underlying raw structure of the document. + /// Access to the underlying raw structure of the document. /// [NotNull] public Structure Structure { get; } @@ -65,7 +65,7 @@ /// /// The version number of the PDF specification which this file conforms to, for example 1.4. /// - public decimal Version => version.Version; + public double Version => version.Version; /// /// Get the number of pages in this document. diff --git a/src/UglyToad.PdfPig/Writer/IPdfStreamWriter.cs b/src/UglyToad.PdfPig/Writer/IPdfStreamWriter.cs index cac1b1de..98d5941d 100644 --- a/src/UglyToad.PdfPig/Writer/IPdfStreamWriter.cs +++ b/src/UglyToad.PdfPig/Writer/IPdfStreamWriter.cs @@ -50,7 +50,7 @@ /// Initializes the PDF stream with pdf header. /// /// Version of PDF. - void InitializePdf(decimal version); + void InitializePdf(double version); /// /// Completes the PDF writing trailing PDF information. diff --git a/src/UglyToad.PdfPig/Writer/PdfABaselineRuleBuilder.cs b/src/UglyToad.PdfPig/Writer/PdfABaselineRuleBuilder.cs index 4ca39d35..aa9014f1 100644 --- a/src/UglyToad.PdfPig/Writer/PdfABaselineRuleBuilder.cs +++ b/src/UglyToad.PdfPig/Writer/PdfABaselineRuleBuilder.cs @@ -14,7 +14,7 @@ namespace UglyToad.PdfPig.Writer Func writerFunc, PdfDocumentBuilder.DocumentInformationBuilder documentInformationBuilder, PdfAStandard archiveStandard, - decimal version, + double version, XDocument xmpMetadata) { catalog[NameToken.OutputIntents] = OutputIntentsFactory.GetOutputIntentsArray(writerFunc); diff --git a/src/UglyToad.PdfPig/Writer/PdfDedupStreamWriter.cs b/src/UglyToad.PdfPig/Writer/PdfDedupStreamWriter.cs index 72ad6525..17f29c56 100644 --- a/src/UglyToad.PdfPig/Writer/PdfDedupStreamWriter.cs +++ b/src/UglyToad.PdfPig/Writer/PdfDedupStreamWriter.cs @@ -13,7 +13,7 @@ Stream stream, bool dispose, ITokenWriter tokenWriter = null, - Action recordVersion = null + Action recordVersion = null ) : base(stream, dispose, tokenWriter, recordVersion) { } diff --git a/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs b/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs index 7e203f3f..2bc6f960 100644 --- a/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs +++ b/src/UglyToad.PdfPig/Writer/PdfDocumentBuilder.cs @@ -31,7 +31,7 @@ namespace UglyToad.PdfPig.Writer private readonly Dictionary fonts = new Dictionary(); private bool completed = false; private int fontId = 0; - private decimal version = 1.7m; + private double version = 1.7; private readonly static ArrayToken DefaultProcSet = new ArrayToken(new List { @@ -85,14 +85,14 @@ namespace UglyToad.PdfPig.Writer public PdfDocumentBuilder() { context = new PdfStreamWriter(new MemoryStream(), true, recordVersion: x => version = x); - context.InitializePdf(1.7m); + context.InitializePdf(1.7); } /// /// Creates a document builder keeping resources in memory. /// /// Pdf version to use in header. - public PdfDocumentBuilder(decimal version) + public PdfDocumentBuilder(double version) { context = new PdfStreamWriter(new MemoryStream(), true, recordVersion: x => version = x); context.InitializePdf(version); @@ -106,7 +106,7 @@ namespace UglyToad.PdfPig.Writer /// Type of pdf stream writer to use /// Pdf version to use in header. /// Token writer to use - public PdfDocumentBuilder(Stream stream, bool disposeStream = false, PdfWriterType type = PdfWriterType.Default, decimal version = 1.7m, ITokenWriter tokenWriter = null) + public PdfDocumentBuilder(Stream stream, bool disposeStream = false, PdfWriterType type = PdfWriterType.Default, double version = 1.7, ITokenWriter tokenWriter = null) { switch (type) { diff --git a/src/UglyToad.PdfPig/Writer/PdfMerger.cs b/src/UglyToad.PdfPig/Writer/PdfMerger.cs index 318a4583..33e24423 100644 --- a/src/UglyToad.PdfPig/Writer/PdfMerger.cs +++ b/src/UglyToad.PdfPig/Writer/PdfMerger.cs @@ -135,7 +135,7 @@ private static void Merge(IReadOnlyList files, Stream output, IReadOnlyList> pagesBundle, PdfAStandard archiveStandard = PdfAStandard.None, PdfDocumentBuilder.DocumentInformationBuilder docInfoBuilder = null) { - var maxVersion = files.Select(x=>x.Version).Max(); + var maxVersion = files.Select(x => x.Version).Max(); using (var document = new PdfDocumentBuilder(output, false, PdfWriterType.Default, maxVersion)) { document.ArchiveStandard = archiveStandard; diff --git a/src/UglyToad.PdfPig/Writer/PdfStreamWriter.cs b/src/UglyToad.PdfPig/Writer/PdfStreamWriter.cs index 34058c58..eb5e3c58 100644 --- a/src/UglyToad.PdfPig/Writer/PdfStreamWriter.cs +++ b/src/UglyToad.PdfPig/Writer/PdfStreamWriter.cs @@ -13,8 +13,8 @@ /// internal class PdfStreamWriter : IPdfStreamWriter { - private readonly Action recordVersion; - protected const decimal DefaultVersion = 1.2m; + private readonly Action recordVersion; + protected const double DefaultVersion = 1.2; protected Dictionary offsets = new Dictionary(); protected bool DisposeStream { get; set; } protected bool Initialized { get; set; } @@ -35,7 +35,7 @@ Stream baseStream, bool disposeStream = true, ITokenWriter tokenWriter = null, - Action recordVersion = null) + Action recordVersion = null) { Stream = baseStream ?? throw new ArgumentNullException(nameof(baseStream)); @@ -81,7 +81,7 @@ return new IndirectReferenceToken(new IndirectReference(CurrentNumber++, 0)); } - public void InitializePdf(decimal version) + public void InitializePdf(double version) { recordVersion?.Invoke(version); diff --git a/src/UglyToad.PdfPig/Writer/Xmp/XmpWriter.cs b/src/UglyToad.PdfPig/Writer/Xmp/XmpWriter.cs index f56d0717..fc583560 100644 --- a/src/UglyToad.PdfPig/Writer/Xmp/XmpWriter.cs +++ b/src/UglyToad.PdfPig/Writer/Xmp/XmpWriter.cs @@ -38,7 +38,7 @@ namespace UglyToad.PdfPig.Writer.Xmp private const string PdfAIdentificationExtensionPrefix = "pdfaid"; private const string PdfAIdentificationExtensionNamespace = "http://www.aiim.org/pdfa/ns/id/"; - public static StreamToken GenerateXmpStream(PdfDocumentBuilder.DocumentInformationBuilder builder, decimal version, + public static StreamToken GenerateXmpStream(PdfDocumentBuilder.DocumentInformationBuilder builder, double version, PdfAStandard standard, XDocument additionalXmpMetadata) { XNamespace xmpMeta = XmpMetaNamespace;