Eliminar objetos PDF en C# Selectively removing objects from a PDF document can be a complex task. However, IronPDF provides developers with an easy and intuitive way to manipulate the PDF's Document Object Model (DOM) directly. This example will demonstrate how to programmatically remove specific objects, such as images or text, from a PDF file using just a few lines of code. 4-Step Code to Remove PDF Objects PdfDocument pdf = PdfDocument.FromFile("sampleObjectsWithImages.pdf"); IPdfPageObjectModel objects = pdf.Pages.First().ObjectModel; objects.ImageObjects.RemoveAt(0); pdf.SaveAs("removed.pdf"); Code Explanation For this example, we first load a PDF file using FromFile. This method loads a PDF file of your choice and assigns it to a variable. Afterwards, we can drill down by finding the list of objects on the first page of the PDF with Pages.First. This retrieves the first page of the PDF. To access the PDF DOM object, we then access the ObjectModel collection, which holds the PDF objects of the first page. To remove an object, we target its specific collection within the ObjectModel. In this case, we are removing an image from the ImageObjects collection. We then call the standard list method RemoveAt and pass the index of the element we wish to delete. In this example, we remove the first image found in the collection by passing the index 0. Remember that collections are zero-indexed, so the first element is always at index zero. Finally, we save the modified PDF, now missing the removed element, to a new file by calling SaveAs. Discover How to Effortlessly Remove PDF DOM - Visit Our Guide Now! Ver en GitHub Código https://github.com/iron-software/IronPdf.Examples/tree/main/examples/remove-pdf-objects Descargar ZIP Tutorial Relacionado Guía de Cómo Hacer Relacionada Documentación de Clase Obtener Paquetes de Idiomas Descargar IronPDF DLL Reportar un problema en esta página ¿Listo para empezar? Nuget Descargas 16,133,208 | Versión: 2025.11 recién lanzado Descarga Gratis de NuGet Descargas totales: 16,133,208 Ver Licencias
Producto completamente funcional Obtén 30 días de producto completamente funcional.Instálalo y ejecútalo en minutos.
Soporte técnico 24/5 Acceso completo a nuestro equipo de soporte técnico durante tu prueba del producto
Producto completamente funcional Obtén 30 días de producto completamente funcional.Instálalo y ejecútalo en minutos.
Soporte técnico 24/5 Acceso completo a nuestro equipo de soporte técnico durante tu prueba del producto