We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

.Net PDF - Swap All Shape Colors

Hello,


How can I go about iterating through all shape objects so I can replace the color? This may also include Floating Text Boxes, etc.

I’m going to be hunting for 3-4 specific colors which may be used as backgrounds or borders and replace them with their respective color counterpart which is dynamic based on situation.

I’ve successfully used TextFragmentAbsorber to find text and change its color but not sure how to tackle modifying shape colors for existing PDFs (not built with Aspose).

Thanks



Hi Philip,


Thanks for contacting support.

Currently Aspose.Pdf API supports the feature to extract text, attachment, Annotations, Text but currently it does not support extraction of Graph objects. However I have logged a new feature request PDFNET-42484 in our issue tracking system. We will further look into the details of this enhancement and will notify you as soon as we implement it. Please be patient and spare us little time.

We are sorry for the inconvenience.

Best Regards,

Thank you, I will look forward to hearing about this new feature.

In the mean while - how can I get the location (Left, Top, Height, Width) & tag value of each image in the PDF?

Thanks

Hi Philip,


You can use following code snippet to get the width, height, LLX (Xcoordinate of lower left corner), LLY, URX, URY of each image.

JAVA

// Load the source PDF document
com.aspose.pdf.Document doc = new com.aspose.pdf.Document(“c:\input.pdf”);
com.aspose.pdf.ImagePlacementAbsorber abs = new com.aspose.pdf.ImagePlacementAbsorber();
// Load the contents of first page
doc.getPages().get_Item(1).accept(abs);

for(int counter=1; counter <= abs.getImagePlacements().size(); counter++)
{
com.aspose.pdf.ImagePlacement imagePlacement = abs.getImagePlacements().get_Item(counter);
System.out.println(“Image # = " +counter );
// Get image properties
System.out.println(“image width:” + imagePlacement.getRectangle().getWidth());
System.out.println(“image height:” + imagePlacement.getRectangle().getHeight());
System.out.println(“image LLX:” + imagePlacement.getRectangle().getLLX());
System.out.println(“image LLY:” + imagePlacement.getRectangle().getLLY());
System.out.println(“image URX:” + imagePlacement.getRectangle().getURX());
System.out.println(“image URY:” + imagePlacement.getRectangle().getURY());
System.out.println(“image horizontal resolution:” + imagePlacement.getResolution().getX());
System.out.println(“image vertical resolution:” + imagePlacement.getResolution().getY());
System.out.println(”==================================================");
}

If you need further assistance, please feel free to contact us.

Best Regards,