本文整理汇总了C#中PdfDictionary.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# PdfDictionary.Resolve方法的具体用法?C# PdfDictionary.Resolve怎么用?C# PdfDictionary.Resolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfDictionary
的用法示例。
在下文中一共展示了PdfDictionary.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadEncodingDifferences
/**
<summary>Loads the encoding differences into the given collection.</summary>
<param name="encodingDictionary">Encoding dictionary.</param>
<param name="codes">Encoding to alter applying differences.</param>
*/
protected void LoadEncodingDifferences(
PdfDictionary encodingDictionary,
IDictionary<ByteArray,int> codes
)
{
PdfArray differenceObjects = (PdfArray)encodingDictionary.Resolve(PdfName.Differences);
if(differenceObjects == null)
return;
/*
NOTE: Each code is the first index in a sequence of character codes to be changed.
The first character name after the code becomes the name corresponding to that code.
Subsequent names replace consecutive code indices until the next code appears
in the array or the array ends.
*/
byte[] charCodeData = new byte[1];
foreach(PdfDirectObject differenceObject in differenceObjects)
{
if(differenceObject is PdfInteger)
{charCodeData[0] = (byte)(((int)((PdfInteger)differenceObject).Value) & 0xFF);}
else // NOTE: MUST be PdfName.
{
ByteArray charCode = new ByteArray(charCodeData);
string charName = (string)((PdfName)differenceObject).Value;
if(charName.Equals(".notdef"))
{codes.Remove(charCode);}
else
{
int? code = GlyphMapping.NameToCode(charName);
codes[charCode] = (code ?? charCodeData[0]);
}
charCodeData[0]++;
}
}
}
示例2: SetScript
/**
<summary>Sets the Javascript script into the specified base data object.</summary>
*/
internal static void SetScript(
PdfDictionary baseDataObject,
PdfName key,
string value
)
{
PdfDataObject scriptObject = baseDataObject.Resolve(key);
if(!(scriptObject is PdfStream) && value.Length > 256)
{baseDataObject[key] = baseDataObject.File.Register(scriptObject = new PdfStream());}
// Insert the script!
if(scriptObject is PdfStream)
{
bytes::IBuffer scriptBuffer = ((PdfStream)scriptObject).Body;
scriptBuffer.SetLength(0);
scriptBuffer.Append(value);
}
else
{baseDataObject[key] = new PdfTextString(value);}
}
示例3: GetScript
/**
<summary>Gets the Javascript script from the specified base data object.</summary>
*/
internal static string GetScript(
PdfDictionary baseDataObject,
PdfName key
)
{
PdfDataObject scriptObject = baseDataObject.Resolve(key);
if(scriptObject == null)
return null;
else if(scriptObject is PdfTextString)
return ((PdfTextString)scriptObject).StringValue;
else
{
bytes::IBuffer scriptBuffer = ((PdfStream)scriptObject).Body;
return scriptBuffer.GetString(0,(int)scriptBuffer.Length);
}
}