Vector Graphics Detect and Remove?

Hello,
I have a couple of basic questions about ‘aspose.PDF’ library.

  1. Using some sample code, I was able to detect vector graphics in a PDF file. I would like to know if there is the ability to remove the vector graphics from a PDF file?
  2. Does the library off the ability to insert vector graphics into a PDF file?

I basically like to find the vector graphics and replace it with another in a PDF file.

Thank you
Peter

@PKonstant

Can you please provide more details on how you are currently detecting vector graphics and what specific method you are using to replace them in the PDF file?

I ran this code and I could see it find vector graphics in a PDF.
using (var document = new
Aspose.Pdf.Document(“C:\TEMP\PDFs\Originals\sample_original_2.pdf”))
{
// Instantiate a new GraphicsAbsorber object to process graphic elements
using (var grAbsorber = new Aspose.Pdf.Vector.GraphicsAbsorber())
{
// Visit the second page of the document to extract graphic elements
grAbsorber.Visit(document.Pages[1]);

      // Retrieve the list of graphic elements from the GraphicsAbsorber
      var elements = grAbsorber.Elements;

      // Access the operators associated with the second graphic element
      var operations = elements[1].Operators;

      // Retrieve the rectangle associated with the second graphic element
      var rectangle = elements[1].Rectangle;

      // Get the position of the second graphic element
      var position = elements[1].Position;
    }
  }

Now that I found them, I would like to remove them from the PDF. (It turns out our company bought a division from another company and I am tasked with replacing all their logos and the company’s name in 100s of PDF files.) Their logo was done using vector graphics. I am looking for a way to replace their logo with ours.

My sample PDF just contains the logo. When I run the program, there are 15 elements with coordinates. I tried to match the coordinates while debugging to the coordinates using Adobe Illustrator but they didn’t match.

@PKonstant
The documentation provides two remove variants

Have you tried them?

Thanks for the information. That was helpful. I am currently trying to evaluate this library to see if it will do what I need. Referencing your sample code, it didn’t remove my vector graphics. Could the apparent reason be that I do not have a license for the ASPOSE.PDF library? I am currently evaluating it, but do not have a temporary license yet. After running my program, I looked at the PDF file and it had a text field added saying ‘Evaluation Only. Created with Aspose.PDF. Copyright 2002-2025 Aspose Pty Ltd.’ so I assume the remove should of worked but it didn’t.

Update: I obtained a temporary license and was able to remove the vector graphics by changing the size of the rectangle.
‘var rectangle = new Aspose.Pdf.Rectangle(0, 0, 595, 842);’
I was also able to insert a vector graphic file (.svg) to a new document. When I tried to use an existing document, the program hung on the save. I will play around with that a bit more and report back. Thank you

@PKonstant

It would be good if you could attach the source files and code used so we could reproduce the issue.