Hello i'm working on a speedreading app and i'm looking for some tips or suggestions. In this app i have to use different reading techniques this requires formatting the text in different sizes from a pdf. for techniques as auto scrolling without pictures. Does someone already know who to do this? or has an example for me?
IF the PDF contains text that is weirdly formatted or contained in images you are without luck, else there are several ObjC libraries available (on github)
they all wrap the CoreGraphics CDPDF* Functions
this isn't that easy and cant be answered in a one-liner but the basic approach is:
get a CGPDFDocument
get each PDFPage
get the CGPDFDictionary for each page and parse it. it will give you ALL objects in the pdf page
foreach string you encounter, call CGPDFStringCopy and append it to a mutableString that serves as your buffer
the buffer is the doc's text
Related
I'm in a situation where I need to distinguish whether or not a PDF has a certain layout after scanning the document for text. Is this possible with PDF.js and if so where would I find this information?
Unfortunately, PDFs consist of very low-level drawing commands, and as such it is very difficult to extract any formatting information from them, no matter what tool/library. (See for example, here)
I am trying to create a simple tool that uses this website's functionality http://cat.prhlt.upv.es/mer/ which parses some strokes of text to a math formula. I noticed that they mention that it converts the input to InkML or MathML.
Now I noticed that according to this link: Tradeoff between LaTex, MathML, and XHTMLMathML in an iOS app? you can use MathJax to convert certain input to MathML.
What I need clarification/assistance with is how can I take input (say from finger strokes) or a picture and then convert it to a format in which I can provide this website from an iOS device and read the result at the top of the page. I have done everything regarding taking a picture or drawing an equation on an iPhone but I am just confused how I can take that and feed it to this site in order to get a result.
Is this possible, and if so how?
I think there's a misunderstanding here. http://cat.prhlt.upv.es/mer/ isn't an API for converting images into formulae—it's just an example demonstration of the Seshat software tool.
If you're looking to convert hand-drawn math expressions into LaTeX or MathML (which can then be pretty printed on your device), you want to compile Seshat and then feed it, not the website, your input. My answer here explains how to format input for Seshat.
I am very new to sqlite and I need help. I have looked a lot on the net, in books and within Stack Overflow for a solution to my problem, but so far no cigar.
I have some text saved in an Sqlite database that I display in a webview and I would like to add a photo once every 50 lines of so. The photos themselves would reside in a server. According to tutorials I found on the net, regular HTML like
<img src="http://rempu.modwest.com/photo/SS.png" alt="some_text">
embedded in the text should work in sqlite but I get only the missing image icon. The fact the icon appears at all seems to indicate that the HTML is understood and the problem is the URL. I have tried relative URLs with local files, absolute ones with remote files but nothing works even with paths I know to be correct.
.
Lots of Stack Overload pages suggest to use URLs rather than BLOBS for images in sqlite, none I found explains HOW this is done. Anybody can help? I apologise in advance if my question is dumb.
Thanks,
Frank
So your question isn't dumb, but it is a little confusing. If I understand it correctly, you're trying to display images with some alt text inside a UIWebView?
So most of what you're probably going to see here on SO related to images & iOS is downloading those images to display natively inside something like a UITableView or something like that. That's probably just going to confuse the issue here.
What I would do is, inside the SQLite database, store absolute URLs (include the http:// and FDQN) for the images you want to display. Then, when you're building the HTML (which it sounds like you're then displaying using UIWebView's loadHTMLString:baseURL:) just insert those URLs into the appropriate HTML tags. You can then shove that string into loadHTMLString and UIWebView should take care of loading the approriate images for you!
And yes I completely agree with whoever told you BLOBs are a Bad Thing™ in SQLite. However, I've seen some "clever" solutions with utilizing base64 encoding of images and storing the resulting string in a TEXT field in SQLite. This is slightly better but not by much. It's an option though if you want, and you'll just need to go get the appropriate HTML code to load a base64 image source.
Let me know if that works!
I downloaded the EverNote API Xcode Project but I have a question regarding the OCR feature. With their OCR service, can I take a picture and show the extracted text in a UILabel or does it not work like that?
Or is the text that is extracted not shown to me but only is for the search function of photos?
Has anyone ever had any experience with this or any ideas?
Thanks!
Yes, but it looks like it's going to be a bit of work.
When you get an EDAMResource that corresponds to an image, it has a property called recognition that returns an EDAMData object that contains the XML that defines the recognition info. For example, I attached this image to a note:
I inspected the recognition info that was attached to the corresponding EDAMResource object, and found this:
the xml i found on pastie.org, because it's too big to fit in an answer
As you can see, there's a LOT of information here. The XML is defined in the API documentation, so this would be where you parse the XML and extract the relevant information yourself. Fortunately, the structure of the XML is quite simple (you could write a parser in a few minutes). The hard part will be to figure out what parts you want to use.
It doesn't really work like that. Evernote doesn't really do "OCR" in the pure sense of turning document images into coherent paragraphs of text.
Evernote's recognition XML (which you can retrieve after via the technique that #DaveDeLong shows above) is most useful as an index to search against; the service will provide you sets of rectangles and sets of possible words/text fragments with probability scores attached. This makes a great basis for matching search terms, but a terrible one for constructing a single string that represents the document.
(I know this answer is like 4 years late, but Dave's excellent description doesn't really address this philosophical distinction that you'll run up against if you try to actually do what you were suggesting in the question.)
I've been doing some head banging on this one and solicit your advice.
I am building an app that as part of it's features is to present PDF forms; meaning display them, allow fields to be changed and save the modified PDF file back out. UIWebViews do not support PDF interactive forms.
Using the CGPDF apis (and benefit from other questions posted here and elsewhere), I can certainly present the PDF (without the form fields/widgets), scan and find the fields in the document, figure out where on the screen to draw something and make them interactive.
What I can't seem to figure out is how to change the CGPDFDictionary objects and write them back out to a file. One could use the CGPDF Apis to create a new PDF document from whole cloth, but how do you use it to modify an existing file?
Should I be looking elsewhere such as 3rd party PDF libs like PoDoFo or libHaru?
I'd love to hear from anyone who has successfully modified a PDF and written it back out as to your approach.
I once did this incredibly cheaply by munging through the PDF -- I mean using regular expressions -- and just dirtily changing the actual raw text of the raw PDF data file.
It can work perfectly in simple situations where you are easily able to find the value in question.
No idea what you're trying to do here but a lateral thought! Hope it helps!