How to Extract Vector Graphics from PDF in .NET

I also need to extract vector graphics by layers from pdf file in .NET app too. Is it still impossible by using Aspose PDF in 2023? Or Is there any other product that can do the extraction?

I am afraid the Aspose.PDF Cloud API does not support extracting vector graphics from a PDF document at the moment. However, recently we have supported the feature in our on premise API, Aspose.PDF for .NET. I am moving your post to the related forum for more details.

@pdfmaster

In 23.8 version, we added a new functionality for interacting with graphic elements. Elements can be absorbed by GraphicAbsorber class :

var source = new Document(input1);
var ga = new GraphicsAbsorber();
ga.Visit(source.Pages[1]);

You can position of each element (SuppressUpdate and ResumeUpdate are needed to avoid contents stream updates after each position change):

va.SuppressUpdate();
foreach (var el in va.Elements)
{
    var position = el.Position;
    el.Position = new Point(position.X - 150, position.Y - 100);
}
va.ResumeUpdate();

You can delete delete elements from the page’s content one by one:

va.SuppressUpdate();
var rectangle = new Rectangle(500, 0, 600, 200);
foreach (var el in va.Elements)
{
    if (!rectangle.Contains(element.Position))
    {
        el.Remove();
    }
}
va.ResumeUpdate();

or collect items into GraphicElementCollection and delete them at once (better performance):

var rectangle = new Rectangle(500, 0, 600, 200);
var elems = new GraphicElementCollection();
foreach (var element in ga.Elements)
{
    if (!rectangle.Contains(element.Position))
    {
         elems.Add(element);
    }
}
source.Pages[1].DeleteGraphics(elems);

And also you can add graphic elements to another page:

destinationDoc.Pages[1].Contents.SuppressUpdate();
foreach (var el in elems)
{
    el.AddOnPage(destinationDoc.Pages[1]);
}
destinationDoc.Pages[1].Contents.ResumeUpdate();

or by using:

destinationDoc.Pages[1].AddGraphics(ga.Elements);