mirror of
https://github.com/UglyToad/PdfPig.git
synced 2026-03-10 00:23:29 +08:00
remove all old cos objects
This commit is contained in:
19
src/UglyToad.PdfPig.Tests/TestFilterProvider.cs
Normal file
19
src/UglyToad.PdfPig.Tests/TestFilterProvider.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace UglyToad.PdfPig.Tests
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using PdfPig.Filters;
|
||||
using PdfPig.Tokenization.Tokens;
|
||||
|
||||
internal class TestFilterProvider : IFilterProvider
|
||||
{
|
||||
public IReadOnlyList<IFilter> GetFilters(DictionaryToken dictionary)
|
||||
{
|
||||
return new List<IFilter>();
|
||||
}
|
||||
|
||||
public IReadOnlyList<IFilter> GetAllFilters()
|
||||
{
|
||||
return new List<IFilter>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace UglyToad.PdfPig.Tests.Tokenization.Scanner
|
||||
namespace UglyToad.PdfPig.Tests
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using PdfPig.ContentStream;
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace UglyToad.PdfPig.Tests.Parser.Parts
|
||||
namespace UglyToad.PdfPig.Tests
|
||||
{
|
||||
using System;
|
||||
using Logging;
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace UglyToad.PdfPig.Tests.Parser.Parts
|
||||
namespace UglyToad.PdfPig.Tests
|
||||
{
|
||||
using System;
|
||||
using IO;
|
||||
@@ -5,7 +5,6 @@
|
||||
using System.Text;
|
||||
using IO;
|
||||
using PdfPig.ContentStream;
|
||||
using PdfPig.Filters;
|
||||
using PdfPig.Tokenization.Scanner;
|
||||
using PdfPig.Tokenization.Tokens;
|
||||
using PdfPig.Util;
|
||||
@@ -334,22 +333,4 @@ endobj";
|
||||
16
|
||||
endobj";
|
||||
var inputBytes = new ByteArrayInputBytes(OtherEncodings.StringAsLatin1Bytes(s));
|
||||
|
||||
var scanner = new PdfTokenScanner(inputBytes, new TestObjectLocationProvider(), new TestFilterProvider());
|
||||
|
||||
var token = ReadToEnd(scanner)[1];
|
||||
|
||||
Assert.Equal(7, token.Number.ObjectNumber);
|
||||
|
||||
}
|
||||
|
||||
private PdfTokenScanner GetScanner(string s, TestObjectLocationProvider locationProvider = null)
|
||||
{
|
||||
var input = StringBytesTestConverter.Convert(s, false);
|
||||
|
||||
return new PdfTokenScanner(input.Bytes, locationProvider ?? new TestObjectLocationProvider(),
|
||||
new TestFilterProvider());
|
||||
}
|
||||
|
||||
private static IReadOnlyList<ObjectToken> ReadToEnd(PdfTokenScanner scanner)
|
||||
|
||||
|
||||
@@ -3,10 +3,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Core;
|
||||
using Cos;
|
||||
|
||||
internal class PdfBoolean : CosBase, ICosStreamWriter, IEquatable<PdfBoolean>
|
||||
internal class PdfBoolean : IEquatable<PdfBoolean>
|
||||
{
|
||||
/// <summary>
|
||||
/// The bytes representing a true value in the PDF content.
|
||||
@@ -39,11 +37,6 @@
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromBoolean(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Supports casting from <see cref="bool"/> to <see cref="PdfBoolean"/>.
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
namespace UglyToad.PdfPig.ContentStream
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Cos;
|
||||
using Tokenization.Tokens;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
internal class PdfDictionary : CosBase, IReadOnlyDictionary<CosName, CosBase>
|
||||
{
|
||||
private readonly Dictionary<CosName, CosBase> inner = new Dictionary<CosName, CosBase>();
|
||||
|
||||
[CanBeNull]
|
||||
public CosName GetName(CosName key)
|
||||
{
|
||||
if (!inner.TryGetValue(key, out CosBase obj) || !(obj is CosName name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public bool TryGetName(CosName key, out CosName value)
|
||||
{
|
||||
value = GetName(key);
|
||||
|
||||
return value != null;
|
||||
}
|
||||
|
||||
public bool IsType(CosName expectedType)
|
||||
{
|
||||
if (!inner.TryGetValue(CosName.TYPE, out CosBase obj) || obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (obj)
|
||||
{
|
||||
case CosName name:
|
||||
return expectedType.Equals(name);
|
||||
case CosString str:
|
||||
return string.Equals(expectedType.Name, str.GetString());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public CosBase GetItemOrDefault(CosName key)
|
||||
{
|
||||
if (inner.TryGetValue(key, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool TryGetItemOfType<T>(CosName key, out T item) where T : CosBase
|
||||
{
|
||||
item = null;
|
||||
if (inner.TryGetValue(key, out var value) && value is T t)
|
||||
{
|
||||
item = t;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Set(CosName key, CosBase value)
|
||||
{
|
||||
if (key == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
}
|
||||
|
||||
inner[key] = value ?? throw new ArgumentNullException(nameof(value));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
foreach (var cosBase in inner)
|
||||
{
|
||||
builder.Append($"({cosBase.Key}, {cosBase.Value}) ");
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
#region Interface Members
|
||||
public int Count => inner.Count;
|
||||
public CosBase this[CosName key] => inner[key];
|
||||
public IEnumerable<CosName> Keys => inner.Keys;
|
||||
public IEnumerable<CosBase> Values => inner.Values;
|
||||
public bool ContainsKey(CosName key) => inner.ContainsKey(key);
|
||||
public bool TryGetValue(CosName key, out CosBase value) => inner.TryGetValue(key, out value);
|
||||
public IEnumerator<KeyValuePair<CosName, CosBase>> GetEnumerator() => inner.GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static PdfDictionary FromDictionaryToken(DictionaryToken token)
|
||||
{
|
||||
if (token == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(token));
|
||||
}
|
||||
|
||||
return new PdfDictionary();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
namespace UglyToad.PdfPig.ContentStream
|
||||
{
|
||||
using System;
|
||||
using Cos;
|
||||
using Filters;
|
||||
using Tokenization.Tokens;
|
||||
|
||||
internal class PdfRawStream : CosBase
|
||||
{
|
||||
private static readonly object Lock = new object();
|
||||
|
||||
private readonly byte[] streamBytes;
|
||||
private readonly StreamToken stream;
|
||||
|
||||
private byte[] decodedBytes;
|
||||
|
||||
public PdfDictionary Dictionary { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Combines the dictionary for the stream with the raw, encoded/filtered bytes.
|
||||
/// </summary>
|
||||
public PdfRawStream(byte[] streamBytes, PdfDictionary streamDictionary)
|
||||
{
|
||||
this.streamBytes = streamBytes;
|
||||
|
||||
Dictionary = streamDictionary ?? throw new ArgumentNullException(nameof(streamDictionary));
|
||||
}
|
||||
|
||||
public PdfRawStream(StreamToken stream)
|
||||
{
|
||||
this.stream = stream;
|
||||
}
|
||||
|
||||
public byte[] Decode(IFilterProvider filterProvider)
|
||||
{
|
||||
lock (Lock)
|
||||
{
|
||||
if (decodedBytes != null)
|
||||
{
|
||||
return decodedBytes;
|
||||
}
|
||||
|
||||
if (stream != null)
|
||||
{
|
||||
var tokenFilters = filterProvider.GetFilters(stream.StreamDictionary);
|
||||
|
||||
if (tokenFilters.Count > 0)
|
||||
{
|
||||
throw new NotImplementedException("Need to change everything to use this method.");
|
||||
}
|
||||
|
||||
decodedBytes = stream.Data;
|
||||
|
||||
return decodedBytes;
|
||||
}
|
||||
|
||||
var filters = filterProvider.GetFilters(Dictionary);
|
||||
|
||||
var transform = streamBytes;
|
||||
for (var i = 0; i < filters.Count; i++)
|
||||
{
|
||||
//transform = filters[i].Decode(transform, Dictionary, i);
|
||||
}
|
||||
|
||||
decodedBytes = transform;
|
||||
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
throw new NotImplementedException("This used to implement using CosDictionary but I removed it! :O");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
namespace UglyToad.PdfPig.ContentStream.TypedAccessors
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using Cos;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
internal static class DictionaryValueAccessorExtensions
|
||||
{
|
||||
public static long GetLongOrDefault(this PdfDictionary dictionary, CosName key)
|
||||
{
|
||||
return dictionary.GetLongOrDefault(key, -1L);
|
||||
}
|
||||
|
||||
public static long GetLongOrDefault(this PdfDictionary dictionary, IEnumerable<string> keys, long defaultValue)
|
||||
{
|
||||
foreach (var key in keys)
|
||||
{
|
||||
if (dictionary.TryGetValue(CosName.Create(key), out var value) && value is ICosNumber number)
|
||||
{
|
||||
return number.AsLong();
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static long GetLongOrDefault(this PdfDictionary dictionary, string key, long defaultValue)
|
||||
{
|
||||
return dictionary.GetLongOrDefault(CosName.Create(key), defaultValue);
|
||||
}
|
||||
|
||||
public static long GetLongOrDefault(this PdfDictionary dictionary, CosName key, long defaultValue)
|
||||
{
|
||||
if (!dictionary.TryGetValue(key, out CosBase obj) || !(obj is ICosNumber number))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return number.AsLong();
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, CosName key)
|
||||
{
|
||||
return dictionary.GetIntOrDefault(key, -1);
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, IEnumerable<string> keyList, int defaultValue)
|
||||
{
|
||||
foreach (var key in keyList)
|
||||
{
|
||||
if (dictionary.TryGetValue(CosName.Create(key), out var obj) && obj is ICosNumber number)
|
||||
{
|
||||
return number.AsInt();
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, string key, int defaultValue)
|
||||
{
|
||||
return dictionary.GetIntOrDefault(CosName.Create(key), defaultValue);
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, CosName key, int defaultValue)
|
||||
{
|
||||
return dictionary.GetIntOrDefault(key, null, defaultValue);
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, CosName firstKey, CosName secondKey)
|
||||
{
|
||||
return dictionary.GetIntOrDefault(firstKey, secondKey, -1);
|
||||
}
|
||||
|
||||
public static int GetIntOrDefault(this PdfDictionary dictionary, CosName firstKey, CosName secondKey, int defaultValue)
|
||||
{
|
||||
if (dictionary.TryGetValue(firstKey, out var obj) && obj is ICosNumber number)
|
||||
{
|
||||
return number.AsInt();
|
||||
}
|
||||
|
||||
if (secondKey != null && dictionary.TryGetValue(secondKey, out obj) && obj is ICosNumber second)
|
||||
{
|
||||
return second.AsInt();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public static decimal GetDecimalOrDefault(this PdfDictionary dictionary, CosName key, decimal defaultValue)
|
||||
{
|
||||
if (!dictionary.TryGetValue(key, out CosBase obj) || !(obj is ICosNumber number))
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return (decimal)number.AsDouble();
|
||||
}
|
||||
|
||||
public static CosBase GetDictionaryObject(this PdfDictionary dictionary, CosName firstKey, CosName secondKey)
|
||||
{
|
||||
CosBase result = dictionary.GetDictionaryObject(firstKey);
|
||||
|
||||
if (result == null && secondKey != null)
|
||||
{
|
||||
result = dictionary.GetDictionaryObject(secondKey);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static CosBase GetDictionaryObject(this PdfDictionary dictionary, IEnumerable<string> keyList)
|
||||
{
|
||||
foreach (var key in keyList)
|
||||
{
|
||||
var obj = dictionary.GetDictionaryObject(CosName.Create(key));
|
||||
|
||||
if (obj != null)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public static CosBase GetDictionaryObject(this PdfDictionary dictionary, CosName key)
|
||||
{
|
||||
dictionary.TryGetValue(key, out CosBase result);
|
||||
|
||||
if (result is CosObject)
|
||||
{
|
||||
result = ((CosObject)result).GetObject();
|
||||
}
|
||||
if (result is CosNull)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
[CanBeNull]
|
||||
public static PdfDictionary GetDictionaryOrDefault(this PdfDictionary dictionary,
|
||||
CosName key)
|
||||
{
|
||||
if (!dictionary.TryGetValue(key, out var value))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return value as PdfDictionary;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
namespace UglyToad.PdfPig.ContentStream.TypedAccessors
|
||||
{
|
||||
using Cos;
|
||||
|
||||
internal static class DictionaryValueSetterExtensions
|
||||
{
|
||||
public static void SetLong(this PdfDictionary dictionary, CosName key, long value)
|
||||
{
|
||||
var wrappedInt = CosInt.Get(value);
|
||||
|
||||
dictionary.Set(key, wrappedInt);
|
||||
}
|
||||
|
||||
public static void SetInt(this PdfDictionary dictionary, CosName key, int value)
|
||||
{
|
||||
var wrappedInt = CosInt.Get(value);
|
||||
|
||||
dictionary.Set(key, wrappedInt);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,567 +0,0 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* An array of PDFBase objects as part of the PDF document.
|
||||
*
|
||||
* @author Ben Litchfield
|
||||
*/
|
||||
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
internal class COSArray : CosBase, IEnumerable<CosBase>, ICosUpdateInfo
|
||||
{
|
||||
private readonly List<CosBase> objects = new List<CosBase>();
|
||||
public bool NeedsToBeUpdated { get; set; }
|
||||
|
||||
public int Count => objects.Count;
|
||||
|
||||
/**
|
||||
* This will add an object to the array.
|
||||
*
|
||||
* @param object The object to add to the array.
|
||||
*/
|
||||
public void add(CosBase obj)
|
||||
{
|
||||
objects.Add(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add an object to the array.
|
||||
*
|
||||
* @param object The object to add to the array.
|
||||
*/
|
||||
public void add(ICosObject obj)
|
||||
{
|
||||
objects.Add(obj.GetCosObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified object at the ith location and push the rest to the
|
||||
* right.
|
||||
*
|
||||
* @param i The index to add at.
|
||||
* @param object The object to add at that index.
|
||||
*/
|
||||
public void add(int i, CosBase obj)
|
||||
{
|
||||
objects.Insert(i, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove all of the objects in the collection.
|
||||
*/
|
||||
public void clear()
|
||||
{
|
||||
objects.Clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove all of the objects in the collection.
|
||||
*
|
||||
* @param objectsList The list of objects to remove from the collection.
|
||||
*/
|
||||
public void removeAll(IEnumerable<CosBase> objectsList)
|
||||
{
|
||||
if (objectsList == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var cosBase in objectsList)
|
||||
{
|
||||
objects.Remove(cosBase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This will retain all of the objects in the collection.
|
||||
*
|
||||
* @param objectsList The list of objects to retain from the collection.
|
||||
*/
|
||||
public void retainAll(IEnumerable<CosBase> objectsList)
|
||||
{
|
||||
objects.Clear();
|
||||
objects.AddRange(new List<CosBase>(objectsList));
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add an object to the array.
|
||||
*
|
||||
* @param objectsList The object to add to the array.
|
||||
*/
|
||||
public void addAll(IEnumerable<CosBase> objectsList)
|
||||
{
|
||||
objects.AddRange(objectsList);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add all objects to this array.
|
||||
*
|
||||
* @param objectList The objects to add.
|
||||
*/
|
||||
public void addAll(COSArray objectList)
|
||||
{
|
||||
if (objectList != null)
|
||||
{
|
||||
objects.AddRange(objectList.objects);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the specified object at the ith location and push the rest to the
|
||||
* right.
|
||||
*
|
||||
* @param i The index to add at.
|
||||
* @param objectList The object to add at that index.
|
||||
*/
|
||||
public void addAll(int i, IEnumerable<CosBase> objectList)
|
||||
{
|
||||
if (objectList == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(objectList));
|
||||
}
|
||||
|
||||
objects.InsertRange(i, objectList);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will set an object at a specific index.
|
||||
*
|
||||
* @param index zero based index into array.
|
||||
* @param object The object to set.
|
||||
*/
|
||||
public void set(int index, CosBase obj)
|
||||
{
|
||||
objects[index] = obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will set an object at a specific index.
|
||||
*
|
||||
* @param index zero based index into array.
|
||||
* @param intVal The object to set.
|
||||
*/
|
||||
public void set(int index, int intVal)
|
||||
{
|
||||
set(index, CosInt.Get(intVal));
|
||||
}
|
||||
|
||||
/**
|
||||
* This will set an object at a specific index.
|
||||
*
|
||||
* @param index zero based index into array.
|
||||
* @param object The object to set.
|
||||
*/
|
||||
public void set(int index, ICosObject obj)
|
||||
{
|
||||
CosBase baseObj = null;
|
||||
if (obj != null)
|
||||
{
|
||||
baseObj = baseObj.GetCosObject();
|
||||
}
|
||||
|
||||
set(index, baseObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get an object from the array. This will dereference the object.
|
||||
* If the object is COSNull then null will be returned.
|
||||
*
|
||||
* @param index The index into the array to get the object.
|
||||
*
|
||||
* @return The object at the requested index.
|
||||
*/
|
||||
public CosBase getObject(int index)
|
||||
{
|
||||
var obj = objects[index];
|
||||
if (obj is CosObject cosObject)
|
||||
{
|
||||
obj = cosObject.GetObject();
|
||||
}
|
||||
if (obj is CosNull)
|
||||
{
|
||||
obj = null;
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get an object from the array. This will NOT dereference
|
||||
* the COS object.
|
||||
*
|
||||
* @param index The index into the array to get the object.
|
||||
*
|
||||
* @return The object at the requested index.
|
||||
*/
|
||||
public CosBase get(int index)
|
||||
{
|
||||
return objects[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault the value of the array as an integer.
|
||||
*
|
||||
* @param index The index into the list.
|
||||
*
|
||||
* @return The value at that index or -1 if it is null.
|
||||
*/
|
||||
public int getInt(int index)
|
||||
{
|
||||
return getInt(index, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault the value of the array as an integer, return the default if it does
|
||||
* not exist.
|
||||
*
|
||||
* @param index The value of the array.
|
||||
* @param defaultValue The value to return if the value is null.
|
||||
* @return The value at the index or the defaultValue.
|
||||
*/
|
||||
public int getInt(int index, int defaultValue)
|
||||
{
|
||||
int retval = defaultValue;
|
||||
if (index < size())
|
||||
{
|
||||
var obj = objects[index];
|
||||
if (obj is ICosNumber num)
|
||||
{
|
||||
retval = num.AsInt();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value in the array as an integer.
|
||||
*
|
||||
* @param index The index into the array.
|
||||
* @param value The value to set.
|
||||
*/
|
||||
public void setInt(int index, int value)
|
||||
{
|
||||
set(index, CosInt.Get(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value in the array as a name.
|
||||
* @param index The index into the array.
|
||||
* @param name The name to set in the array.
|
||||
*/
|
||||
public void setName(int index, string name)
|
||||
{
|
||||
set(index, CosName.Create(name));
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault the value of the array as a string.
|
||||
*
|
||||
* @param index The index into the array.
|
||||
* @return The name converted to a string or null if it does not exist.
|
||||
*/
|
||||
public string getName(int index)
|
||||
{
|
||||
return getName(index, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault an entry in the array that is expected to be a COSName.
|
||||
* @param index The index into the array.
|
||||
* @param defaultValue The value to return if it is null.
|
||||
* @return The value at the index or defaultValue if none is found.
|
||||
*/
|
||||
public string getName(int index, string defaultValue)
|
||||
{
|
||||
var retval = defaultValue;
|
||||
if (index < size())
|
||||
{
|
||||
var obj = objects[index];
|
||||
if (obj is CosName name)
|
||||
{
|
||||
retval = name.Name;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value in the array as a string.
|
||||
* @param index The index into the array.
|
||||
* @param string The string to set in the array.
|
||||
*/
|
||||
public void setString(int index, string str)
|
||||
{
|
||||
if (str != null)
|
||||
{
|
||||
set(index, new CosString(str));
|
||||
}
|
||||
else
|
||||
{
|
||||
set(index, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault the value of the array as a string.
|
||||
*
|
||||
* @param index The index into the array.
|
||||
* @return The string or null if it does not exist.
|
||||
*/
|
||||
public string getString(int index)
|
||||
{
|
||||
return getString(index, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* GetLongOrDefault an entry in the array that is expected to be a COSName.
|
||||
* @param index The index into the array.
|
||||
* @param defaultValue The value to return if it is null.
|
||||
* @return The value at the index or defaultValue if none is found.
|
||||
*/
|
||||
public string getString(int index, string defaultValue)
|
||||
{
|
||||
var retval = defaultValue;
|
||||
if (index < size())
|
||||
{
|
||||
var obj = objects[index];
|
||||
if (obj is CosString str)
|
||||
{
|
||||
retval = str.GetString();
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get the size of this array.
|
||||
*
|
||||
* @return The number of elements in the array.
|
||||
*/
|
||||
public int size()
|
||||
{
|
||||
return objects.Count;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove an element from the array.
|
||||
*
|
||||
* @param i The index of the object to remove.
|
||||
*
|
||||
* @return The object that was removed.
|
||||
*/
|
||||
public CosBase remove(int i)
|
||||
{
|
||||
var item = objects[i];
|
||||
objects.RemoveAt(i);
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove an element from the array.
|
||||
*
|
||||
* @param o The object to remove.
|
||||
*
|
||||
* @return <code>true</code> if the object was removed, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
public bool remove(CosBase o)
|
||||
{
|
||||
return objects.Remove(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove an element from the array.
|
||||
* This method will also remove a reference to the object.
|
||||
*
|
||||
* @param o The object to remove.
|
||||
* @return <code>true</code> if the object was removed, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
public bool removeObject(CosBase o)
|
||||
{
|
||||
var removed = remove(o);
|
||||
if (!removed)
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
{
|
||||
CosBase entry = get(i);
|
||||
if (entry is CosObject obj)
|
||||
{
|
||||
if (obj.GetObject().Equals(o))
|
||||
{
|
||||
return remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
public IEnumerator<CosBase> GetEnumerator()
|
||||
{
|
||||
return objects.GetEnumerator();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "COSArray{" + objects + "}";
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return the index of the entry or -1 if it is not found.
|
||||
*
|
||||
* @param object The object to search for.
|
||||
* @return The index of the object or -1.
|
||||
*/
|
||||
public int indexOf(CosBase obj)
|
||||
{
|
||||
int retval = -1;
|
||||
for (int i = 0; retval < 0 && i < size(); i++)
|
||||
{
|
||||
if (get(i).Equals(obj))
|
||||
{
|
||||
retval = i;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will return the index of the entry or -1 if it is not found.
|
||||
* This method will also find references to indirect objects.
|
||||
*
|
||||
* @param object The object to search for.
|
||||
* @return The index of the object or -1.
|
||||
*/
|
||||
public int indexOfObject(CosBase obj)
|
||||
{
|
||||
int retval = -1;
|
||||
for (int i = 0; retval < 0 && i < this.size(); i++)
|
||||
{
|
||||
CosBase item = this.get(i);
|
||||
if (item.Equals(obj))
|
||||
{
|
||||
retval = i;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (item is CosObject && ((CosObject)item).GetObject().Equals(obj))
|
||||
{
|
||||
retval = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add null values until the size of the array is at least
|
||||
* as large as the parameter. If the array is already larger than the
|
||||
* parameter then nothing is done.
|
||||
*
|
||||
* @param size The desired size of the array.
|
||||
*/
|
||||
public void growToSize(int size)
|
||||
{
|
||||
growToSize(size, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add the object until the size of the array is at least
|
||||
* as large as the parameter. If the array is already larger than the
|
||||
* parameter then nothing is done.
|
||||
*
|
||||
* @param size The desired size of the array.
|
||||
* @param object The object to fill the array with.
|
||||
*/
|
||||
public void growToSize(int targetSize, CosBase obj)
|
||||
{
|
||||
while (size() < targetSize)
|
||||
{
|
||||
add(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* visitor pattern double dispatch method.
|
||||
*
|
||||
* @param visitor The object to notify when visiting this object.
|
||||
* @return any object, depending on the visitor implementation, or null
|
||||
* @throws IOException If an error occurs while visiting this object.
|
||||
*/
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromArray(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will take an COSArray of numbers and convert it to a float[].
|
||||
*
|
||||
* @return This COSArray as an array of float numbers.
|
||||
*/
|
||||
public float[] toFloatArray()
|
||||
{
|
||||
float[] retval = new float[size()];
|
||||
for (int i = 0; i < size(); i++)
|
||||
{
|
||||
retval[i] = ((ICosNumber)getObject(i)).AsFloat();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the current contents of the COSArray and set it with the float[].
|
||||
*
|
||||
* @param value The new value of the float array.
|
||||
*/
|
||||
public void setFloatArray(float[] value)
|
||||
{
|
||||
this.clear();
|
||||
foreach (float aValue in value)
|
||||
{
|
||||
add(new CosFloat(aValue));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return contents of COSArray as a Java List.
|
||||
*
|
||||
* @return the COSArray as List
|
||||
*/
|
||||
public List<CosBase> toList()
|
||||
{
|
||||
return new List<CosBase>(objects);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
internal abstract class CosBase : ICosObject
|
||||
{
|
||||
public bool Direct { get; set; }
|
||||
|
||||
public CosBase GetCosObject()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract object Accept(ICosVisitor visitor);
|
||||
}
|
||||
|
||||
internal interface ICosObject
|
||||
{
|
||||
CosBase GetCosObject();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,186 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Core;
|
||||
using Util;
|
||||
|
||||
internal class CosFloat : CosBase, ICosNumber, ICosStreamWriter
|
||||
{
|
||||
private readonly decimal value;
|
||||
private readonly string valueAsString;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param aFloat The primitive float object that this object wraps.
|
||||
*/
|
||||
public CosFloat(float aFloat)
|
||||
{
|
||||
// use a BigDecimal as intermediate state to avoid
|
||||
// a floating point string representation of the float value
|
||||
value = new decimal(aFloat);
|
||||
valueAsString = RemoveNullDigits(value.ToString("G"));
|
||||
}
|
||||
|
||||
private static readonly Regex ZeroNegativeDecimalPart = new Regex("^0\\.0*\\-\\d+");
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param aFloat The primitive float object that this object wraps.
|
||||
*
|
||||
* @throws IOException If aFloat is not a float.
|
||||
*/
|
||||
public CosFloat(string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
(this.value, valueAsString) = CheckMinMaxValues(decimal.Parse(value), value);
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
if (ZeroNegativeDecimalPart.IsMatch(value))
|
||||
{
|
||||
// PDFBOX-2990 has 0.00000-33917698
|
||||
// PDFBOX-3369 has 0.00-35095424
|
||||
// PDFBOX-3500 has 0.-262
|
||||
try
|
||||
{
|
||||
valueAsString = "-" + valueAsString.ReplaceLimited("\\-", "", 1);
|
||||
this.value = decimal.Parse(valueAsString);
|
||||
|
||||
(this.value, valueAsString) = CheckMinMaxValues(this.value, value);
|
||||
}
|
||||
catch (FormatException e2)
|
||||
{
|
||||
throw new ArgumentException($"Error expected floating point number actual=\'{value}\'", e2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Error expected floating point number actual=\'{value}\'", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static (decimal, string) CheckMinMaxValues(decimal currentValue, string currentValueAsString)
|
||||
{
|
||||
float floatValue = (float)currentValue;
|
||||
double doubleValue = (double)currentValue;
|
||||
bool valueReplaced = false;
|
||||
// check for huge values
|
||||
if (float.IsNegativeInfinity(floatValue) || float.IsPositiveInfinity(floatValue))
|
||||
{
|
||||
|
||||
if (Math.Abs(doubleValue) > float.MaxValue)
|
||||
{
|
||||
floatValue = float.MaxValue * (float.IsPositiveInfinity(floatValue) ? 1 : -1);
|
||||
valueReplaced = true;
|
||||
}
|
||||
}
|
||||
// check for very small values
|
||||
else if (floatValue == 0 && doubleValue != 0)
|
||||
{
|
||||
// todo what is min normal?
|
||||
if (Math.Abs(doubleValue) < float.MinValue)
|
||||
{
|
||||
floatValue = float.MinValue;
|
||||
floatValue *= doubleValue >= 0 ? 1 : -1;
|
||||
valueReplaced = true;
|
||||
}
|
||||
}
|
||||
if (valueReplaced)
|
||||
{
|
||||
return (new decimal(floatValue), RemoveNullDigits(currentValue.ToString("g")));
|
||||
}
|
||||
|
||||
return (currentValue, currentValueAsString);
|
||||
}
|
||||
|
||||
private static string RemoveNullDigits(string plainStringValue)
|
||||
{
|
||||
// remove fraction digit "0" only
|
||||
if (plainStringValue.IndexOf('.') > -1 && !plainStringValue.EndsWith(".0"))
|
||||
{
|
||||
while (plainStringValue.EndsWith("0") && !plainStringValue.EndsWith(".0"))
|
||||
{
|
||||
plainStringValue = plainStringValue.Substring(0, plainStringValue.Length - 1);
|
||||
}
|
||||
}
|
||||
return plainStringValue;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var cosFloat = obj as CosFloat;
|
||||
|
||||
return Equals(cosFloat);
|
||||
}
|
||||
|
||||
protected bool Equals(CosFloat other)
|
||||
{
|
||||
return value == other?.value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return value.GetHashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "COSFloat{" + valueAsString + "}";
|
||||
}
|
||||
|
||||
public void WriteToPdfStream(BinaryWriter output)
|
||||
{
|
||||
var encoding = Encoding.GetEncoding("ISO-8859-1");
|
||||
output.Write(encoding.GetBytes(valueAsString));
|
||||
}
|
||||
|
||||
/**
|
||||
* visitor pattern double dispatch method.
|
||||
*
|
||||
* @param visitor The object to notify when visiting this object.
|
||||
* @return any object, depending on the visitor implementation, or null
|
||||
* @throws IOException If an error occurs while visiting this object.
|
||||
*/
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromFloat(this);
|
||||
}
|
||||
|
||||
public float AsFloat()
|
||||
{
|
||||
return (float)value;
|
||||
}
|
||||
|
||||
public double AsDouble()
|
||||
{
|
||||
return (double) value;
|
||||
}
|
||||
|
||||
public int AsInt()
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
public long AsLong()
|
||||
{
|
||||
return (long) value;
|
||||
}
|
||||
|
||||
public decimal AsDecimal()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,151 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Core;
|
||||
|
||||
internal class CosInt : CosBase, ICosNumber, ICosStreamWriter
|
||||
{
|
||||
/**
|
||||
* The lowest integer to be kept in the {@link #STATIC} array.
|
||||
*/
|
||||
private const int Low = -100;
|
||||
|
||||
/**
|
||||
* The highest integer to be kept in the {@link #STATIC} array.
|
||||
*/
|
||||
private const int High = 256;
|
||||
|
||||
/**
|
||||
* Static instances of all CosInts in the range from {@link #LOW}
|
||||
* to {@link #HIGH}.
|
||||
*/
|
||||
private static readonly CosInt[] Static = new CosInt[High - Low + 1];
|
||||
|
||||
/**
|
||||
* Constant for the number zero.
|
||||
* @since Apache PDFBox 1.1.0
|
||||
*/
|
||||
public static readonly CosInt Zero = Get(0);
|
||||
|
||||
/**
|
||||
* Constant for the number one.
|
||||
* @since Apache PDFBox 1.1.0
|
||||
*/
|
||||
public static readonly CosInt One = Get(1);
|
||||
|
||||
/**
|
||||
* Constant for the number two.
|
||||
* @since Apache PDFBox 1.1.0
|
||||
*/
|
||||
public static readonly CosInt Two = Get(2);
|
||||
|
||||
/**
|
||||
* Constant for the number three.
|
||||
* @since Apache PDFBox 1.1.0
|
||||
*/
|
||||
public static readonly CosInt Three = Get(3);
|
||||
|
||||
/**
|
||||
* Returns a CosInt instance with the given value.
|
||||
*
|
||||
* @param val integer value
|
||||
* @return CosInt instance
|
||||
*/
|
||||
public static CosInt Get(long val)
|
||||
{
|
||||
if (Low <= val && val <= High)
|
||||
{
|
||||
int index = (int)val - Low;
|
||||
// no synchronization needed
|
||||
if (Static[index] == null)
|
||||
{
|
||||
Static[index] = new CosInt(val);
|
||||
}
|
||||
return Static[index];
|
||||
}
|
||||
return new CosInt(val);
|
||||
}
|
||||
|
||||
private readonly long value;
|
||||
|
||||
/**
|
||||
* constructor.
|
||||
*
|
||||
* @param val The integer value of this object.
|
||||
*/
|
||||
private CosInt(long val)
|
||||
{
|
||||
value = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as CosInt);
|
||||
}
|
||||
|
||||
protected bool Equals(CosInt other)
|
||||
{
|
||||
return value == other?.value;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return value.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "COSInt{" + value + "}";
|
||||
}
|
||||
|
||||
public void WriteToPdfStream(BinaryWriter output)
|
||||
{
|
||||
var encoding = Encoding.GetEncoding("ISO-8859-1");
|
||||
|
||||
output.Write(encoding.GetBytes(value.ToString("D")));
|
||||
}
|
||||
|
||||
/**
|
||||
* visitor pattern double dispatch method.
|
||||
*
|
||||
* @param visitor The object to notify when visiting this object.
|
||||
* @return any object, depending on the visitor implementation, or null
|
||||
* @throws IOException If an error occurs while visiting this object.
|
||||
*/
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromInt(this);
|
||||
}
|
||||
|
||||
public float AsFloat()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public double AsDouble()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public int AsInt()
|
||||
{
|
||||
return (int)value;
|
||||
}
|
||||
|
||||
public long AsLong()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public decimal AsDecimal()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,682 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Core;
|
||||
using Tokenization.Tokens;
|
||||
using Util;
|
||||
using Util.JetBrains.Annotations;
|
||||
|
||||
/**
|
||||
* A PDF Name object.
|
||||
*
|
||||
* @author Ben Litchfield
|
||||
*/
|
||||
[Obsolete]
|
||||
internal class CosName : CosBase, IComparable<CosName>, ICosStreamWriter
|
||||
{
|
||||
// using ConcurrentHashMap because this can be accessed by multiple threads
|
||||
private static readonly ConcurrentDictionary<string, CosName> NameMap = new ConcurrentDictionary<string, CosName>();
|
||||
|
||||
// all common CosName values are stored in this HashMap
|
||||
// they are already defined as static constants and don't need to be synchronized
|
||||
private static readonly Dictionary<string, CosName> CommonNameMap = new Dictionary<string, CosName>(768);
|
||||
|
||||
//
|
||||
// IMPORTANT: this list is *alphabetized* and does not need any JavaDoc
|
||||
//
|
||||
|
||||
// A
|
||||
public static readonly CosName A = new CosName("A");
|
||||
public static readonly CosName AA = new CosName("AA");
|
||||
public static readonly CosName ACRO_FORM = new CosName("AcroForm");
|
||||
public static readonly CosName ACTUAL_TEXT = new CosName("ActualText");
|
||||
public static readonly CosName ADBE_PKCS7_DETACHED = new CosName("adbe.pkcs7.detached");
|
||||
public static readonly CosName ADBE_PKCS7_SHA1 = new CosName("adbe.pkcs7.sha1");
|
||||
public static readonly CosName ADBE_X509_RSA_SHA1 = new CosName("adbe.x509.rsa_sha1");
|
||||
public static readonly CosName ADOBE_PPKLITE = new CosName("Adobe.PPKLite");
|
||||
public static readonly CosName AESV2 = new CosName("AESV2");
|
||||
public static readonly CosName AESV3 = new CosName("AESV3");
|
||||
public static readonly CosName AFTER = new CosName("After");
|
||||
public static readonly CosName AIS = new CosName("AIS");
|
||||
public static readonly CosName ALT = new CosName("Alt");
|
||||
public static readonly CosName ALPHA = new CosName("Alpha");
|
||||
public static readonly CosName ALTERNATE = new CosName("Alternate");
|
||||
public static readonly CosName ANNOT = new CosName("Annot");
|
||||
public static readonly CosName ANNOTS = new CosName("Annots");
|
||||
public static readonly CosName ANTI_ALIAS = new CosName("AntiAlias");
|
||||
public static readonly CosName AP = new CosName("AP");
|
||||
public static readonly CosName AP_REF = new CosName("APRef");
|
||||
public static readonly CosName APP = new CosName("App");
|
||||
public static readonly CosName ART_BOX = new CosName("ArtBox");
|
||||
public static readonly CosName ARTIFACT = new CosName("Artifact");
|
||||
public static readonly CosName AS = new CosName("AS");
|
||||
public static readonly CosName ASCENT = new CosName("Ascent");
|
||||
public static readonly CosName ASCII_HEX_DECODE = new CosName("ASCIIHexDecode");
|
||||
public static readonly CosName ASCII_HEX_DECODE_ABBREVIATION = new CosName("AHx");
|
||||
public static readonly CosName ASCII85_DECODE = new CosName("ASCII85Decode");
|
||||
public static readonly CosName ASCII85_DECODE_ABBREVIATION = new CosName("A85");
|
||||
public static readonly CosName ATTACHED = new CosName("Attached");
|
||||
public static readonly CosName AUTHOR = new CosName("Author");
|
||||
public static readonly CosName AVG_WIDTH = new CosName("AvgWidth");
|
||||
// B
|
||||
public static readonly CosName B = new CosName("B");
|
||||
public static readonly CosName BACKGROUND = new CosName("Background");
|
||||
public static readonly CosName BASE_ENCODING = new CosName("BaseEncoding");
|
||||
public static readonly CosName BASE_FONT = new CosName("BaseFont");
|
||||
public static readonly CosName BASE_STATE = new CosName("BaseState");
|
||||
public static readonly CosName BBOX = new CosName("BBox");
|
||||
public static readonly CosName BC = new CosName("BC");
|
||||
public static readonly CosName BE = new CosName("BE");
|
||||
public static readonly CosName BEFORE = new CosName("Before");
|
||||
public static readonly CosName BG = new CosName("BG");
|
||||
public static readonly CosName BITS_PER_COMPONENT = new CosName("BitsPerComponent");
|
||||
public static readonly CosName BITS_PER_COORDINATE = new CosName("BitsPerCoordinate");
|
||||
public static readonly CosName BITS_PER_FLAG = new CosName("BitsPerFlag");
|
||||
public static readonly CosName BITS_PER_SAMPLE = new CosName("BitsPerSample");
|
||||
public static readonly CosName BLACK_IS_1 = new CosName("BlackIs1");
|
||||
public static readonly CosName BLACK_POINT = new CosName("BlackPoint");
|
||||
public static readonly CosName BLEED_BOX = new CosName("BleedBox");
|
||||
public static readonly CosName BM = new CosName("BM");
|
||||
public static readonly CosName BORDER = new CosName("Border");
|
||||
public static readonly CosName BOUNDS = new CosName("Bounds");
|
||||
public static readonly CosName BPC = new CosName("BPC");
|
||||
public static readonly CosName BS = new CosName("BS");
|
||||
//** Acro form field type for button fields.
|
||||
public static readonly CosName BTN = new CosName("Btn");
|
||||
public static readonly CosName BYTERANGE = new CosName("ByteRange");
|
||||
// C
|
||||
public static readonly CosName C = new CosName("C");
|
||||
public static readonly CosName C0 = new CosName("C0");
|
||||
public static readonly CosName C1 = new CosName("C1");
|
||||
public static readonly CosName CA = new CosName("CA");
|
||||
public static readonly CosName CA_NS = new CosName("ca");
|
||||
public static readonly CosName CALGRAY = new CosName("CalGray");
|
||||
public static readonly CosName CALRGB = new CosName("CalRGB");
|
||||
public static readonly CosName CAP = new CosName("Cap");
|
||||
public static readonly CosName CAP_HEIGHT = new CosName("CapHeight");
|
||||
public static readonly CosName CATALOG = new CosName("Catalog");
|
||||
public static readonly CosName CCITTFAX_DECODE = new CosName("CCITTFaxDecode");
|
||||
public static readonly CosName CCITTFAX_DECODE_ABBREVIATION = new CosName("CCF");
|
||||
public static readonly CosName CENTER_WINDOW = new CosName("CenterWindow");
|
||||
public static readonly CosName CF = new CosName("CF");
|
||||
public static readonly CosName CFM = new CosName("CFM");
|
||||
//** Acro form field type for choice fields.
|
||||
public static readonly CosName CH = new CosName("Ch");
|
||||
public static readonly CosName CHAR_PROCS = new CosName("CharProcs");
|
||||
public static readonly CosName CHAR_SET = new CosName("CharSet");
|
||||
public static readonly CosName CICI_SIGNIT = new CosName("CICI.SignIt");
|
||||
public static readonly CosName CID_FONT_TYPE0 = new CosName("CIDFontType0");
|
||||
public static readonly CosName CID_FONT_TYPE2 = new CosName("CIDFontType2");
|
||||
public static readonly CosName CID_TO_GID_MAP = new CosName("CIDToGIDMap");
|
||||
public static readonly CosName CID_SET = new CosName("CIDSet");
|
||||
public static readonly CosName CIDSYSTEMINFO = new CosName("CIDSystemInfo");
|
||||
public static readonly CosName CL = new CosName("CL");
|
||||
public static readonly CosName CLR_F = new CosName("ClrF");
|
||||
public static readonly CosName CLR_FF = new CosName("ClrFf");
|
||||
public static readonly CosName CMAP = new CosName("CMap");
|
||||
public static readonly CosName CMAPNAME = new CosName("CMapName");
|
||||
public static readonly CosName CMYK = new CosName("CMYK");
|
||||
public static readonly CosName CO = new CosName("CO");
|
||||
public static readonly CosName COLOR_BURN = new CosName("ColorBurn");
|
||||
public static readonly CosName COLOR_DODGE = new CosName("ColorDodge");
|
||||
public static readonly CosName COLORANTS = new CosName("Colorants");
|
||||
public static readonly CosName COLORS = new CosName("Colors");
|
||||
public static readonly CosName COLORSPACE = new CosName("ColorSpace");
|
||||
public static readonly CosName COLUMNS = new CosName("Columns");
|
||||
public static readonly CosName COMPATIBLE = new CosName("Compatible");
|
||||
public static readonly CosName COMPONENTS = new CosName("Components");
|
||||
public static readonly CosName CONTACT_INFO = new CosName("ContactInfo");
|
||||
public static readonly CosName CONTENTS = new CosName("Contents");
|
||||
public static readonly CosName COORDS = new CosName("Coords");
|
||||
public static readonly CosName COUNT = new CosName("Count");
|
||||
public static readonly CosName CP = new CosName("CP");
|
||||
public static readonly CosName CREATION_DATE = new CosName("CreationDate");
|
||||
public static readonly CosName CREATOR = new CosName("Creator");
|
||||
public static readonly CosName CROP_BOX = new CosName("CropBox");
|
||||
public static readonly CosName CRYPT = new CosName("Crypt");
|
||||
public static readonly CosName CS = new CosName("CS");
|
||||
// D
|
||||
public static readonly CosName D = new CosName("D");
|
||||
public static readonly CosName DA = new CosName("DA");
|
||||
public static readonly CosName DARKEN = new CosName("Darken");
|
||||
public static readonly CosName DATE = new CosName("Date");
|
||||
public static readonly CosName DCT_DECODE = new CosName("DCTDecode");
|
||||
public static readonly CosName DCT_DECODE_ABBREVIATION = new CosName("DCT");
|
||||
public static readonly CosName DECODE = new CosName("Decode");
|
||||
public static readonly CosName DECODE_PARMS = new CosName("DecodeParms");
|
||||
public static readonly CosName DEFAULT = new CosName("default");
|
||||
public static readonly CosName DEFAULT_CMYK = new CosName("DefaultCMYK");
|
||||
public static readonly CosName DEFAULT_GRAY = new CosName("DefaultGray");
|
||||
public static readonly CosName DEFAULT_RGB = new CosName("DefaultRGB");
|
||||
public static readonly CosName DESC = new CosName("Desc");
|
||||
public static readonly CosName DESCENDANT_FONTS = new CosName("DescendantFonts");
|
||||
public static readonly CosName DESCENT = new CosName("Descent");
|
||||
public static readonly CosName DEST = new CosName("Dest");
|
||||
public static readonly CosName DEST_OUTPUT_PROFILE = new CosName("DestOutputProfile");
|
||||
public static readonly CosName DESTS = new CosName("Dests");
|
||||
public static readonly CosName DEVICECMYK = new CosName("DeviceCMYK");
|
||||
public static readonly CosName DEVICEGRAY = new CosName("DeviceGray");
|
||||
public static readonly CosName DEVICEN = new CosName("DeviceN");
|
||||
public static readonly CosName DEVICERGB = new CosName("DeviceRGB");
|
||||
public static readonly CosName DI = new CosName("Di");
|
||||
public static readonly CosName DIFFERENCE = new CosName("Difference");
|
||||
public static readonly CosName DIFFERENCES = new CosName("Differences");
|
||||
public static readonly CosName DIGEST_METHOD = new CosName("DigestMethod");
|
||||
public static readonly CosName DIGEST_RIPEMD160 = new CosName("RIPEMD160");
|
||||
public static readonly CosName DIGEST_SHA1 = new CosName("SHA1");
|
||||
public static readonly CosName DIGEST_SHA256 = new CosName("SHA256");
|
||||
public static readonly CosName DIGEST_SHA384 = new CosName("SHA384");
|
||||
public static readonly CosName DIGEST_SHA512 = new CosName("SHA512");
|
||||
public static readonly CosName DIRECTION = new CosName("Direction");
|
||||
public static readonly CosName DISPLAY_DOC_TITLE = new CosName("DisplayDocTitle");
|
||||
public static readonly CosName DL = new CosName("DL");
|
||||
public static readonly CosName DM = new CosName("Dm");
|
||||
public static readonly CosName DOC = new CosName("Doc");
|
||||
public static readonly CosName DOC_CHECKSUM = new CosName("DocChecksum");
|
||||
public static readonly CosName DOC_TIME_STAMP = new CosName("DocTimeStamp");
|
||||
public static readonly CosName DOCMDP = new CosName("DocMDP");
|
||||
public static readonly CosName DOMAIN = new CosName("Domain");
|
||||
public static readonly CosName DOS = new CosName("DOS");
|
||||
public static readonly CosName DP = new CosName("DP");
|
||||
public static readonly CosName DR = new CosName("DR");
|
||||
public static readonly CosName DS = new CosName("DS");
|
||||
public static readonly CosName DUPLEX = new CosName("Duplex");
|
||||
public static readonly CosName DUR = new CosName("Dur");
|
||||
public static readonly CosName DV = new CosName("DV");
|
||||
public static readonly CosName DW = new CosName("DW");
|
||||
public static readonly CosName DW2 = new CosName("DW2");
|
||||
// E
|
||||
public static readonly CosName E = new CosName("E");
|
||||
public static readonly CosName EARLY_CHANGE = new CosName("EarlyChange");
|
||||
public static readonly CosName EF = new CosName("EF");
|
||||
public static readonly CosName EMBEDDED_FDFS = new CosName("EmbeddedFDFs");
|
||||
public static readonly CosName EMBEDDED_FILES = new CosName("EmbeddedFiles");
|
||||
public static readonly CosName EMPTY = new CosName("");
|
||||
public static readonly CosName ENCODE = new CosName("Encode");
|
||||
public static readonly CosName ENCODED_BYTE_ALIGN = new CosName("EncodedByteAlign");
|
||||
public static readonly CosName ENCODING = new CosName("Encoding");
|
||||
public static readonly CosName ENCODING_90MS_RKSJ_H = new CosName("90ms-RKSJ-H");
|
||||
public static readonly CosName ENCODING_90MS_RKSJ_V = new CosName("90ms-RKSJ-V");
|
||||
public static readonly CosName ENCODING_ETEN_B5_H = new CosName("ETen-B5-H");
|
||||
public static readonly CosName ENCODING_ETEN_B5_V = new CosName("ETen-B5-V");
|
||||
public static readonly CosName ENCRYPT = new CosName("Encrypt");
|
||||
public static readonly CosName ENCRYPT_META_DATA = new CosName("EncryptMetadata");
|
||||
public static readonly CosName END_OF_LINE = new CosName("EndOfLine");
|
||||
public static readonly CosName ENTRUST_PPKEF = new CosName("Entrust.PPKEF");
|
||||
public static readonly CosName EXCLUSION = new CosName("Exclusion");
|
||||
public static readonly CosName EXT_G_STATE = new CosName("ExtGState");
|
||||
public static readonly CosName EXTEND = new CosName("Extend");
|
||||
public static readonly CosName EXTENDS = new CosName("Extends");
|
||||
// F
|
||||
public static readonly CosName F = new CosName("F");
|
||||
public static readonly CosName F_DECODE_PARMS = new CosName("FDecodeParms");
|
||||
public static readonly CosName F_FILTER = new CosName("FFilter");
|
||||
public static readonly CosName FB = new CosName("FB");
|
||||
public static readonly CosName FDF = new CosName("FDF");
|
||||
public static readonly CosName FF = new CosName("Ff");
|
||||
public static readonly CosName FIELDS = new CosName("Fields");
|
||||
public static readonly CosName FILESPEC = new CosName("Filespec");
|
||||
public static readonly CosName FILTER = new CosName("Filter");
|
||||
public static readonly CosName FIRST = new CosName("First");
|
||||
public static readonly CosName FIRST_CHAR = new CosName("FirstChar");
|
||||
public static readonly CosName FIT_WINDOW = new CosName("FitWindow");
|
||||
public static readonly CosName FL = new CosName("FL");
|
||||
public static readonly CosName FLAGS = new CosName("Flags");
|
||||
public static readonly CosName FLATE_DECODE = new CosName("FlateDecode");
|
||||
public static readonly CosName FLATE_DECODE_ABBREVIATION = new CosName("Fl");
|
||||
public static readonly CosName FONT = new CosName("Font");
|
||||
public static readonly CosName FONT_BBOX = new CosName("FontBBox");
|
||||
public static readonly CosName FONT_DESC = new CosName("FontDescriptor");
|
||||
public static readonly CosName FONT_FAMILY = new CosName("FontFamily");
|
||||
public static readonly CosName FONT_FILE = new CosName("FontFile");
|
||||
public static readonly CosName FONT_FILE2 = new CosName("FontFile2");
|
||||
public static readonly CosName FONT_FILE3 = new CosName("FontFile3");
|
||||
public static readonly CosName FONT_MATRIX = new CosName("FontMatrix");
|
||||
public static readonly CosName FONT_NAME = new CosName("FontName");
|
||||
public static readonly CosName FONT_STRETCH = new CosName("FontStretch");
|
||||
public static readonly CosName FONT_WEIGHT = new CosName("FontWeight");
|
||||
public static readonly CosName FORM = new CosName("Form");
|
||||
public static readonly CosName FORMTYPE = new CosName("FormType");
|
||||
public static readonly CosName FRM = new CosName("FRM");
|
||||
public static readonly CosName FT = new CosName("FT");
|
||||
public static readonly CosName FUNCTION = new CosName("Function");
|
||||
public static readonly CosName FUNCTION_TYPE = new CosName("FunctionType");
|
||||
public static readonly CosName FUNCTIONS = new CosName("Functions");
|
||||
// G
|
||||
public static readonly CosName G = new CosName("G");
|
||||
public static readonly CosName GAMMA = new CosName("Gamma");
|
||||
public static readonly CosName GROUP = new CosName("Group");
|
||||
public static readonly CosName GTS_PDFA1 = new CosName("GTS_PDFA1");
|
||||
// H
|
||||
public static readonly CosName H = new CosName("H");
|
||||
public static readonly CosName HARD_LIGHT = new CosName("HardLight");
|
||||
public static readonly CosName HEIGHT = new CosName("Height");
|
||||
public static readonly CosName HIDE_MENUBAR = new CosName("HideMenubar");
|
||||
public static readonly CosName HIDE_TOOLBAR = new CosName("HideToolbar");
|
||||
public static readonly CosName HIDE_WINDOWUI = new CosName("HideWindowUI");
|
||||
// I
|
||||
public static readonly CosName I = new CosName("I");
|
||||
public static readonly CosName IC = new CosName("IC");
|
||||
public static readonly CosName ICCBASED = new CosName("ICCBased");
|
||||
public static readonly CosName ID = new CosName("ID");
|
||||
public static readonly CosName ID_TREE = new CosName("IDTree");
|
||||
public static readonly CosName IDENTITY = new CosName("Identity");
|
||||
public static readonly CosName IDENTITY_H = new CosName("Identity-H");
|
||||
public static readonly CosName IDENTITY_V = new CosName("Identity-V");
|
||||
public static readonly CosName IF = new CosName("IF");
|
||||
public static readonly CosName IM = new CosName("IM");
|
||||
public static readonly CosName IMAGE = new CosName("Image");
|
||||
public static readonly CosName IMAGE_MASK = new CosName("ImageMask");
|
||||
public static readonly CosName INDEX = new CosName("Index");
|
||||
public static readonly CosName INDEXED = new CosName("Indexed");
|
||||
public static readonly CosName INFO = new CosName("Info");
|
||||
public static readonly CosName INKLIST = new CosName("InkList");
|
||||
public static readonly CosName INTERPOLATE = new CosName("Interpolate");
|
||||
public static readonly CosName IT = new CosName("IT");
|
||||
public static readonly CosName ITALIC_ANGLE = new CosName("ItalicAngle");
|
||||
// J
|
||||
public static readonly CosName JAVA_SCRIPT = new CosName("JavaScript");
|
||||
public static readonly CosName JBIG2_DECODE = new CosName("JBIG2Decode");
|
||||
public static readonly CosName JBIG2_GLOBALS = new CosName("JBIG2Globals");
|
||||
public static readonly CosName JPX_DECODE = new CosName("JPXDecode");
|
||||
public static readonly CosName JS = new CosName("JS");
|
||||
// K
|
||||
public static readonly CosName K = new CosName("K");
|
||||
public static readonly CosName KEYWORDS = new CosName("Keywords");
|
||||
public static readonly CosName KIDS = new CosName("Kids");
|
||||
// L
|
||||
public static readonly CosName L = new CosName("L");
|
||||
public static readonly CosName LAB = new CosName("Lab");
|
||||
public static readonly CosName LANG = new CosName("Lang");
|
||||
public static readonly CosName LAST = new CosName("Last");
|
||||
public static readonly CosName LAST_CHAR = new CosName("LastChar");
|
||||
public static readonly CosName LAST_MODIFIED = new CosName("LastModified");
|
||||
public static readonly CosName LC = new CosName("LC");
|
||||
public static readonly CosName LE = new CosName("LE");
|
||||
public static readonly CosName LEADING = new CosName("Leading");
|
||||
public static readonly CosName LEGAL_ATTESTATION = new CosName("LegalAttestation");
|
||||
public static readonly CosName LENGTH = new CosName("Length");
|
||||
public static readonly CosName LENGTH1 = new CosName("Length1");
|
||||
public static readonly CosName LENGTH2 = new CosName("Length2");
|
||||
public static readonly CosName LIGHTEN = new CosName("Lighten");
|
||||
public static readonly CosName LIMITS = new CosName("Limits");
|
||||
public static readonly CosName LJ = new CosName("LJ");
|
||||
public static readonly CosName LL = new CosName("LL");
|
||||
public static readonly CosName LLE = new CosName("LLE");
|
||||
public static readonly CosName LLO = new CosName("LLO");
|
||||
public static readonly CosName LOCATION = new CosName("Location");
|
||||
public static readonly CosName LUMINOSITY = new CosName("Luminosity");
|
||||
public static readonly CosName LW = new CosName("LW");
|
||||
public static readonly CosName LZW_DECODE = new CosName("LZWDecode");
|
||||
public static readonly CosName LZW_DECODE_ABBREVIATION = new CosName("LZW");
|
||||
// M
|
||||
public static readonly CosName M = new CosName("M");
|
||||
public static readonly CosName MAC = new CosName("Mac");
|
||||
public static readonly CosName MAC_EXPERT_ENCODING = new CosName("MacExpertEncoding");
|
||||
public static readonly CosName MAC_ROMAN_ENCODING = new CosName("MacRomanEncoding");
|
||||
public static readonly CosName MARK_INFO = new CosName("MarkInfo");
|
||||
public static readonly CosName MASK = new CosName("Mask");
|
||||
public static readonly CosName MATRIX = new CosName("Matrix");
|
||||
public static readonly CosName MAX_LEN = new CosName("MaxLen");
|
||||
public static readonly CosName MAX_WIDTH = new CosName("MaxWidth");
|
||||
public static readonly CosName MCID = new CosName("MCID");
|
||||
public static readonly CosName MDP = new CosName("MDP");
|
||||
public static readonly CosName MEDIA_BOX = new CosName("MediaBox");
|
||||
public static readonly CosName METADATA = new CosName("Metadata");
|
||||
public static readonly CosName MISSING_WIDTH = new CosName("MissingWidth");
|
||||
public static readonly CosName MIX = new CosName("Mix");
|
||||
public static readonly CosName MK = new CosName("MK");
|
||||
public static readonly CosName ML = new CosName("ML");
|
||||
public static readonly CosName MM_TYPE1 = new CosName("MMType1");
|
||||
public static readonly CosName MOD_DATE = new CosName("ModDate");
|
||||
public static readonly CosName MULTIPLY = new CosName("Multiply");
|
||||
// N
|
||||
public static readonly CosName N = new CosName("N");
|
||||
public static readonly CosName NAME = new CosName("Name");
|
||||
public static readonly CosName NAMES = new CosName("Names");
|
||||
public static readonly CosName NEED_APPEARANCES = new CosName("NeedAppearances");
|
||||
public static readonly CosName NEXT = new CosName("Next");
|
||||
public static readonly CosName NM = new CosName("NM");
|
||||
public static readonly CosName NON_EFONT_NO_WARN = new CosName("NonEFontNoWarn");
|
||||
public static readonly CosName NON_FULL_SCREEN_PAGE_MODE = new CosName("NonFullScreenPageMode");
|
||||
public static readonly CosName NONE = new CosName("None");
|
||||
public static readonly CosName NORMAL = new CosName("Normal");
|
||||
public static readonly CosName NUMS = new CosName("Nums");
|
||||
// O
|
||||
public static readonly CosName O = new CosName("O");
|
||||
public static readonly CosName OBJ = new CosName("Obj");
|
||||
public static readonly CosName OBJ_STM = new CosName("ObjStm");
|
||||
public static readonly CosName OC = new CosName("OC");
|
||||
public static readonly CosName OCG = new CosName("OCG");
|
||||
public static readonly CosName OCGS = new CosName("OCGs");
|
||||
public static readonly CosName OCPROPERTIES = new CosName("OCProperties");
|
||||
public static readonly CosName OE = new CosName("OE");
|
||||
|
||||
/**
|
||||
* "OFF", to be used for OCGs, not for Acroform
|
||||
*/
|
||||
public static readonly CosName OFF = new CosName("OFF");
|
||||
|
||||
/**
|
||||
* "Off", to be used for Acroform, not for OCGs
|
||||
*/
|
||||
public static readonly CosName Off = new CosName("Off");
|
||||
|
||||
public static readonly CosName ON = new CosName("ON");
|
||||
public static readonly CosName OP = new CosName("OP");
|
||||
public static readonly CosName OP_NS = new CosName("op");
|
||||
public static readonly CosName OPEN_ACTION = new CosName("OpenAction");
|
||||
public static readonly CosName OPEN_TYPE = new CosName("OpenType");
|
||||
public static readonly CosName OPM = new CosName("OPM");
|
||||
public static readonly CosName OPT = new CosName("Opt");
|
||||
public static readonly CosName ORDER = new CosName("Order");
|
||||
public static readonly CosName ORDERING = new CosName("Ordering");
|
||||
public static readonly CosName OS = new CosName("OS");
|
||||
public static readonly CosName OUTLINES = new CosName("Outlines");
|
||||
public static readonly CosName OUTPUT_CONDITION = new CosName("OutputCondition");
|
||||
public static readonly CosName OUTPUT_CONDITION_IDENTIFIER = new CosName(
|
||||
"OutputConditionIdentifier");
|
||||
public static readonly CosName OUTPUT_INTENT = new CosName("OutputIntent");
|
||||
public static readonly CosName OUTPUT_INTENTS = new CosName("OutputIntents");
|
||||
public static readonly CosName OVERLAY = new CosName("Overlay");
|
||||
// P
|
||||
public static readonly CosName P = new CosName("P");
|
||||
public static readonly CosName PAGE = new CosName("Page");
|
||||
public static readonly CosName PAGE_LABELS = new CosName("PageLabels");
|
||||
public static readonly CosName PAGE_LAYOUT = new CosName("PageLayout");
|
||||
public static readonly CosName PAGE_MODE = new CosName("PageMode");
|
||||
public static readonly CosName PAGES = new CosName("Pages");
|
||||
public static readonly CosName PAINT_TYPE = new CosName("PaintType");
|
||||
public static readonly CosName PANOSE = new CosName("Panose");
|
||||
public static readonly CosName PARAMS = new CosName("Params");
|
||||
public static readonly CosName PARENT = new CosName("Parent");
|
||||
public static readonly CosName PARENT_TREE = new CosName("ParentTree");
|
||||
public static readonly CosName PARENT_TREE_NEXT_KEY = new CosName("ParentTreeNextKey");
|
||||
public static readonly CosName PATTERN = new CosName("Pattern");
|
||||
public static readonly CosName PATTERN_TYPE = new CosName("PatternType");
|
||||
public static readonly CosName PDF_DOC_ENCODING = new CosName("PDFDocEncoding");
|
||||
public static readonly CosName PERMS = new CosName("Perms");
|
||||
public static readonly CosName PG = new CosName("Pg");
|
||||
public static readonly CosName PRE_RELEASE = new CosName("PreRelease");
|
||||
public static readonly CosName PREDICTOR = new CosName("Predictor");
|
||||
public static readonly CosName PREV = new CosName("Prev");
|
||||
public static readonly CosName PRINT_AREA = new CosName("PrintArea");
|
||||
public static readonly CosName PRINT_CLIP = new CosName("PrintClip");
|
||||
public static readonly CosName PRINT_SCALING = new CosName("PrintScaling");
|
||||
public static readonly CosName PROC_SET = new CosName("ProcSet");
|
||||
public static readonly CosName PROCESS = new CosName("Process");
|
||||
public static readonly CosName PRODUCER = new CosName("Producer");
|
||||
public static readonly CosName PROP_BUILD = new CosName("Prop_Build");
|
||||
public static readonly CosName PROPERTIES = new CosName("Properties");
|
||||
public static readonly CosName PS = new CosName("PS");
|
||||
public static readonly CosName PUB_SEC = new CosName("PubSec");
|
||||
// Q
|
||||
public static readonly CosName Q = new CosName("Q");
|
||||
public static readonly CosName QUADPOINTS = new CosName("QuadPoints");
|
||||
// R
|
||||
public static readonly CosName R = new CosName("R");
|
||||
public static readonly CosName RANGE = new CosName("Range");
|
||||
public static readonly CosName RC = new CosName("RC");
|
||||
public static readonly CosName RD = new CosName("RD");
|
||||
public static readonly CosName REASON = new CosName("Reason");
|
||||
public static readonly CosName REASONS = new CosName("Reasons");
|
||||
public static readonly CosName REPEAT = new CosName("Repeat");
|
||||
public static readonly CosName RECIPIENTS = new CosName("Recipients");
|
||||
public static readonly CosName RECT = new CosName("Rect");
|
||||
public static readonly CosName REGISTRY = new CosName("Registry");
|
||||
public static readonly CosName REGISTRY_NAME = new CosName("RegistryName");
|
||||
public static readonly CosName RENAME = new CosName("Rename");
|
||||
public static readonly CosName RESOURCES = new CosName("Resources");
|
||||
public static readonly CosName RGB = new CosName("RGB");
|
||||
public static readonly CosName RI = new CosName("RI");
|
||||
public static readonly CosName ROLE_MAP = new CosName("RoleMap");
|
||||
public static readonly CosName ROOT = new CosName("Root");
|
||||
public static readonly CosName ROTATE = new CosName("Rotate");
|
||||
public static readonly CosName ROWS = new CosName("Rows");
|
||||
public static readonly CosName RUN_LENGTH_DECODE = new CosName("RunLengthDecode");
|
||||
public static readonly CosName RUN_LENGTH_DECODE_ABBREVIATION = new CosName("RL");
|
||||
public static readonly CosName RV = new CosName("RV");
|
||||
// S
|
||||
public static readonly CosName S = new CosName("S");
|
||||
public static readonly CosName SA = new CosName("SA");
|
||||
public static readonly CosName SCREEN = new CosName("Screen");
|
||||
public static readonly CosName SE = new CosName("SE");
|
||||
public static readonly CosName SEPARATION = new CosName("Separation");
|
||||
public static readonly CosName SET_F = new CosName("SetF");
|
||||
public static readonly CosName SET_FF = new CosName("SetFf");
|
||||
public static readonly CosName SHADING = new CosName("Shading");
|
||||
public static readonly CosName SHADING_TYPE = new CosName("ShadingType");
|
||||
public static readonly CosName SIG = new CosName("Sig");
|
||||
public static readonly CosName SIG_FLAGS = new CosName("SigFlags");
|
||||
public static readonly CosName SIZE = new CosName("Size");
|
||||
public static readonly CosName SM = new CosName("SM");
|
||||
public static readonly CosName SMASK = new CosName("SMask");
|
||||
public static readonly CosName SOFT_LIGHT = new CosName("SoftLight");
|
||||
public static readonly CosName SOUND = new CosName("Sound");
|
||||
public static readonly CosName SS = new CosName("SS");
|
||||
public static readonly CosName ST = new CosName("St");
|
||||
public static readonly CosName STANDARD_ENCODING = new CosName("StandardEncoding");
|
||||
public static readonly CosName STATE = new CosName("State");
|
||||
public static readonly CosName STATE_MODEL = new CosName("StateModel");
|
||||
public static readonly CosName STATUS = new CosName("Status");
|
||||
public static readonly CosName STD_CF = new CosName("StdCF");
|
||||
public static readonly CosName STEM_H = new CosName("StemH");
|
||||
public static readonly CosName STEM_V = new CosName("StemV");
|
||||
public static readonly CosName STM_F = new CosName("StmF");
|
||||
public static readonly CosName STR_F = new CosName("StrF");
|
||||
public static readonly CosName STRUCT_PARENT = new CosName("StructParent");
|
||||
public static readonly CosName STRUCT_PARENTS = new CosName("StructParents");
|
||||
public static readonly CosName STRUCT_TREE_ROOT = new CosName("StructTreeRoot");
|
||||
public static readonly CosName STYLE = new CosName("Style");
|
||||
public static readonly CosName SUB_FILTER = new CosName("SubFilter");
|
||||
public static readonly CosName SUBJ = new CosName("Subj");
|
||||
public static readonly CosName SUBJECT = new CosName("Subject");
|
||||
public static readonly CosName SUBTYPE = new CosName("Subtype");
|
||||
public static readonly CosName SUPPLEMENT = new CosName("Supplement");
|
||||
public static readonly CosName SV = new CosName("SV");
|
||||
public static readonly CosName SW = new CosName("SW");
|
||||
public static readonly CosName SY = new CosName("Sy");
|
||||
public static readonly CosName SYNCHRONOUS = new CosName("Synchronous");
|
||||
// T
|
||||
public static readonly CosName T = new CosName("T");
|
||||
public static readonly CosName TARGET = new CosName("Target");
|
||||
public static readonly CosName TEMPLATES = new CosName("Templates");
|
||||
public static readonly CosName THREADS = new CosName("Threads");
|
||||
public static readonly CosName THUMB = new CosName("Thumb");
|
||||
public static readonly CosName TI = new CosName("TI");
|
||||
public static readonly CosName TILING_TYPE = new CosName("TilingType");
|
||||
public static readonly CosName TIME_STAMP = new CosName("TimeStamp");
|
||||
public static readonly CosName TITLE = new CosName("Title");
|
||||
public static readonly CosName TK = new CosName("TK");
|
||||
public static readonly CosName TM = new CosName("TM");
|
||||
public static readonly CosName TO_UNICODE = new CosName("ToUnicode");
|
||||
public static readonly CosName TR = new CosName("TR");
|
||||
public static readonly CosName TR2 = new CosName("TR2");
|
||||
public static readonly CosName TRAPPED = new CosName("Trapped");
|
||||
public static readonly CosName TRANS = new CosName("Trans");
|
||||
public static readonly CosName TRANSPARENCY = new CosName("Transparency");
|
||||
public static readonly CosName TREF = new CosName("TRef");
|
||||
public static readonly CosName TRIM_BOX = new CosName("TrimBox");
|
||||
public static readonly CosName TRUE_TYPE = new CosName("TrueType");
|
||||
public static readonly CosName TRUSTED_MODE = new CosName("TrustedMode");
|
||||
public static readonly CosName TU = new CosName("TU");
|
||||
/** Acro form field type for text field. */
|
||||
public static readonly CosName TX = new CosName("Tx");
|
||||
public static readonly CosName TYPE = new CosName("Type");
|
||||
public static readonly CosName TYPE0 = new CosName("Type0");
|
||||
public static readonly CosName TYPE1 = new CosName("Type1");
|
||||
public static readonly CosName TYPE3 = new CosName("Type3");
|
||||
// U
|
||||
public static readonly CosName U = new CosName("U");
|
||||
public static readonly CosName UE = new CosName("UE");
|
||||
public static readonly CosName UF = new CosName("UF");
|
||||
public static readonly CosName UNCHANGED = new CosName("Unchanged");
|
||||
public static readonly CosName UNIX = new CosName("Unix");
|
||||
public static readonly CosName URI = new CosName("URI");
|
||||
public static readonly CosName URL = new CosName("URL");
|
||||
public static readonly CosName USER_UNIT = new CosName("UserUnit");
|
||||
// V
|
||||
public static readonly CosName V = new CosName("V");
|
||||
public static readonly CosName VERISIGN_PPKVS = new CosName("VeriSign.PPKVS");
|
||||
public static readonly CosName VERSION = new CosName("Version");
|
||||
public static readonly CosName VERTICES = new CosName("Vertices");
|
||||
public static readonly CosName VERTICES_PER_ROW = new CosName("VerticesPerRow");
|
||||
public static readonly CosName VIEW_AREA = new CosName("ViewArea");
|
||||
public static readonly CosName VIEW_CLIP = new CosName("ViewClip");
|
||||
public static readonly CosName VIEWER_PREFERENCES = new CosName("ViewerPreferences");
|
||||
public static readonly CosName VOLUME = new CosName("Volume");
|
||||
// W
|
||||
public static readonly CosName W = new CosName("W");
|
||||
public static readonly CosName W2 = new CosName("W2");
|
||||
public static readonly CosName WHITE_POINT = new CosName("WhitePoint");
|
||||
public static readonly CosName WIDGET = new CosName("Widget");
|
||||
public static readonly CosName WIDTH = new CosName("Width");
|
||||
public static readonly CosName WIDTHS = new CosName("Widths");
|
||||
public static readonly CosName WIN_ANSI_ENCODING = new CosName("WinAnsiEncoding");
|
||||
// X
|
||||
public static readonly CosName XFA = new CosName("XFA");
|
||||
public static readonly CosName X_STEP = new CosName("XStep");
|
||||
public static readonly CosName XHEIGHT = new CosName("XHeight");
|
||||
public static readonly CosName XOBJECT = new CosName("XObject");
|
||||
public static readonly CosName XREF = new CosName("XRef");
|
||||
public static readonly CosName XREF_STM = new CosName("XRefStm");
|
||||
// Y
|
||||
public static readonly CosName Y_STEP = new CosName("YStep");
|
||||
public static readonly CosName YES = new CosName("Yes");
|
||||
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Create or retrieve a <see cref="CosName"/> object with a given name.
|
||||
/// </summary>
|
||||
/// <returns><see langword="null"/> if the string is invalid, an instance of the given <see cref="CosName"/> otherwise.</returns>
|
||||
[CanBeNull]
|
||||
[DebuggerStepThrough]
|
||||
public static CosName Create(string name)
|
||||
{
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!CommonNameMap.TryGetValue(name, out var cosName))
|
||||
{
|
||||
if (!NameMap.TryGetValue(name, out cosName))
|
||||
{
|
||||
cosName = new CosName(name, false);
|
||||
}
|
||||
}
|
||||
|
||||
return cosName;
|
||||
}
|
||||
|
||||
public static bool Equals(CosName f, CosName s)
|
||||
{
|
||||
return string.Equals(f?.Name, s?.Name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private constructor. This will limit the number of CosName objects. that are created.
|
||||
*
|
||||
* @param name The name of the CosName object.
|
||||
* @param staticValue Indicates if the CosName object is static so that it can be stored in the HashMap without
|
||||
* synchronizing.
|
||||
*/
|
||||
private CosName(string aName, bool staticValue = true)
|
||||
{
|
||||
Name = aName;
|
||||
if (staticValue)
|
||||
{
|
||||
CommonNameMap.Add(aName, this);
|
||||
}
|
||||
else
|
||||
{
|
||||
NameMap.TryAdd(aName, this);
|
||||
}
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"/{Name}";
|
||||
}
|
||||
|
||||
public void WriteToPdfStream(BinaryWriter output)
|
||||
{
|
||||
output.Write('/');
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(Name);
|
||||
|
||||
foreach (var b in bytes)
|
||||
{
|
||||
int current = b & 0xFF;
|
||||
|
||||
// be more restrictive than the PDF spec, "Name Objects", see PDFBOX-2073
|
||||
if (current >= 'A' && current <= 'Z' ||
|
||||
current >= 'a' && current <= 'z' ||
|
||||
current >= '0' && current <= '9' ||
|
||||
current == '+' ||
|
||||
current == '-' ||
|
||||
current == '_' ||
|
||||
current == '@' ||
|
||||
current == '*' ||
|
||||
current == '$' ||
|
||||
current == ';' ||
|
||||
current == '.')
|
||||
{
|
||||
output.Write(current);
|
||||
}
|
||||
else
|
||||
{
|
||||
output.Write('#');
|
||||
Hex.WriteHexByte(b, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as CosName);
|
||||
}
|
||||
|
||||
public bool Equals(CosName other)
|
||||
{
|
||||
return string.Equals(Name, other?.Name);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Name.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is the name <see cref="string.Empty"/>?
|
||||
/// </summary>
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return Name == string.Empty;
|
||||
}
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromName(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Not usually needed except if resources need to be reclaimed in a long running process.
|
||||
*/
|
||||
public static void ClearResources()
|
||||
{
|
||||
// Clear them all
|
||||
NameMap.Clear();
|
||||
}
|
||||
|
||||
public int CompareTo(CosName other)
|
||||
{
|
||||
return Name?.CompareTo(other?.Name) ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
using System.IO;
|
||||
using Core;
|
||||
|
||||
internal class CosNull : CosBase, ICosStreamWriter
|
||||
{
|
||||
/// <summary>
|
||||
/// The Null Token
|
||||
/// </summary>
|
||||
public static readonly byte[] NullBytes = { (byte)'n', (byte)'u', (byte)'l', (byte)'l' };
|
||||
|
||||
/// <summary>
|
||||
/// The one <see cref="CosNull"/> object in the system.
|
||||
/// </summary>
|
||||
public static CosNull Null => NullLazy.Value;
|
||||
private static readonly Lazy<CosNull> NullLazy = new Lazy<CosNull>(() => new CosNull());
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Limit creation of <see cref="CosNull"/> to one instance.
|
||||
/// </summary>
|
||||
private CosNull() { }
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromNull(this);
|
||||
}
|
||||
|
||||
public void WriteToPdfStream(BinaryWriter output)
|
||||
{
|
||||
output.Write(NullBytes);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "COSNull";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
|
||||
internal static class CosNumberFactory
|
||||
{
|
||||
/**
|
||||
* This factory method will get the appropriate number object.
|
||||
*
|
||||
* @param number The string representation of the number.
|
||||
*
|
||||
* @return A number object, either float or int.
|
||||
*
|
||||
* @throws IOException If the string is not a number.
|
||||
*/
|
||||
public static ICosNumber get(string value)
|
||||
{
|
||||
if (value.Length == 1)
|
||||
{
|
||||
char digit = value[0];
|
||||
if ('0' <= digit && digit <= '9')
|
||||
{
|
||||
return CosInt.Get(digit - '0');
|
||||
}
|
||||
else if (digit == '-' || digit == '.')
|
||||
{
|
||||
// See https://issues.apache.org/jira/browse/PDFBOX-592
|
||||
return CosInt.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException($"Not a number: {value}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (value.IndexOf('.') == -1 && (value.ToLower().IndexOf('e') == -1))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (value[0] == '+')
|
||||
{
|
||||
return CosInt.Get(long.Parse(value.Substring(1)));
|
||||
}
|
||||
return CosInt.Get(long.Parse(value));
|
||||
}
|
||||
catch (FormatException)
|
||||
{
|
||||
// might be a huge number, see PDFBOX-3116
|
||||
return new CosFloat(value);
|
||||
}
|
||||
}
|
||||
|
||||
return new CosFloat(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System.Diagnostics;
|
||||
using ContentStream;
|
||||
|
||||
internal class CosObject : CosBase, ICosUpdateInfo
|
||||
{
|
||||
private CosBase baseObject;
|
||||
private long objectNumber;
|
||||
private int generationNumber;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param object The object that this encapsulates.
|
||||
*
|
||||
*/
|
||||
public CosObject(CosBase obj)
|
||||
{
|
||||
SetObject(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get the dictionary object in this object that has the name key and
|
||||
* if it is a pdfobjref then it will dereference that and return it.
|
||||
*
|
||||
* @param key The key to the value that we are searching for.
|
||||
*
|
||||
* @return The pdf object that matches the key.
|
||||
*/
|
||||
public CosBase GetDictionaryObject(CosName key)
|
||||
{
|
||||
CosBase retval = null;
|
||||
if (baseObject is CosDictionary)
|
||||
{
|
||||
retval = ((CosDictionary)baseObject).getDictionaryObject(key);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get the dictionary object in this object that has the name key.
|
||||
*
|
||||
* @param key The key to the value that we are searching for.
|
||||
*
|
||||
* @return The pdf object that matches the key.
|
||||
*/
|
||||
public CosBase GetItem(CosName key)
|
||||
{
|
||||
CosBase retval = null;
|
||||
if (baseObject is CosDictionary)
|
||||
{
|
||||
retval = ((CosDictionary)baseObject).getItem(key);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will get the object that this object encapsulates.
|
||||
*
|
||||
* @return The encapsulated object.
|
||||
*/
|
||||
public CosBase GetObject()
|
||||
{
|
||||
return baseObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will set the object that this object encapsulates.
|
||||
*
|
||||
* @param object The new object to encapsulate.
|
||||
*/
|
||||
public void SetObject(CosBase obj)
|
||||
{
|
||||
baseObject = obj;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "COSObject{" + objectNumber + ", " + generationNumber + "}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property objectNumber.
|
||||
* @return Value of property objectNumber.
|
||||
*/
|
||||
public long GetObjectNumber()
|
||||
{
|
||||
return objectNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for property objectNumber.
|
||||
* @param objectNum New value of property objectNumber.
|
||||
*/
|
||||
public void SetObjectNumber(long objectNum)
|
||||
{
|
||||
objectNumber = objectNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property generationNumber.
|
||||
* @return Value of property generationNumber.
|
||||
*/
|
||||
public int GetGenerationNumber()
|
||||
{
|
||||
return generationNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for property generationNumber.
|
||||
* @param generationNumberValue New value of property generationNumber.
|
||||
*/
|
||||
public void SetGenerationNumber(int generationNumberValue)
|
||||
{
|
||||
generationNumber = generationNumberValue;
|
||||
}
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return GetObject() != null ? GetObject().Accept(visitor) : CosNull.Null.Accept(visitor);
|
||||
}
|
||||
|
||||
public bool NeedsToBeUpdated { get; set; }
|
||||
|
||||
[DebuggerStepThrough]
|
||||
public IndirectReference ToIndirectReference()
|
||||
{
|
||||
return new IndirectReference(objectNumber, generationNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using ContentStream;
|
||||
|
||||
internal class CosObjectPool
|
||||
{
|
||||
private readonly Dictionary<IndirectReference, CosObject> objects = new Dictionary<IndirectReference, CosObject>();
|
||||
|
||||
public CosObject Get(IndirectReference key)
|
||||
{
|
||||
if (objects.TryGetValue(key, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
// this was a forward reference, make "proxy" object
|
||||
var obj = new CosObject(null);
|
||||
obj.SetObjectNumber(key.ObjectNumber);
|
||||
obj.SetGenerationNumber(key.Generation);
|
||||
objects[key] = obj;
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
public CosObject GetOrCreateDefault(IndirectReference key)
|
||||
{
|
||||
if (!objects.TryGetValue(key, out CosObject obj))
|
||||
{
|
||||
obj = new CosObject(null);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,189 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Util;
|
||||
|
||||
internal class CosString : CosBase
|
||||
{
|
||||
public byte[] Bytes { get; }
|
||||
|
||||
/**
|
||||
* Creates a new PDF string from a byte array. This method can be used to read a string from
|
||||
* an existing PDF file, or to create a new byte string.
|
||||
*
|
||||
* @param bytes The raw bytes of the PDF text string or byte string.
|
||||
*/
|
||||
public CosString(byte[] bytes)
|
||||
{
|
||||
Bytes = CloneBytes(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <i>text string</i> from a Java string.
|
||||
*
|
||||
* @param text The string value of the object.
|
||||
*/
|
||||
public CosString(string text)
|
||||
{
|
||||
// check whether the string uses only characters available in PDFDocEncoding
|
||||
bool isOnlyPdfDocEncoding = true;
|
||||
for (int i = 0; i < text.Length; i++)
|
||||
{
|
||||
if (!PdfDocEncoding.ContainsChar(text[i]))
|
||||
{
|
||||
isOnlyPdfDocEncoding = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isOnlyPdfDocEncoding)
|
||||
{
|
||||
// PDFDocEncoded string
|
||||
Bytes = PdfDocEncoding.GetBytes(text);
|
||||
}
|
||||
else
|
||||
{
|
||||
// UTF-16BE encoded string with a leading byte order marker
|
||||
byte[] data = Encoding.BigEndianUnicode.GetBytes(text);
|
||||
|
||||
using (var outBytes = new MemoryStream(data.Length + 2))
|
||||
using (var w = new StreamWriter(outBytes))
|
||||
{
|
||||
w.Write(0xFE); // BOM
|
||||
w.Write(0xFF); // BOM
|
||||
|
||||
try
|
||||
{
|
||||
w.Write(data);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// should never happen
|
||||
throw new InvalidOperationException("Fatal Error", e);
|
||||
}
|
||||
|
||||
Bytes = outBytes.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] CloneBytes(IReadOnlyList<byte> bytes)
|
||||
{
|
||||
var result = new byte[bytes.Count];
|
||||
|
||||
for (int i = 0; i < bytes.Count; i++)
|
||||
{
|
||||
result[i] = bytes[i];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will create a <see cref="CosString"/> from a string of hex characters.
|
||||
/// </summary>
|
||||
/// <param name="hex">A hex string.</param>
|
||||
/// <returns>A cos string with the hex characters converted to their actual bytes.</returns>
|
||||
public static CosString ParseHex(string hex)
|
||||
{
|
||||
using (var bytes = new MemoryStream())
|
||||
using (var writer = new StreamWriter(bytes))
|
||||
{
|
||||
StringBuilder hexBuffer = new StringBuilder(hex.Trim());
|
||||
|
||||
// if odd number then the last hex digit is assumed to be 0
|
||||
if (hexBuffer.Length % 2 != 0)
|
||||
{
|
||||
hexBuffer.Append('0');
|
||||
}
|
||||
|
||||
int length = hexBuffer.Length;
|
||||
for (int i = 0; i < length; i += 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
writer.Write(Convert.ToInt32(hexBuffer.ToString().Substring(i, 2), 16));
|
||||
}
|
||||
catch (FormatException e)
|
||||
{
|
||||
throw new ArgumentException("Invalid hex string: " + hex, e);
|
||||
}
|
||||
}
|
||||
|
||||
return new CosString(bytes.ToArray());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Returns the content of this string as a PDF <i>text string</i>.
|
||||
*/
|
||||
public string GetString()
|
||||
{
|
||||
// text string - BOM indicates Unicode
|
||||
if (Bytes.Length >= 2)
|
||||
{
|
||||
if ((Bytes[0] & 0xff) == 0xFE && (Bytes[1] & 0xff) == 0xFF)
|
||||
{
|
||||
Encoding.BigEndianUnicode.GetString(Bytes, 2, Bytes.Length - 2);
|
||||
}
|
||||
else if ((Bytes[0] & 0xff) == 0xFF && (Bytes[1] & 0xff) == 0xFE)
|
||||
{
|
||||
Encoding.Unicode.GetString(Bytes, 2, Bytes.Length - 2);
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise use PDFDocEncoding
|
||||
return PdfDocEncoding.ToString(Bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the content of this string as a PDF <i>ASCII string</i>.
|
||||
*/
|
||||
public string GetAscii()
|
||||
{
|
||||
return Encoding.ASCII.GetString(Bytes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will take this string and create a hex representation of the bytes that make the string.
|
||||
/// </summary>
|
||||
/// <returns>A hex string representing the bytes in this string.</returns>
|
||||
public string ToHexString()
|
||||
{
|
||||
return Hex.GetString(Bytes);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
return Equals(obj as CosString);
|
||||
}
|
||||
|
||||
protected bool Equals(CosString other)
|
||||
{
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var thisString = GetString();
|
||||
var otherString = other.GetString();
|
||||
|
||||
return string.Equals(thisString, otherString);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return ((Bytes != null ? Bytes.GetHashCode() : 0) * 397);
|
||||
}
|
||||
}
|
||||
|
||||
public override object Accept(ICosVisitor visitor)
|
||||
{
|
||||
return visitor.VisitFromString(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
internal interface ICosNumber
|
||||
{
|
||||
float AsFloat();
|
||||
|
||||
double AsDouble();
|
||||
|
||||
int AsInt();
|
||||
|
||||
long AsLong();
|
||||
|
||||
decimal AsDecimal();
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
namespace UglyToad.PdfPig.Cos
|
||||
{
|
||||
using ContentStream;
|
||||
|
||||
/**
|
||||
* An interface for visiting a PDF document at the type (COS) level.
|
||||
*
|
||||
* @author Michael Traut
|
||||
*/
|
||||
internal interface ICosVisitor
|
||||
{
|
||||
/**
|
||||
* Notification of visit to Array object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromArray(COSArray obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to boolean object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromBoolean(PdfBoolean obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to dictionary object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromDictionary(CosDictionary obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to float object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromFloat(CosFloat obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to integer object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromInt(CosInt obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to name object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromName(CosName obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to null object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromNull(CosNull obj);
|
||||
|
||||
/**
|
||||
* Notification of visit to string object.
|
||||
*
|
||||
* @param obj The Object that is being visited.
|
||||
* @return any Object depending on the visitor implementation, or null
|
||||
* @throws IOException If there is an error while visiting this object.
|
||||
*/
|
||||
object VisitFromString(CosString obj);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
namespace UglyToad.PdfPig.Filters
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using ContentStream;
|
||||
using Tokenization.Tokens;
|
||||
|
||||
internal interface IFilterProvider
|
||||
{
|
||||
IReadOnlyList<IFilter> GetFilters(DictionaryToken dictionary);
|
||||
|
||||
IReadOnlyList<IFilter> GetFilters(PdfDictionary streamDictionary);
|
||||
|
||||
IReadOnlyList<IFilter> GetAllFilters();
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ContentStream;
|
||||
using Cos;
|
||||
using Exceptions;
|
||||
using Logging;
|
||||
using Tokenization.Tokens;
|
||||
@@ -56,35 +54,7 @@
|
||||
throw new PdfDocumentFormatException($"The filter for the stream was not a valid object. Expected name or array, instead got: {token}.");
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public IReadOnlyList<IFilter> GetFilters(PdfDictionary streamDictionary)
|
||||
{
|
||||
if (streamDictionary == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(streamDictionary));
|
||||
}
|
||||
|
||||
var filterObject = streamDictionary.GetItemOrDefault(CosName.FILTER);
|
||||
|
||||
if (filterObject == null)
|
||||
{
|
||||
return new IFilter[0];
|
||||
}
|
||||
|
||||
switch (filterObject)
|
||||
{
|
||||
case COSArray filters:
|
||||
// TODO: presumably this may be invalid...
|
||||
return filters.Select(x => GetFilterStrict(((CosName) x).Name)).ToList();
|
||||
case CosName name:
|
||||
return new[] {GetFilterStrict(name.Name)};
|
||||
default:
|
||||
throw new InvalidOperationException("The filter for a stream may be either a string or an array, instead this Pdf has: "
|
||||
+ filterObject.GetType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IFilter GetFilterStrict(string name)
|
||||
{
|
||||
if (!filterFactories.TryGetValue(name, out var factory))
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
namespace UglyToad.PdfPig.Fonts.Parser.Handlers
|
||||
{
|
||||
using Cmap;
|
||||
using ContentStream;
|
||||
using Encodings;
|
||||
using Exceptions;
|
||||
using Filters;
|
||||
@@ -109,10 +108,8 @@
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var raw = new PdfRawStream(stream);
|
||||
|
||||
var bytes = raw.Decode(filterProvider);
|
||||
|
||||
var bytes = stream.Decode(filterProvider);
|
||||
|
||||
var font = type1FontParser.Parse(new ByteArrayInputBytes(bytes));
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace UglyToad.PdfPig.Graphics
|
||||
|
||||
arguments.Add(array.ToArray());
|
||||
}
|
||||
else if (parameter.ParameterType == typeof(CosName))
|
||||
else if (parameter.ParameterType == typeof(NameToken))
|
||||
{
|
||||
if (operands[offset] is NameToken name)
|
||||
{
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
xrefCosChecker = new XrefCosOffsetChecker();
|
||||
}
|
||||
|
||||
public CrossReferenceTable Parse(IRandomAccessRead reader, bool isLenientParsing, long xrefLocation,
|
||||
CosObjectPool pool, IPdfTokenScanner pdfScanner, ISeekableTokenScanner tokenScanner)
|
||||
public CrossReferenceTable Parse(IRandomAccessRead reader, bool isLenientParsing, long xrefLocation, IPdfTokenScanner pdfScanner, ISeekableTokenScanner tokenScanner)
|
||||
{
|
||||
long fixedOffset = offsetValidator.CheckXRefOffset(xrefLocation, tokenScanner, reader, isLenientParsing);
|
||||
if (fixedOffset > -1)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
{
|
||||
using System;
|
||||
using Content;
|
||||
using Cos;
|
||||
using Parts;
|
||||
|
||||
/// <summary>
|
||||
@@ -10,15 +9,12 @@
|
||||
/// </summary>
|
||||
internal class ParsingCachingProviders
|
||||
{
|
||||
public CosObjectPool ObjectPool { get; }
|
||||
|
||||
public BruteForceSearcher BruteForceSearcher { get; }
|
||||
|
||||
public IResourceStore ResourceContainer { get; }
|
||||
|
||||
public ParsingCachingProviders(CosObjectPool objectPool, BruteForceSearcher bruteForceSearcher, IResourceStore resourceContainer)
|
||||
public ParsingCachingProviders(BruteForceSearcher bruteForceSearcher, IResourceStore resourceContainer)
|
||||
{
|
||||
ObjectPool = objectPool ?? throw new ArgumentNullException(nameof(objectPool));
|
||||
BruteForceSearcher = bruteForceSearcher ?? throw new ArgumentNullException(nameof(bruteForceSearcher));
|
||||
ResourceContainer = resourceContainer ?? throw new ArgumentNullException(nameof(resourceContainer));
|
||||
}
|
||||
|
||||
@@ -56,13 +56,12 @@
|
||||
var log = container.Get<ILog>();
|
||||
var filterProvider = container.Get<IFilterProvider>();
|
||||
var bruteForceSearcher = new BruteForceSearcher(reader);
|
||||
var pool = new CosObjectPool();
|
||||
|
||||
CrossReferenceTable crossReferenceTable = null;
|
||||
|
||||
// We're ok with this since our intent is to lazily load the cross reference table.
|
||||
// ReSharper disable once AccessToModifiedClosure
|
||||
var locationProvider = new ObjectLocationProvider(() => crossReferenceTable, pool, bruteForceSearcher);
|
||||
var locationProvider = new ObjectLocationProvider(() => crossReferenceTable, bruteForceSearcher);
|
||||
var pdfScanner = new PdfTokenScanner(inputBytes, locationProvider, filterProvider);
|
||||
|
||||
var xrefValidator = new XrefOffsetValidator(log);
|
||||
@@ -79,7 +78,7 @@
|
||||
|
||||
crossReferenceOffset = validator.Validate(crossReferenceOffset, scanner, reader, isLenientParsing);
|
||||
|
||||
crossReferenceTable = crossReferenceParser.Parse(reader, isLenientParsing, crossReferenceOffset, pool, pdfScanner, scanner);
|
||||
crossReferenceTable = crossReferenceParser.Parse(reader, isLenientParsing, crossReferenceOffset, pdfScanner, scanner);
|
||||
|
||||
var trueTypeFontParser = new TrueTypeFontParser();
|
||||
var fontDescriptorFactory = new FontDescriptorFactory();
|
||||
@@ -108,7 +107,7 @@
|
||||
|
||||
var catalog = catalogFactory.Create(rootDictionary, reader, isLenientParsing);
|
||||
|
||||
var caching = new ParsingCachingProviders(pool, bruteForceSearcher, resourceContainer);
|
||||
var caching = new ParsingCachingProviders(bruteForceSearcher, resourceContainer);
|
||||
|
||||
return new PdfDocument(log, reader, version, crossReferenceTable, isLenientParsing, caching, pageFactory, catalog, information,
|
||||
pdfScanner);
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
/// Since we want to scan objects while reading the cross reference table we lazily load it when it's ready.
|
||||
/// </summary>
|
||||
private readonly Func<CrossReferenceTable> crossReferenceTable;
|
||||
private readonly CosObjectPool pool;
|
||||
private readonly BruteForceSearcher searcher;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,10 +35,9 @@
|
||||
|
||||
private readonly Dictionary<IndirectReference, long> offsets = new Dictionary<IndirectReference, long>();
|
||||
|
||||
public ObjectLocationProvider(Func<CrossReferenceTable> crossReferenceTable, CosObjectPool pool, BruteForceSearcher searcher)
|
||||
public ObjectLocationProvider(Func<CrossReferenceTable> crossReferenceTable, BruteForceSearcher searcher)
|
||||
{
|
||||
this.crossReferenceTable = crossReferenceTable;
|
||||
this.pool = pool;
|
||||
this.searcher = searcher;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user