How to create a hidden text layer behind an image


Hello

I'm trying to create a text layer behind an image to make it searchable. I already have the OCR of the page, I know the strings and the area boxes they should be in.

The problem is that the bounding box of the text changes based on a font size that must be set. As I'm not actually showing the text, just using it to highlight on the image where the word is when searched, I don't want to have to set a font size.

I'm using code like this...

Aspose.Pdf.Generator.FloatingBox textFloatingBox1 = new Aspose.Pdf.Generator.FloatingBox(wordArea.Width, wordArea.Height);
// Specify the ZIndex value for textFloatingBox1
textFloatingBox1.ZIndex = 0;
textFloatingBox1.Left = wordArea.Left ;
textFloatingBox1.Top = wordArea.Top;

sec1.Paragraphs.Add(textFloatingBox1);

Aspose.Pdf.Generator.Text t1 = new Aspose.Pdf.Generator.Text(sec1);
textFloatingBox1.Paragraphs.Add(t1);

Aspose.Pdf.Generator.Segment seg1 = new Aspose.Pdf.Generator.Segment(t1);
seg1.Content = wordvalue;
seg1.TextInfo.FontSize = 12; // is font size the problem???
t1.Opacity = 0F;
t1.Segments.Add(seg1);

What I've found is that setting the font size higher or lower actually changes the size of the text fragement, which is not desirable as I already know the exact area of that word.

Can anybody help? Is there another api for this that I'm missing?

Hi Rich,

Thanks for using our products.

I have tested the scenario and unable to notice any problem. You can check the following documentation link for details and code snippet as per your requirement.

How to - Create MultiLayer PDF document

Please do let us know if you need any further assistance.

Thanks & Regards,

The problem is that the text box sizing seems to be incorrect. I set text on the page with code above … Just to prove the problem I can set a width, height, X, and Y all to be 300. Notice in the attached image the actual SIZE of the created text box in comparison to it’s X and Y. The size is getting overriden by something else (font size changing the bounding box?).


Is there a better way to accomplish this or is this a bug in aspose kit?

Also… changing the font size changes the bounding size of teh text area. Even though I have set FixedWidth and FixedHeight. Is there a better way to do hidden text layer to make the pdf searchable? I need to be able to create the in the location on the image so the word is highlighted (I have the coordinates for ocr location).


Nobody at aspose is able to resolve this issue? I need to escalate this quickly (our company has purchased priority support)

Hi Rich,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for the delay in reply.

As I understand your problem, you are facing the issue when you change the Font Size, the text area size also increases. I tested this issue and I am able to notice this problem. Please confirm whether my understanding about your issue is correct or you are facing some other issue. It would be better if you can share your complete code and generated PDF file with us. This will help us identify and rectify the issue soon.

Also, regarding priority support, I think you can use the Priority Support account which has been purchase by your company and register your issue directly in the Priority Support forum as well. Following is the link for Priority Support forum.

http://www.aspose.com/community/forums/aspose.priority.support/480/showforum.aspx

Sorry for the inconvenience,