INSERT IMAGE IN ASPOSE WORD AS EDITABLE IMAGE

Hello Team,

I want to insert an image into a Word document and set the “Edit Picture” option to true, allowing the user to search the content inside the image. How can I achieve this programmatically so that the image is inserted with the “Edit Picture” feature enabled?

Thank you!

@RaghulBabu214

To insert an image into a Word document with the “Edit Picture” option enabled, you can use Aspose.Words to achieve this. The key is to insert the image as a shape and set its properties accordingly. Here’s a simple example in C#:

using Aspose.Words;
using Aspose.Words.Drawing;

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Load your image
string imagePath = "path/to/your/image.png";
Shape shape = builder.InsertImage(imagePath);

// Set the shape's properties to enable editing
shape.WrapType = WrapType.Inline; // or WrapType.None based on your layout preference
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Page;

// Save the document
doc.Save("output.docx");

In this example, the image is inserted inline, which allows for editing. Make sure to adjust the WrapType and positioning properties based on your layout needs.

Next Steps: If you need further customization or have specific layout requirements, please provide additional details so I can assist you better.

If you have any questions or need further assistance, feel free to ask!

@RaghulBabu214,

It seems you’ve already posted a similar query in the forum. Nevertheless, I will move your thread to the appropriate category, where a member of our Aspose.Words team will review it and provide assistance soon.

1 Like

@RaghulBabu214 To be editable, the image must be EMF metafile. You can insert EMF image into the document the same way as any other image:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertImage(@"C:\Temp\test.emf");
doc.Save(@"C:\Temp\out.docx");

with emf file also I didn’t get that enabled for the below document
output_Filename_1.docx (116.0 KB)

an you help me with aspose ocr on top of
private static void

InsertHtmlTable(DocumentBuilder builder, Workbook workbook, Worksheet worksheet, Range range, ReplacingArgs e, string r = “D8:G16”)
{
worksheet.PageSetup.BlackAndWhite = false;


worksheet.PageSetup.PrintArea = "B2:S411";

worksheet.PageSetup.LeftMargin = 0;
worksheet.PageSetup.RightMargin = 0;
worksheet.PageSetup.TopMargin = 0;
worksheet.PageSetup.BottomMargin = 0;

ImageOrPrintOptions options = new ImageOrPrintOptions();
options.OnePagePerSheet = true;
options.ImageType = (Aspose.Cells.Drawing.ImageType)ImageType.Jpeg;
options.HorizontalResolution = 200;
options.VerticalResolution = 200;

SheetRender sr = new SheetRender(worksheet, options);
// Save the image to a temp file with .jpg extension
string tempImagePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".jpg");
sr.ToImage(0, tempImagePath);


Shape shape = builder.InsertImage(tempImagePath);
shape.WrapType = WrapType.Square;
shape.AllowOverlap = true;
shape.RelativeHorizontalPosition = RelativeHorizontalPosition.Margin;
shape.RelativeVerticalPosition = RelativeVerticalPosition.Margin;
shape.HorizontalAlignment = HorizontalAlignment.Left;
shape.VerticalAlignment = VerticalAlignment.Top;


}

so that I can search in word … Basically what I need is when inserting an image in word I wanted it to be searchable…Is there a way to achieve this using apose ocr or any other if so kindly help me with code

With emf file also I am not able to search give me a simple solution for this

With wmf I am able to get that option in word document for the inserted image can i set that in code itself and why emf I am not geting edit picture…? can I enable that Edit Picture in code itself so that its serchabel

@RaghulBabu214 Aspose.Words does not support OCR operations. As I can see “Edit Picture” option is enabled in the attached Document:

Its enabled can I set that true from code…? Or using macros in aspose can I achieve that search can u help me with image search in aspose word

@RaghulBabu214

This option is visible in MS Word when the image is EMF metafile. There is no way to control this option from the code.

Unfortunately, Aspose.Words does not provide a feature to search text in images nor MS Word does.

1 Like

can you make this image private

@RaghulBabu214 On you as the topic owner and Aspose staff can see the attachments and images in the forum.

1 Like