←Select platform

ParentObjectNumber Property

Summary

The optional unique number (ID) of the parent of this annotation object.

Syntax
C#
C++/CLI
Java
Python
public string ParentObjectNumber {get; set;} 
public String getParentObjectNumber(); 
public void setParentObjectNumber( 
   java.lang.String string 
); 
public:  
   property String^ ParentObjectNumber 
   { 
      String^ get() 
      void set(String^ value) 
   } 
ParentObjectNumber # get and set (PDFAnnotation) 

Property Value

Optional unique number (ID) of the parent of this annotation object. The default value is null.

Remarks

Refer to ObjectNumber for more information and an example.

Example
C#
Java
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Controls; 
using Leadtools.Drawing; 
using Leadtools.ImageProcessing; 
using Leadtools.Pdf; 
using Leadtools.Svg; 
 
 
public void AnnotationsReplyParentChildTest() 
{ 
   string sourceFile = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf"); 
   string targetFile = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools_with_rectangle_reply.pdf"); 
 
   // Copy the source to target 
   if (File.Exists(targetFile)) 
   { 
      File.SetAttributes(targetFile, File.GetAttributes(targetFile) & ~FileAttributes.ReadOnly); 
      File.Delete(targetFile); 
   } 
 
   File.Copy(sourceFile, targetFile, true); 
   File.SetAttributes(targetFile, File.GetAttributes(targetFile) & ~FileAttributes.ReadOnly); 
 
   var annotations = new List<PDFAnnotation>(); 
 
   // Add a rectangle and a reply to it 
   const string myRectangle = "myRectangle"; 
   const string myReply = "myReply"; 
 
   // Create dashed red pen with width of 2 
   var pen = new PDFPen(); 
   pen.Color = RasterColor.FromKnownColor(RasterKnownColor.Red); 
   pen.PenStyle = PDFPen.Dashed; 
   pen.Width = 2; 
 
   // Create red solid brush 
   var brush = new PDFBrush(); 
   brush.BrushStyle = PDFBrush.Solid; 
   brush.Color = RasterColor.FromKnownColor(RasterKnownColor.Red); 
 
   var rectObj = new PDFRectangleAnnotation(); 
   rectObj.PageNumber = 1; 
   rectObj.Pen = pen; 
   rectObj.Brush = brush; 
   var rect = new PDFRect(72, 72, 144, 108); 
   rectObj.Bounds = rect; 
   rectObj.Transparency = 1; 
   // Set the object number to a unique value, here we call it parent1. Note that this is 
   // will be used when storing the objects inside the PDF and the object id (or number) 
   // will be replaced by a unique value during the save process. 
   rectObj.ObjectNumber = myRectangle; 
   annotations.Add(rectObj); 
 
   // Add an opened note that is a child of the rectangle 
   var noteObj1 = new PDFNoteAnnotation(); 
   noteObj1.PageNumber = 1; 
   noteObj1.Content = "Reply to rect"; 
   noteObj1.Point = new PDFPoint(72, 72); 
   noteObj1.Color = RasterColor.FromKnownColor(RasterKnownColor.Yellow); 
   noteObj1.Open = false; 
   // We must give it a unique name, again will be replaced by the framework. 
   noteObj1.ObjectNumber = myReply; 
   // And set the object we are replying to, in this case, the rectangle 
   noteObj1.ParentObjectNumber = rectObj.ObjectNumber; 
   annotations.Add(noteObj1); 
 
   // Add an ellipse, with no note 
   var ellipseObj = new PDFEllipseAnnotation(); 
   ellipseObj.PageNumber = 1; 
   ellipseObj.Pen = pen; 
   ellipseObj.Brush = brush; 
   rect = new PDFRect(216, 72, 288, 108); 
   ellipseObj.Center = new PDFPoint(rect.Left + rect.Right / 2, rect.Top + rect.Bottom / 2); 
   ellipseObj.HorizontalRadius = rect.Right - rect.Left; 
   ellipseObj.VerticalRadius = rect.Bottom - rect.Top; 
   ellipseObj.Transparency = 1; 
   // Note that since we will not add a reply to this annotation object, we do not 
   // have to set the value of ObjectNumber to anything and leave it as the default 
   // of null. The framework will replace it with a unique value during the save 
   // process. 
   //ellipseObj.ObjectNumber = null; 
   annotations.Add(ellipseObj); 
 
   // Add an opened note that is a not a child of any objects. 
   var noteObj2 = new PDFNoteAnnotation(); 
   noteObj2.PageNumber = 1; 
   noteObj2.Content = "No parent"; 
   noteObj2.Point = new PDFPoint(216, 72); 
   noteObj2.Color = RasterColor.FromKnownColor(RasterKnownColor.Yellow); 
   noteObj2.Open = true; 
   // Again, since we do not need to associate this object with any other there is no 
   // need to set its nor its parent ID 
   //noteObj2.ObjectNumber = null; 
   //noteObj2.ParentObjectNumber = null; 
   annotations.Add(noteObj2); 
 
   // Save the PDF file 
 
   var pdfFile = new PDFFile(targetFile); 
   pdfFile.WriteAnnotations(annotations, null); 
 
   Console.WriteLine("PDF file with annotations created in\n{0}", targetFile); 
 
   // Open the created PDF in Adobe Acrobat and it should contain the following: 
   // - Dashed red rectangle object. 
   // - Closed reply to the rectangle with "Reply to rect" content. This should show as a note in the rectangle object. 
   // - Dashed red ellipse object. 
   // - Open yellow stand-alone note object with "No parent" content. 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.ByteArrayInputStream; 
import java.io.File; 
import java.io.FileInputStream; 
import java.io.FileNotFoundException; 
import java.io.FileOutputStream; 
import java.io.FileReader; 
import java.io.IOException; 
import java.io.InputStream; 
import java.nio.file.Files; 
import java.nio.file.Paths; 
import java.nio.file.StandardCopyOption; 
import java.util.ArrayList; 
import java.util.Date; 
import java.util.List; 
import java.util.Scanner; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.pdf.*; 
 
 
public void pdfFileAnnotationsReplyParentChildExample() throws IOException { 
 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String sourceFile = combine(LEAD_VARS_IMAGES_DIR, "Leadtools.pdf"); 
   String targetFile = combine(LEAD_VARS_IMAGES_DIR, "Leadtools_with_rectangle_reply.pdf"); 
 
   // Copy the source to target 
   File file = new File(targetFile); 
   if (file.exists()) { 
      file.delete(); 
   } 
 
   Files.copy(Paths.get(sourceFile), Paths.get(targetFile), StandardCopyOption.REPLACE_EXISTING); 
 
   ArrayList<PDFAnnotation> annotations = new ArrayList<PDFAnnotation>(); 
 
   // Add a rectangle and a reply to it 
   final String MY_RECTANGLE = "myRectangle"; 
   final String MY_REPLY = "myReply"; 
 
   // Create dashed red pen with width of 2 
   PDFPen pen = new PDFPen(); 
   pen.setColor(RasterColor.fromKnownColor(RasterKnownColor.RED)); 
   pen.setPenStyle(PDFPen.DASHED); 
   pen.setWidth(2); 
 
   // Create red solid brush 
   PDFBrush brush = new PDFBrush(); 
   brush.setBrushStyle(PDFBrush.SOLID); 
   brush.setColor(RasterColor.fromKnownColor(RasterKnownColor.RED)); 
 
   PDFRectangleAnnotation rectObj = new PDFRectangleAnnotation(); 
   rectObj.setPageNumber(1); 
   rectObj.setPen(pen); 
   rectObj.setBrush(brush); 
   PDFRect rect = new PDFRect(72, 72, 144, 108); 
   rectObj.setBounds(rect); 
   rectObj.setTransparency(1); 
 
   // Set the object number to a unique value, here we call it parent1. Note that 
   // this is 
   // will be used when storing the objects inside the PDF and the object id (or 
   // number) 
   // will be replaced by a unique value during the save process. 
   rectObj.setObjectNumber(MY_RECTANGLE); 
   annotations.add(rectObj); 
 
   // Add an opened note that is a child of the rectangle 
   PDFNoteAnnotation noteObj1 = new PDFNoteAnnotation(); 
   noteObj1.setPageNumber(1); 
   noteObj1.setContent("Reply to rect"); 
   noteObj1.setPoint(new PDFPoint(72, 72)); 
   noteObj1.setColor(RasterColor.fromKnownColor(RasterKnownColor.YELLOW)); 
   noteObj1.setOpen(false); 
 
   // We must give it a unique name, again will be replaced by the framework. 
   noteObj1.setObjectNumber(MY_REPLY); 
 
   // And set the object we are replying to, in this case, the rectangle 
   noteObj1.setParentObjectNumber(rectObj.getObjectNumber()); 
   annotations.add(noteObj1); 
 
   // Add an ellipse, with no note 
   PDFEllipseAnnotation ellipseObj = new PDFEllipseAnnotation(); 
   ellipseObj.setPageNumber(1); 
   ellipseObj.setPen(pen); 
   ellipseObj.setBrush(brush); 
   rect = new PDFRect(216, 72, 288, 108); 
   ellipseObj.setCenter(new PDFPoint(rect.getLeft() + rect.getRight() / 2, rect.getTop() + rect.getBottom() / 2)); 
   ellipseObj.setHorizontalRadius(rect.getRight() - rect.getLeft()); 
   ellipseObj.setVerticalRadius(rect.getBottom() - rect.getTop()); 
   ellipseObj.setTransparency(1); 
 
   // Note that since we will not add a reply to this annotation object, we do not 
   // have to set the value of ObjectNumber to anything and leave it as the default 
   // of null. The framework will replace it with a unique value during the save 
   // process. 
   // ellipseObj.ObjectNumber = null; 
   annotations.add(ellipseObj); 
 
   // Add an opened note that is a not a child of any objects. 
   PDFNoteAnnotation noteObj2 = new PDFNoteAnnotation(); 
   noteObj2.setPageNumber(1); 
   noteObj2.setContent("No parent"); 
   noteObj2.setPoint(new PDFPoint(216, 72)); 
   noteObj2.setColor(RasterColor.fromKnownColor(RasterKnownColor.YELLOW)); 
   noteObj2.setOpen(true); 
 
   // Again, since we do not need to associate this object with any other there is 
   // no need to set its nor its parent ID 
   // noteObj2.ObjectNumber = null; 
   // noteObj2.ParentObjectNumber = null; 
   annotations.add(noteObj2); 
 
   // Save the PDF file 
   PDFFile pdfFile = new PDFFile(targetFile); 
   pdfFile.writeAnnotations(annotations, null); 
 
   System.out.printf("PDF file with annotations created in%n%s", targetFile); 
 
   assertTrue("Check if target file exists", new File(targetFile).exists()); 
   // Open the created PDF in Adobe Acrobat and it should contain the following: 
   // - Dashed red rectangle object. 
   // - Closed reply to the rectangle with "Reply to rect" content. This should 
   // show as a note in the rectangle object. 
   // - Dashed red ellipse object. 
   // - Open yellow stand-alone note object with "No parent" content. 
 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.