本文整理汇总了C#中PdfDictionary.GetAsStream方法的典型用法代码示例。如果您正苦于以下问题:C# PdfDictionary.GetAsStream方法的具体用法?C# PdfDictionary.GetAsStream怎么用?C# PdfDictionary.GetAsStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfDictionary
的用法示例。
在下文中一共展示了PdfDictionary.GetAsStream方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Uses the OCGParser on a page </summary>
/// <param name="parser"> the OCGParser </param>
/// <param name="page"> the page dictionary of the page that needs to be parsed. </param>
/// <exception cref="IOException"> </exception>
private void Parse(OCGParser parser, PdfDictionary page) {
PRStream stream = (PRStream) page.GetAsStream(PdfName.CONTENTS);
PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
parser.Parse(stream, resources);
}
示例2: Parse
/**
* Parses the content of a page, replacing appearances of annotations
* with Form XObjects.
* @param page a page dictionary
* @throws IOException
*/
virtual public void Parse(PdfDictionary page, PdfIndirectReference pageref) {
LOGGER.Info("Parsing page with reference " + pageref);
// initializing member variables
baos = new MemoryStream();
this.page = page;
this.pageref = pageref;
structParents = page.GetAsNumber(PdfName.STRUCTPARENTS);
if(structParents == null)
throw new DocumentException(MessageLocalization.GetComposedMessage("can.t.read.document.structure"));
annots = page.GetAsArray(PdfName.ANNOTS);
if(annots == null)
annots = new PdfArray();
PdfDictionary resources = page.GetAsDict(PdfName.RESOURCES);
xobjects = resources.GetAsDict(PdfName.XOBJECT);
if (xobjects == null) {
xobjects = new PdfDictionary();
resources.Put(PdfName.XOBJECT, xobjects);
}
// parsing the content stream of the page
PRStream stream = (PRStream) page.GetAsStream(PdfName.CONTENTS);
byte[] contentBytes = PdfReader.GetStreamBytes(stream);
PRTokeniser tokeniser = new PRTokeniser(new RandomAccessFileOrArray(RASFACTORY.CreateSource(contentBytes)));
PdfContentParser ps = new PdfContentParser(tokeniser);
List<PdfObject> operands = new List<PdfObject>();
while (ps.Parse(operands).Count > 0) {
PdfLiteral opr = (PdfLiteral) operands[operands.Count - 1];
ProcessOperator(opr, operands);
}
// dealing with orphans
while (items.Count > 0 && items[0].GetPageref() == pageref.Number) {
StructureItem item = items[0];
if (item is StructureObject) {
ConvertToXObject((StructureObject) item);
items.RemoveAt(0);
}
}
if(annots.Length == 0) {
page.Remove(PdfName.ANNOTS);
}
else {
PdfDictionary annot;
for(int i = 0; i < annots.Size; i++) {
annot = annots.GetAsDict(i);
if(annot.GetAsNumber(PdfName.STRUCTPARENT) == null)
throw new DocumentException(MessageLocalization.GetComposedMessage("could.not.flatten.file.untagged.annotations.found"));
}
}
// replacing the content stream
baos.Flush();
baos.Close();
stream.SetData(baos.ToArray());
// showing how many items are left
LOGGER.Info(String.Format("There are {0} items left for processing", items.Count));
}