Extracting inline image is supported by Aspose.PDF?

Hi Team!

Does Aspose.PDF support processing inline image that is defined directly within the content stream? How can I extract these images from a pdf file?

@erdeiga

Are you talking about inline images in HTML? Are you converting HTML to PDF? Please share some more details and sample files with us so that we can provide you feedback accordingly.

@asad.ali

Not exactly or I don’t know if there is any connection between them.

Pleas check the following reference from the Document management — Portable document format — Part 1: PDF 1.7

Document: https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
8.9.7 Inline Images Page 214

I am talking about Inline Images:

As an alternative to the image XObjects described in 8.9.5, “Image Dictionaries”, a sampled image may be specified in the form of an inline image. This type of image shall be defined directly within the content stream in which it will be painted rather than as a separate object. Because the inline format gives the reader less flexibility in managing the image data, it shall be used only for small images (4 KB or less).

So I’m interested if I have a pdf document that contains this kind of images then how can I extract, edit or replace those with Aspose.PDF?

Here is a simple example pdf that contains an inline image: test_inline.pdf (584 Bytes)

@erdeiga

Aspose.PDF offers ImagePlacementAbsorber Class that supports inline images. We tested the below code snippet to extract images from your file and noticed that API was able to find the images but it threw an exception while saving the extracted images:

Document pdfDocument = new Document(dataDir + "test_inline.pdf");
ImagePlacementAbsorber abs = new ImagePlacementAbsorber();
pdfDocument.Pages[1].Accept(abs);
foreach (ImagePlacement image in abs.ImagePlacements)
{ 
 image.Save(new FileStream(dataDir + "ID+PassPort.jpg", FileMode.Create), ImageFormat.Jpeg);
}

Therefore, we have logged an issue as PDFNET-50267 in our issue tracking system for further investigation. We will look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

Thank you for your help.

How could I insert an image as an inline image into a pdf using Aspose.PDF?

@erdeiga

We are afraid that this functionality has not been added to the API yet. A feature request as PDFNET-50292 has been logged in our issue tracking system for the sake of implementation. We will further look into details of the ticket and let you know as soon as the requested feature is available. Please be patient and spare us some time.

We are sorry for the inconvenience.

1 Like

Does this feature request contains the following requirements?

  1. Insert inline image
  2. Replace inline image
  3. Remove inline image
  4. Remove areas in Inline images covered by the redact annotation

It would be great if Aspose.PDF would support these features.

@asad.ali
Is there any way to determine if the found ImagePlacement object is an Inline Image?

@erdeiga

We have updated the ticket information and now it includes all of your requirements.

An enhancement request as PDFNET-50305 has been logged in our issue tracking system to introduce a flag/property in ImagePlacementAbsorber with which it can be determined if extracted image is an inline image. We will look into its details and let you know as soon as the ticket is resolved. Please give us some time.

We are sorry for the inconvenience.

1 Like