PDF Highlighting above image / below text - objective-c

i'm trying to highlight text in a pdf, and have the highlighted rectangle to be drawn under the text.
It works fine on most PDF's, but I jumped into a problem when the text I'm trying to highlight has an image/background under it. The problem is that the highlight rectangle is drawn under the image as well, so it is not visible.
The drawing order I have is this:
draw a blank rectangle with the page size
draw the highlight
draw the pdf using CGContextDrawPDFPage(context, page);
Is there a way to draw the PDF images and text separately? so that I could go
blank rectangle
pdf images/background
highlight
pdf text
Do I have to do something to the pdf / context so that it draws it automatically the way I want it to? I've tried messing with the context but nothing worked so far, it's all drawn entirely under or entirely above the full pdf
Every reader I've seen does this (PDFExpert, GoodReader, iAnnotate to name a few), so it can't be impossible, I just haven't found the solution yet :)
Any help will help, thanks in advance!!
Cheers

My understanding is that these other apps are reading and rendering the PDF themselves (they support selecting text, or adding annotations, for example), so they would be able to much more easily layer things in the way you're mentioning.
The CGPDFDocument you're starting with is an opaque object (in the OO sense, not transparency) that can draw itself, but I don't know of any way to break out and render various sublayers of the document.
As a way forward, you could look at using Core Image (iOS5+) or some other method to blend the highlights layer with the PDF. If you used the right filter (Multiply, maybe), the darker text would still come through and a .3 alpha highlight would blend with any background.

Related

How do you change text color of all the text of a particular color to another in pdf?

My Professor uses a very hard to see white font colour for about half of his lecture notes.
it is very hard to see on the slides, even worse printed out.
Is there a dynamic way to convert all white text in the entire document to black? hopefully there is a solution with Adobe Acrobat Pro DC which is what i am using, but im open to other suggestions.
In the Accessibility preferences, you can change the way text and line art is displayed. This isn't a permanent change but just changes how the PDF is drawn to the screen.

Merge a picture color in other picture using Adobe Illustrator

I want to merge the color of one picture in other picture. As the picture below is showing. I paste a picture on circle. But there is a clear distinction between the two pictures. I want to get rid of it. Is it possible?
You have a couple options:
1: You could make a Clipping Mask, use the pen tool and trace the object, once you have drawn a line around what you what removed from the background select your outline and your image. goto top menu item Object > Clipping Mask > Make. This will clip your image and hide the background.
2: The image your are using my be tough for step one. Try re-exporting the image as a PNG or GIF with a transparent background then open it in illustrator. You will need to either "open" from within ai or "open with" ai. Copy/paste will not keep the transparency depending on the tools you are using.
My guess is step two will be your easiest solution because of the shadow elements. Good luck!
-Added Edit-
3: Open the original image file and change the background hex value to match the final desired background. This solution is less valuable because you won't have the ability to edit or change your mind about the color while your working.

How to layout the UIlabel object according to design spec in iOS

I have some difficult time in creating iOS screen to match with visual design provided by design team.
The design team has provided the spacing info for each screen which shows how much space each text needs to be apart from other UI element on the screen. This is attached for your reference. You can see here that the two text labels "Activate Your Account" and "A Verification link...." are placed apart by 25px.
The same thing I am trying to achieve in the storyboard. I am attaching the storyboard screen snapshot for reference.
From this you can see that I cannot keep exactly 25px b/w the two text labels because for the following issue
The text font is custom font and I cannot load the same in storyboard. I have added the font file in the project, but when I try to open it in storyboard for UILabel, it doesn't list out. I am not sure why xcode doesn't show up. This makes me hard to resize the label's frame. If I try to decrease the empty space in the label (upper and lower part of the text), this will make label height less, but when I set the font programmatically, it doesn't fit in this small space.
When I try to increase the height of the label, the text inside the label starts displaying at the center leaving space at the top and bottom of the label frame.
So I want to know how to solve this problem. If anyone had this issues and sorted out, please let me know how to fix this.
Many Thanks
Your designers aren't speccing their designs correctly :) Show them how iOS renders text and have them spec their designs in the same way. This is what we do on the Facebook design team. I mocked up an example for you (each square is 4dp/8px).
http://i.stack.imgur.com/q4tZX.png

Getting the bounding box of each glyph in pdf - iOS

I've been trying to highlight text in a pdf. After a lot of research and experiments, it seems like I have to find the bounding box of each glyphs, create an overlay where the actual drawing is happening, and highlight the text by filling the CGRect with the info from bounding box and fill it with color. Now, I am stumped with the bounding box.
I've been using the PDFKitten to search and highlight the text. Now I want to use it to select and highlight the text. What I don't understand is how does it use the bounding box ( as well as other information like ascent, descent, capHeight, etc.) to fill highlight the searched word. When I tried to access the FontDescriptor class to get the info, it displays this:
2012-06-28 16:32:20.626 er[2408:15203] x:-665, y:-325, width:2000, height:1006
2012-06-28 16:32:20.627 er[2408:15203] x:-157, y:-250, width:1126, height:952
2012-06-28 16:32:20.628 er[2408:15203] x:-628, y:-376, width:2000, height:1010
It is very confusing so if anyone can clarify this, it will be very much appreciated.
You cannot use font descriptor information to get bounding box for the glyph.
PDFKitten takes care of finding width and height of the each glyph using RenderingState model.
You can use the same to find the location of the word while scanning the PDF.
Font dictionary provides the widths for the glyph. You can use cid to get the correct width of the glyph.
Try to look into highlighting code of the PDFKitten.

Tips on implementing a custom UITextView interface on the iPhone?

I am trying to implement a control to edit text that will display the text in multiple colors. None of the solutions I have attempted yet have been good enough.
UITextView cannot accomplish this. All of the text must be the same color.
Using CoreGraphics to draw the text does not allow the text to be selected.
Using a UIWebView, DIV and PRE tags cannot be set to contentEditable on Mobile Safari.
Currently playing with using an off-screen TEXTAREA and an on-screen DIV to show the rendered text. This works pretty well, except supporting all of these at the same time seems impossible: click-to-type, click-to-move-cursor, click-and-hold-select/copy/paste.
Anyone have any tips on this predicament?
I've been trying to find any preexisting library out there that will accomplish this in a good way, to no luck. I'm open to any ideas!
Well, just pulling an idea out of my... let's say hat.
Could you put a transparent UITextfield over a view that draws the text? If the background was clear and the text color was clear the user could not perceive it but it should still respond to all commands. As the user enters and edits text you could draw the results on the view underneath.
I think the selection would work without any modification at all. When the user selected the clear text, it should create the illusion of selecting the drawn text automatically.
Like this one? StyledText http://three20.info/gfx/overview/styledtext.png It's in Three20 .
Here is an idea. I have no idea if it would work.
If you are only using colors, and not styles, the a UIWebView with colored text might layout text in exactly the same way as a UITextView. You could put a UITextView with invisible ink (text and background fully transparent) over a UIWebView and mirror the contents with colors in the html. I assume you can do scrolling with javascript along with the colored layout.