本文整理汇总了C#中iTextSharp.text.pdf.PdfAnnotation类的典型用法代码示例。如果您正苦于以下问题:C# PdfAnnotation类的具体用法?C# PdfAnnotation怎么用?C# PdfAnnotation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PdfAnnotation类属于iTextSharp.text.pdf命名空间,在下文中一共展示了PdfAnnotation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Write
// ---------------------------------------------------------------------------
public void Write(Stream stream)
{
// step 1
using (Document document = new Document()) {
// step 2
PdfWriter writer = PdfWriter.GetInstance(document, stream);
// step 3
document.Open();
// step 4
Rectangle rect = new Rectangle(100, 400, 500, 800);
rect.Border = Rectangle.BOX;
rect.BorderWidth = 0.5f;
rect.BorderColor = new BaseColor(0xFF, 0x00, 0x00);
document.Add(rect);
PdfIndirectObject streamObject = null;
using (FileStream fs =
new FileStream(RESOURCE, FileMode.Open, FileAccess.Read))
{
PdfStream stream3D = new PdfStream(fs, writer);
stream3D.Put(PdfName.TYPE, new PdfName("3D"));
stream3D.Put(PdfName.SUBTYPE, new PdfName("U3D"));
stream3D.FlateCompress();
streamObject = writer.AddToBody(stream3D);
stream3D.WriteLength();
}
PdfDictionary dict3D = new PdfDictionary();
dict3D.Put(PdfName.TYPE, new PdfName("3DView"));
dict3D.Put(new PdfName("XN"), new PdfString("Default"));
dict3D.Put(new PdfName("IN"), new PdfString("Unnamed"));
dict3D.Put(new PdfName("MS"), PdfName.M);
dict3D.Put(
new PdfName("C2W"),
new PdfArray(
new float[] { 1, 0, 0, 0, 0, -1, 0, 1, 0, 3, -235, 28 }
)
);
dict3D.Put(PdfName.CO, new PdfNumber(235));
PdfIndirectObject dictObject = writer.AddToBody(dict3D);
PdfAnnotation annot = new PdfAnnotation(writer, rect);
annot.Put(PdfName.CONTENTS, new PdfString("3D Model"));
annot.Put(PdfName.SUBTYPE, new PdfName("3D"));
annot.Put(PdfName.TYPE, PdfName.ANNOT);
annot.Put(new PdfName("3DD"), streamObject.IndirectReference);
annot.Put(new PdfName("3DV"), dictObject.IndirectReference);
PdfAppearance ap = writer.DirectContent.CreateAppearance(
rect.Width, rect.Height
);
annot.SetAppearance(PdfAnnotation.APPEARANCE_NORMAL, ap);
annot.SetPage();
writer.AddAnnotation(annot);
}
}
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:59,代码来源:Pdf3D.cs
示例2: OnGenericTag
/**
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onGenericTag(
* com.itextpdf.text.pdf.PdfWriter,
* com.itextpdf.text.Document,
* com.itextpdf.text.Rectangle, java.lang.String)
*/
public override void OnGenericTag(PdfWriter writer,
Document document, Rectangle rect, string text)
{
PdfAnnotation annotation = new PdfAnnotation(writer,
new Rectangle(
rect.Right + 10, rect.Bottom,
rect.Right + 30, rect.Top
)
);
annotation.Title = "Text annotation";
annotation.Put(PdfName.SUBTYPE, PdfName.TEXT);
annotation.Put(PdfName.OPEN, PdfBoolean.PDFFALSE);
annotation.Put(PdfName.CONTENTS,
new PdfString(string.Format("Icon: {0}", text))
);
annotation.Put(PdfName.NAME, new PdfName(text));
writer.AddAnnotation(annotation);
}
开发者ID:kuujinbo,项目名称:iTextInAction2Ed,代码行数:24,代码来源:GenericAnnotations.cs
示例3: AddAnnotation
/** Adds a <CODE>PdfAnnotation</CODE> or a <CODE>PdfFormField</CODE>
* to the document. Only the top parent of a <CODE>PdfFormField</CODE>
* needs to be added.
* @param annot the <CODE>PdfAnnotation</CODE> or the <CODE>PdfFormField</CODE> to add
*/
public virtual void AddAnnotation(PdfAnnotation annot) {
pdf.AddAnnotation(annot);
}
开发者ID:,项目名称:,代码行数:8,代码来源:
示例4: AddAnnotation
internal void AddAnnotation(PdfAnnotation annot, PdfDictionary pageN) {
List<PdfAnnotation> allAnnots = new List<PdfAnnotation>();
if (annot.IsForm()) {
fieldsAdded = true;
GetAcroFields();
PdfFormField field = (PdfFormField)annot;
if (field.Parent != null)
return;
ExpandFields(field, allAnnots);
}
else
allAnnots.Add(annot);
for (int k = 0; k < allAnnots.Count; ++k) {
annot = allAnnots[k];
if (annot.PlaceInPage > 0)
pageN = reader.GetPageN(annot.PlaceInPage);
if (annot.IsForm()) {
if (!annot.IsUsed()) {
HashSet2<PdfTemplate> templates = annot.GetTemplates();
if (templates != null)
fieldTemplates.AddAll(templates);
}
PdfFormField field = (PdfFormField)annot;
if (field.Parent == null)
AddDocumentField(field.IndirectReference);
}
if (annot.IsAnnotation()) {
PdfObject pdfobj = PdfReader.GetPdfObject(pageN.Get(PdfName.ANNOTS), pageN);
PdfArray annots = null;
if (pdfobj == null || !pdfobj.IsArray()) {
annots = new PdfArray();
pageN.Put(PdfName.ANNOTS, annots);
MarkUsed(pageN);
}
else
annots = (PdfArray)pdfobj;
annots.Add(annot.IndirectReference);
MarkUsed(annots);
if (!annot.IsUsed()) {
PdfRectangle rect = (PdfRectangle)annot.Get(PdfName.RECT);
if (rect != null && (rect.Left != 0 || rect.Right != 0 || rect.Top != 0 || rect.Bottom != 0)) {
int rotation = reader.GetPageRotation(pageN);
Rectangle pageSize = reader.GetPageSizeWithRotation(pageN);
switch (rotation) {
case 90:
annot.Put(PdfName.RECT, new PdfRectangle(
pageSize.Top - rect.Top,
rect.Right,
pageSize.Top - rect.Bottom,
rect.Left));
break;
case 180:
annot.Put(PdfName.RECT, new PdfRectangle(
pageSize.Right - rect.Left,
pageSize.Top - rect.Bottom,
pageSize.Right - rect.Right,
pageSize.Top - rect.Top));
break;
case 270:
annot.Put(PdfName.RECT, new PdfRectangle(
rect.Bottom,
pageSize.Right - rect.Left,
rect.Top,
pageSize.Right - rect.Right));
break;
}
}
}
}
if (!annot.IsUsed()) {
annot.SetUsed();
AddToBody(annot, annot.IndirectReference);
}
}
}
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:75,代码来源:PdfStamperImp.cs
示例5: AddAnnotation
internal void AddAnnotation(PdfAnnotation annot) {
pageEmpty = false;
annotationsImp.AddAnnotation(annot);
}
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:4,代码来源:PdfDocument.cs
示例6: AddAnnotation
internal void AddAnnotation(PdfAnnotation annot, PdfDictionary pageN)
{
ArrayList allAnnots = new ArrayList();
if (annot.IsForm()) {
fieldsAdded = true;
AcroFields afdummy = AcroFields;
PdfFormField field = (PdfFormField)annot;
if (field.Parent != null)
return;
ExpandFields(field, allAnnots);
}
else
allAnnots.Add(annot);
for (int k = 0; k < allAnnots.Count; ++k) {
annot = (PdfAnnotation)allAnnots[k];
if (annot.PlaceInPage > 0)
pageN = reader.GetPageN(annot.PlaceInPage);
if (annot.IsForm()) {
if (!annot.IsUsed()) {
Hashtable templates = annot.Templates;
if (templates != null) {
foreach (object tpl in templates.Keys) {
fieldTemplates[tpl] = null;
}
}
}
PdfFormField field = (PdfFormField)annot;
if (field.Parent == null)
AddDocumentField(field.IndirectReference);
}
if (annot.IsAnnotation()) {
PdfArray annots = (PdfArray)PdfReader.GetPdfObject(pageN.Get(PdfName.ANNOTS), pageN);
if (annots == null) {
annots = new PdfArray();
pageN.Put(PdfName.ANNOTS, annots);
MarkUsed(pageN);
}
annots.Add(annot.IndirectReference);
MarkUsed(annots);
if (!annot.IsUsed()) {
PdfRectangle rect = (PdfRectangle)annot.Get(PdfName.RECT);
if (rect != null && (rect.Left != 0 || rect.Right != 0 || rect.Top != 0 || rect.Bottom != 0)) {
int rotation = reader.GetPageRotation(pageN);
Rectangle pageSize = reader.GetPageSizeWithRotation(pageN);
switch (rotation) {
case 90:
annot.Put(PdfName.RECT, new PdfRectangle(
pageSize.Top - rect.Bottom,
rect.Left,
pageSize.Top - rect.Top,
rect.Right));
break;
case 180:
annot.Put(PdfName.RECT, new PdfRectangle(
pageSize.Right - rect.Left,
pageSize.Top - rect.Bottom,
pageSize.Right - rect.Right,
pageSize.Top - rect.Top));
break;
case 270:
annot.Put(PdfName.RECT, new PdfRectangle(
rect.Bottom,
pageSize.Right - rect.Left,
rect.Top,
pageSize.Right - rect.Right));
break;
}
}
}
}
if (!annot.IsUsed()) {
annot.SetUsed();
AddToBody(annot, annot.IndirectReference);
}
}
}
开发者ID:hjgode,项目名称:iTextSharpCF,代码行数:76,代码来源:PdfStamperImp.cs
示例7: AddAnnotation
internal virtual void AddAnnotation(PdfAnnotation annot)
{
writer.AddAnnotation(annot);
}
开发者ID:HardcoreSoftware,项目名称:iSecretary,代码行数:4,代码来源:PdfContentByte.cs
示例8: RichMediaAnnotation
/**
* Creates a RichMediaAnnotation using rich media content that has already
* been added to the writer. Note that assets, configurations, views added
* to a RichMediaAnnotation created like this will be ignored.
* @param writer the PdfWriter to which the annotation will be added.
* @param rect the rectangle where the annotation will be added.
* @param richMediaContentReference reused rich media content.
*/
public RichMediaAnnotation(PdfWriter writer, Rectangle rect, PdfIndirectReference richMediaContentReference) {
this.richMediaContentReference = richMediaContentReference;
richMediaContent = null;
this.writer = writer;
annot = new PdfAnnotation(writer, rect);
annot.Put(PdfName.SUBTYPE, PdfName.RICHMEDIA);
}
开发者ID:jagruti23,项目名称:itextsharp,代码行数:15,代码来源:RichMediaAnnotation.cs
示例9: AnnotationCheckTest8
virtual public void AnnotationCheckTest8()
{
string filename = OUT + "AnnotationCheckTest8.pdf";
FileStream fos = new FileStream(filename, FileMode.Create);
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, fos, PdfAConformanceLevel.PDF_A_1A);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.SUBTYPE, PdfName.STAMP);
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
bool exceptionThrown = false;
try
{
document.Close();
}
catch (PdfAConformanceException e)
{
if (e.GetObject().Equals(annot) && e.Message.Equals("Annotation of type /Stamp should have Contents key."))
{
exceptionThrown = true;
}
}
if (!exceptionThrown)
Assert.Fail("PdfAConformanceException with correct message should be thrown.");
}
开发者ID:,项目名称:,代码行数:41,代码来源:
示例10: AddAnnotation
internal virtual void AddAnnotation(PdfAnnotation annot) {
bool needToTag = IsTagged() && annot.Role != null && (!(annot is PdfFormField) || ((PdfFormField) annot).Kids == null);
if (needToTag) {
OpenMCBlock(annot);
}
writer.AddAnnotation(annot);
if (needToTag) {
PdfStructureElement strucElem = null;
pdf.structElements.TryGetValue(annot.ID, out strucElem);
if (strucElem != null) {
int structParent = pdf.GetStructParentIndex(annot);
annot.Put(PdfName.STRUCTPARENT, new PdfNumber(structParent));
strucElem.SetAnnotation(annot, CurrentPage);
writer.StructureTreeRoot.SetAnnotationMark(structParent, strucElem.Reference);
}
CloseMCBlock(annot);
}
}
开发者ID:jagruti23,项目名称:itextsharp,代码行数:18,代码来源:PdfContentByte.cs
示例11: AnnotationCheckTest11
virtual public void AnnotationCheckTest11() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest11.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2A);
writer.CreateXmpMetadata();
writer.SetTagged();
document.Open();
document.AddLanguage("en-US");
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.SUBTYPE, PdfName.STAMP);
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
annot.Put(PdfName.CONTENTS, new PdfString("Hello World"));
PdfDictionary ap = new PdfDictionary();
PdfStream s = new PdfStream(Encoding.Default.GetBytes("Hello World"));
ap.Put(PdfName.N, writer.AddToBody(s).IndirectReference);
annot.Put(PdfName.AP, ap);
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
document.Close();
}
开发者ID:,项目名称:,代码行数:29,代码来源:
示例12: CreateHide
public static PdfAction CreateHide(PdfAnnotation annot, bool hide) {
return CreateHide(annot.IndirectReference, hide);
}
开发者ID:yu0410aries,项目名称:itextsharp,代码行数:3,代码来源:PdfAction.cs
示例13: AddPlainAnnotation
virtual public void AddPlainAnnotation(PdfAnnotation annot) {
annotations.Add(annot);
}
开发者ID:,项目名称:,代码行数:3,代码来源:
示例14: AddAnnotation
public override void AddAnnotation(PdfAnnotation annot)
{
}
开发者ID:boecko,项目名称:iTextSharp,代码行数:3,代码来源:PdfCopy.cs
示例15: AddAnnotation
internal override void AddAnnotation(PdfAnnotation annot)
{
((PdfStamperImp)writer).AddAnnotation(annot, ps.pageN);
}
开发者ID:bmictech,项目名称:iTextSharp,代码行数:4,代码来源:StampContent.cs
示例16: AnnotationCheckTest2_2
public void AnnotationCheckTest2_2() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest2_2.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2B);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 200, 100, 200));
annot.Put(PdfName.SUBTYPE, PdfName.WIDGET);
annot.Put(PdfName.CONTENTS, new PdfDictionary());
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
document.Close();
}
开发者ID:smartleos,项目名称:itextsharp,代码行数:23,代码来源:PdfA2CheckerTest.cs
示例17: AnnotationCheckTest2_3
public void AnnotationCheckTest2_3() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest2_3.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2B);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.SUBTYPE, PdfName.WIDGET);
annot.Put(PdfName.CONTENTS, new PdfDictionary());
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
bool exceptionThrown = false;
try {
document.Close();
}
catch (PdfAConformanceException e) {
if (e.GetObject() == annot && e.Message.Equals("Every annotation shall have at least one appearance dictionary")) {
exceptionThrown = true;
}
}
if (!exceptionThrown)
Assert.Fail("PdfAConformanceException with correct message should be thrown.");
}
开发者ID:smartleos,项目名称:itextsharp,代码行数:33,代码来源:PdfA2CheckerTest.cs
示例18: WriteLineToContent
//.........这里部分代码省略.........
for (int k = 0; k < unders.Length; ++k) {
Object[] obj = unders[k];
scolor = (BaseColor)obj[0];
float[] ps = (float[])obj[1];
if (scolor == null)
scolor = color;
if (scolor != null)
graphics.SetColorStroke(scolor);
graphics.SetLineWidth(ps[0] + fontSize * ps[1]);
float shift = ps[2] + fontSize * ps[3];
int cap2 = (int)ps[4];
if (cap2 != 0)
graphics.SetLineCap(cap2);
graphics.MoveTo(xMarker, yMarker + shift);
graphics.LineTo(xMarker + width - subtract, yMarker + shift);
graphics.Stroke();
if (scolor != null)
graphics.ResetGrayStroke();
if (cap2 != 0)
graphics.SetLineCap(0);
}
graphics.SetLineWidth(1);
if (inText && IsTagged(writer)) {
graphics.BeginText(true);
}
}
if (chunk.IsAttribute(Chunk.ACTION))
{
float subtract = lastBaseFactor;
if (nextChunk != null && nextChunk.IsAttribute(Chunk.ACTION))
subtract = 0;
if (nextChunk == null)
subtract += hangingCorrection;
PdfAnnotation annot = null;
if (chunk.IsImage()) {
annot = new PdfAnnotation(writer, xMarker, yMarker + chunk.ImageOffsetY, xMarker + width - subtract, yMarker + chunk.ImageHeight + chunk.ImageOffsetY, (PdfAction)chunk.GetAttribute(Chunk.ACTION));
}
else {
annot = new PdfAnnotation(writer, xMarker, yMarker + descender + chunk.TextRise, xMarker + width - subtract, yMarker + ascender + chunk.TextRise, (PdfAction)chunk.GetAttribute(Chunk.ACTION));
}
text.AddAnnotation(annot, true);
if (IsTagged(writer) && chunk.accessibleElement != null) {
int structParent = GetStructParentIndex(annot);
annot.Put(PdfName.STRUCTPARENT, new PdfNumber(structParent));
PdfStructureElement strucElem;
structElements.TryGetValue(chunk.accessibleElement.ID, out strucElem);
if (strucElem != null) {
PdfArray kArray = strucElem.GetAsArray(PdfName.K);
if (kArray == null) {
kArray = new PdfArray();
PdfObject k = strucElem.Get(PdfName.K);
if (k != null) {
kArray.Add(k);
}
strucElem.Put(PdfName.K, kArray);
}
PdfDictionary dict = new PdfDictionary();
dict.Put(PdfName.TYPE, PdfName.OBJR);
dict.Put(PdfName.OBJ, annot.IndirectReference);
kArray.Add(dict);
writer.StructureTreeRoot.SetAnnotationMark(structParent, strucElem.Reference);
}
}
}
if (chunk.IsAttribute(Chunk.REMOTEGOTO)) {
float subtract = lastBaseFactor;
开发者ID:NelsonSantos,项目名称:fyiReporting-Android,代码行数:67,代码来源:PdfDocument.cs
示例19: AnnotationCheckTest4
public void AnnotationCheckTest4() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest4.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2B);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.SUBTYPE, PdfName.TEXT);
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT & PdfAnnotation.FLAGS_INVISIBLE));
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
bool exceptionThrown = false;
try {
document.Close();
}
catch (PdfAConformanceException e) {
if (e.GetObject() == annot && e.Message
.Equals("The F key's Print flag bit shall be set to 1 and its Hidden, Invisible, NoView and ToggleNoView flag bits shall be set to 0.")) {
exceptionThrown = true;
}
}
if (!exceptionThrown)
Assert.Fail("PdfAConformanceException should be thrown.");
}
开发者ID:smartleos,项目名称:itextsharp,代码行数:33,代码来源:PdfA2CheckerTest.cs
示例20: AnnotationCheckTest6
public void AnnotationCheckTest6() {
Document document = new Document();
PdfAWriter writer = PdfAWriter.GetInstance(document, new FileStream(OUT + "annotationCheckTest6.pdf", FileMode.Create), PdfAConformanceLevel.PDF_A_2B);
writer.CreateXmpMetadata();
document.Open();
Font font = FontFactory.GetFont(RESOURCES + "FreeMonoBold.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED, 12);
document.Add(new Paragraph("Hello World", font));
FileStream iccProfileFileStream = File.Open(RESOURCES + "sRGB Color Space Profile.icm", FileMode.Open, FileAccess.Read, FileShare.Read);
ICC_Profile icc = ICC_Profile.GetInstance(iccProfileFileStream);
iccProfileFileStream.Close();
writer.SetOutputIntents("Custom", "", "http://www.color.org", "sRGB IEC61966-2.1", icc);
PdfAnnotation annot = new PdfAnnotation(writer, new Rectangle(100, 100, 200, 200));
annot.Put(PdfName.F, new PdfNumber(PdfAnnotation.FLAGS_PRINT));
annot.Put(PdfName.SUBTYPE, PdfName.WIDGET);
annot.Put(PdfName.CONTENTS, new PdfDictionary());
annot.Put(PdfName.FT, new PdfName("Btn"));
PdfDictionary ap = new PdfDictionary();
PdfStream s = new PdfStream(Encoding.Default.GetBytes("Hello World"));
//PdfDictionary s = new PdfDictionary();
ap.Put(PdfName.N, writer.AddToBody(s).IndirectReference);
annot.Put(PdfName.AP, ap);
PdfContentByte canvas = writer.DirectContent;
canvas.AddAnnotation(annot);
bool exceptionThrown = false;
try {
document.Close();
}
catch (PdfAConformanceException e) {
if (e.GetObject() == annot && e.Message
.Equals("Appearance dictionary of Widget subtype and Btn field type shall contain only the n key with dictionary value")) {
exceptionThrown = true;
}
}
if (!exceptionThrown)
Assert.Fail("PdfAConformanceException should be thrown.");
}
开发者ID:smartleos,项目名称:itextsharp,代码行数:40,代码来源:PdfA2CheckerTest.cs
注:本文中的iTextSharp.text.pdf.PdfAnnotation类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论