Invisible Text and Content Creation

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Invisible Text and Content Creation

Post by DolphinMann »

After searching the forum for others that want to "add text" in to a PDF I was able to find several useful threads on the topic. I now have text printing on the PDF content page but I had two general questions.

1.) How do I make the text "invisible"? I found one thread but it talked about modifying the "Fill Color" within the Editor GUI. I am working in a non-GUI environment. I did find "SetStrokeAlpha()", but passing 0/255 does not seem to change anything. I could make the text "White" but this would obviously only work on White background PDF's. I could also look at the background color of the region I am writing to but then it fails on any type of gradient, plus it's not truly invisible. Basically I want to do what the "OCR" option does, but I am using a different 3rd party OCR engine. I have all of the data, just want to add it to the PDF so the document becomes searchable, but I do not want to erase the image and have only a text layer. Any adivce?

2.) What would be best practice for printing a large amount of text on the image? Should I do it character by character on the same ContentCreator? Create a different ContentCreator per word/character? Keeping in mind that whatever font/brush stroke I will use will be same for the entire image. I just want to write all of the text as close as possible to the image characters so the PDF is not only searchable, but if someone highlights the text with the mouse(really highlighting the image where the text they see would be) it will pick up on the invisible text I wrote behind it.

3.) How do I determine the FontSize or TextSize if all I have are the OCR coordinates? I found the "CalcTextSize" function on the ContentCreator but I was slightly confused as it appears to TAKE a font size and output the width/height of the text I would be attempting to draw. Basically I already know the width and height and I want to determine what size font I should use, again with the goal being to draw a text character to be as close as possible to an image character(does not have to be perfect).
Example: If I run OCR it will tell me that at X,Y there is a character it thinks may be an "M", which is 20 pixels wide and 20pixels high. I need to approximate the best font size that would match that dimension set.
The only thing I could think of here would be to run a small program that prints all possible characters in all(many) possible font sizes and then stores their relative size. I could then compare my dimensions to that DB and pick the closest match, but was wondering if there is anything better than that.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Invisible Text and Content Creation

Post by Sasha - Tracker Dev Team »

Hello DolphinMann,

1) You have to set the Content Creator's Text Rendering mode to TRM_None by using the IPXC_ContentCreator::SetTextRenderMode method.
2) The optimal way would be to create one content creator, fill it and then place it.
3) For this one you will have to do the CalcTextSize method once with any font size and then use the proportion to calculate the font size based on your rectangle size. You can also vary the text's horizontal scale by using the IPXC_ContentCreator::SetTextScale.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
DolphinMann
User
Posts: 158
Joined: Mon Aug 04, 2014 7:34 pm

Re: Invisible Text and Content Creation

Post by DolphinMann »

1.) Confirmed, and fairly obvious now that I see it. Thank you :)
2.) Good to know.
3.) Thanks, I sorta did this now and it's not terribly slow, was just wondering if there was a reverse function call to get font size based on desired draw size, instead of the other way around....but even if there were it would probably be doing what I am behind the scenes anyway.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Invisible Text and Content Creation

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply