public virtual void CreateChildInstanceTest() { PdfTarget target = PdfTarget.CreateChildTarget(); PdfDictionary dictionary = target.GetPdfObject(); NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R)); }
/// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary> /// <param name="fileSpec">The root document of the target relative to the root document of the source</param> /// <param name="destination">the destination in the target to jump to</param> /// <param name="newWindow"> /// if true, the destination document should be opened in a new window; /// if false, the destination document should replace the current document in the same window /// </param> /// <param name="targetDictionary"> /// A target dictionary specifying path information to the target document. /// Each target dictionary specifies one element in the full path to the target and /// may have nested target dictionaries specifying additional elements /// </param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination , bool newWindow, PdfTarget targetDictionary) { iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName. GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow)); if (fileSpec != null) { action.Put(PdfName.F, fileSpec.GetPdfObject()); } if (destination != null) { ValidateRemoteDestination(destination); action.Put(PdfName.D, destination.GetPdfObject()); } else { LogManager.GetLogger(typeof(iText.Kernel.Pdf.Action.PdfAction)).Warn(iText.IO.LogMessageConstant.EMBEDDED_GO_TO_DESTINATION_NOT_SPECIFIED ); } if (targetDictionary != null) { action.Put(PdfName.T, targetDictionary.GetPdfObject()); } return(action); }
public virtual void CreateInstanceTest() { PdfDictionary dictionary = new PdfDictionary(); PdfTarget target = PdfTarget.Create(dictionary); NUnit.Framework.Assert.AreEqual(dictionary, target.GetPdfObject()); }
public virtual void CreateChildInstanceWithEmbeddedFileTest() { String embeddedFileName = "EmbeddedFileName.file"; PdfTarget target = PdfTarget.CreateChildTarget(embeddedFileName); PdfDictionary dictionary = target.GetPdfObject(); NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R)); NUnit.Framework.Assert.AreEqual(new PdfString(embeddedFileName), dictionary.Get(PdfName.N)); }
public virtual void NamePropertyTest() { String name = "Name"; PdfTarget target = PdfTarget.Create(new PdfDictionary()); target.SetName(name); NUnit.Framework.Assert.AreEqual(name, target.GetName()); NUnit.Framework.Assert.AreEqual(new PdfString(name), target.GetPdfObject().Get(PdfName.N)); }
public virtual void CreateChildInstanceWithNamedDestinationTest() { String namedDestination = "namedDestination"; String annotationIdentifier = "annotationIdentifier"; PdfTarget target = PdfTarget.CreateChildTarget(namedDestination, annotationIdentifier); PdfDictionary dictionary = target.GetPdfObject(); NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R)); NUnit.Framework.Assert.AreEqual(new PdfString(namedDestination), dictionary.Get(PdfName.P)); NUnit.Framework.Assert.AreEqual(new PdfString(annotationIdentifier), dictionary.Get(PdfName.A)); }
public virtual void CreateChildInstanceWithPageNumberTest() { int pageNumber = 23; int annotationIndex = 7; PdfTarget target = PdfTarget.CreateChildTarget(pageNumber, annotationIndex); PdfDictionary dictionary = target.GetPdfObject(); NUnit.Framework.Assert.AreEqual(PdfName.C, dictionary.Get(PdfName.R)); NUnit.Framework.Assert.AreEqual(new PdfNumber(pageNumber - 1), dictionary.Get(PdfName.P)); NUnit.Framework.Assert.AreEqual(new PdfNumber(annotationIndex), dictionary.Get(PdfName.A)); }
public virtual void TargetPropertyTest() { PdfDictionary oldDictionary = new PdfDictionary(); oldDictionary.Put(new PdfName("Id"), new PdfString("Old")); PdfDictionary newDictionary = new PdfDictionary(); newDictionary.Put(new PdfName("Id"), new PdfString("New")); PdfTarget target = PdfTarget.Create(oldDictionary); target.SetTarget(PdfTarget.Create(newDictionary)); NUnit.Framework.Assert.AreEqual(newDictionary, target.GetTarget().GetPdfObject()); NUnit.Framework.Assert.AreEqual(newDictionary, target.GetPdfObject().Get(PdfName.T)); }
public virtual void SetAnnotationTest() { using (PdfDocument document = new PdfDocument(new PdfWriter(new MemoryStream()))) { PdfFileAttachmentAnnotation annotation0 = new PdfFileAttachmentAnnotation(new Rectangle(0, 0, 20, 20)); PdfFileAttachmentAnnotation annotation1 = new PdfFileAttachmentAnnotation(new Rectangle(1, 1, 21, 21)); PdfFileAttachmentAnnotation annotation2 = new PdfFileAttachmentAnnotation(new Rectangle(2, 2, 22, 22)); document.AddNewPage(); document.GetPage(1).AddAnnotation(annotation0); document.GetPage(1).AddAnnotation(annotation1); document.GetPage(1).AddAnnotation(annotation2); PdfTarget target = PdfTarget.Create(new PdfDictionary()); target.SetAnnotation(annotation2, document); PdfDictionary dictionary = target.GetPdfObject(); NUnit.Framework.Assert.AreEqual(0, dictionary.GetAsNumber(PdfName.P).IntValue()); NUnit.Framework.Assert.AreEqual(2, dictionary.GetAsNumber(PdfName.A).IntValue()); } }
/// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary> /// <param name="fileSpec">The root document of the target relative to the root document of the source</param> /// <param name="destination">the destination in the target to jump to</param> /// <param name="newWindow"> /// if true, the destination document should be opened in a new window; /// if false, the destination document should replace the current document in the same window /// </param> /// <param name="targetDictionary"> /// A target dictionary specifying path information to the target document. /// Each target dictionary specifies one element in the full path to the target and /// may have nested target dictionaries specifying additional elements /// </param> /// <returns>created action</returns> public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination , bool newWindow, PdfTarget targetDictionary) { iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName. GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow)); if (fileSpec != null) { action.Put(PdfName.F, fileSpec.GetPdfObject()); } if (destination != null) { action.Put(PdfName.D, destination.GetPdfObject()); } if (targetDictionary != null) { action.Put(PdfName.T, targetDictionary.GetPdfObject()); } return(action); }