Deletes an object previously added to the document.




void Delete(int id)

[Visual Basic]
Sub Delete(id As Integer)



Name Description

The Object ID of the object to be deleted.




Use this method to delete an object previously added to the document.

Deletion may be applied to pages to remove them from the document. For example to delete the current page you might use the following code:

theDoc.Delete theDoc.Page

However if you are deleting multiple pages you will probably find it more efficient to use the RemapPages method. as this is more optimized for moving and removing pages.




The following code snippet illustrates how one might add an image and then delete it if the image color space is CMYK.


using (Doc doc = new Doc()) {
  string thePath = Server.MapPath("../mypics/mypic.jpg");
  int theID1 = doc.AddImageFile(thePath, 1);
  int theID2 = doc.GetInfoInt(theID1, "XObject");
  int theComps = doc.GetInfoInt(theID2, "Components");
  if (theComps == 4) doc.Delete(theID1);

[Visual Basic]
Using doc As New Doc()
  Dim thePath As String = Server.MapPath("../mypics/mypic.jpg")
  Dim theID1 As Integer = doc.AddImageFile(thePath, 1)
  Dim theID2 As Integer = doc.GetInfoInt(theID1, "XObject")
  Dim theComps As Integer = doc.GetInfoInt(theID2, "Components")
  If theComps = 4 Then
  End If
End Using