I am using VFR reader to display my pdf's. I need to extract the Table of Contents on a button click and display it in a tableview then it should lead to the respective pages while tapping on each.I googled for this and got these links
Create a table of contents from a pdf file
http://mobile.tutsplus.com/tutorials/iphone/ios-sdk-adding-a-table-of-contents-to-an-ipad-reader/
And i came to know that, to get TOC we must use "CGPDFDocumentGetCatalog(pdf doc)". But in my reader that "CGPDFDocumentGetCatalog(pdf doc)" is not at all getting called. Now how can i extract my TOC from my pdf file? Kindly help me out of this. I am struggling on this for a week. Thanks in advance.
Unfortunately I think the two answers you refer to point to different implementation strategies, which are both possibly valid but are different.
The first question is what the PDF files you have and want to show in your app look like. There is no such thing as a predefined TOC object in a PDF file, there are simply different ways to emulate this. The two most common ways are:
A) Bookmarks, which are a way to add little pieces of text to a structured tree, where each piece of text points to a specific location in the PDF file. These bookmarks can be added in the design application or later (there are specific tools to do so) and they can implement whatever structure.
B) Your PDF file might contain something that looks like a classic TOC from a book, which is basically just text on the opening pages, optionally with hyperlinks to specific locations in the book.
The second link you refer to shows how to create user interface where you can show the TOC in. The remaining question then is to figure out what items you want to display in the TOC window. In this second link you point to, the solution presented is to provide hard-coded items specific to one specific book. Of course this approach is not very useful when you want to display just any book.
So the question you are left with is how to figure out what items to display and where they link to.
If you consider my possibility A) above: a PDF file with bookmarks, the answer could be relatively simple. Answer 1 you point to explains how to look at the different structures inside a PDF file - bookmarks are simply such a structure (Defined in section 12.3 of the PDF specification: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf)
This means you could use the techniques shown there to walk the different objects in the PDF file, and find each bookmark. The bookmark will give you the text to display and the actual location in the PDF file that text should jump to when clicked.
If you consider my possibility B) above: a PDF file without bookmarks but a classic TOC, this will be much harder to solve. Such table of contents are simply text on one or more pages, optionally with hyperlinks. Of course you could try to find all text on these pages (if you can figure out on which page the TOC starts and ends), but you'd then also have to figure out where that item links to. If there are no hyperlinks involved, that would be a daunting task.
So your first question should be how generic you want to solve this problem. Do you know which PDF files you'll want to display? Can you devise a TOC for these files yourself (as in your solution 2)? If not, can you be sure all PDF files contain bookmarks? The answer to those questions will largely determine the rest of your strategy...
Related
let me explain this clearly: i'm decide to learn about how to store my data with SQLite, and i decide to download sample code and examine it.
So, i have a .csv file with data, when my program launch, first thing user see is rows of elements. (Its like when you enter "Contacts" in your iPhone, just rows with names on it). When user tap an element, next view display data about it (not really matter what data is, there is a xib controller and its easy to manage).
My question is - how to change color of rows? I don't want it to be "standard white" color, maybe some color i want to import (or default colors, but not just white).
This sqlite3 file was created using .csv file, sqlite command tab (terminal), and python. Then imported to application in Xcode.
Please help me!
Color display is controlled by your "sample code". If you really want to change the colors you'll need to ask more specifically in case someone else has seen it. To do it yourself, you need to dig into the source (or in its documentation), find where and how it sets the colors, and change it. A possible short-cut would be to search for common color names using an all-file search (if your IDE offers it, or using grep if you're developing on linux/osx). This might lead you to the places where colors are defined.
But if your goal is to learn SQL, my advice would be not to waste your time on the application. Ignore the ugly colors and move on to a different environment as soon as you get the chance.
I am wondering if someone can help. I have document with several content controls within it. Each content control contains lists or sometime single parapgraphs with styling.
Depending upon certain login I want to copy the entire content control or the content of the content control and paste it into another document.
In short, is there a way to copy and paste content controls between documents preserving styles using OpenXML?
Any help with be highly appreciated.
Thanks in advance.
Ashwin
OpenXML is basically a collection of XML DOMs (just as the underlying DOCX file is a zip file containing a bunch of XML files). So it's not copy/paste as the term is generally meant.
You can copy a node (and its children) from one OpenXML to insert/add to the other. But it is not necessarily simple. For example, if the copied node has a paragraph with a style that does not exist in the destination OpenXML, you need to copy that style's node (and children) too. Same for fonts, lists, etc.
For content controls with simple content (styles/fonts not set or exist in both), this is pretty easy. But the cases where there's something you missed, those you need to address. I know this is not the most specific help, but what you have to handle is highly dependent on what is in your content control. For example, if you have a bitmap in one, then the bitmap, which is a distinct object in the OpenXML, also has to be copied.
Is it possible to get page title via iText?
The PdfTextExtractor returns all text from the page but I don't know what line is title. Also, title may contain more than one line
I don't know coordinates of title thus I can't use RegionTextRenderFilter
I can try to analyze the font size and take the line(s) with biggest font but TextRenderInfo doesn't provide public access to gs (private final GraphicsState gs)
Any other ideas?
Pages within a PDF don't have titles, they just have text that happens to be bold or in a large font and appears in an area you consider to be "more top" than other pieces of text. It sounds like you know this already, I just needed to be clear on this.
See my post here which shows how to get font information by subclassing ITextExtractionStrategy. My sample targets iTextSharp which is the .Net port of iText but they match pretty much feature-to-feature. The biggest differences is that Java uses getXXX and setXXX whereas .Net just uses XXX for both. Otherwise everything should port just fine.
The moral of the story is that you are going to have to write some arbitrary rules defining what you think of as a "title" and then parse based on those rules.
I'm fairly new to Cocoa and am having trouble Googling for the best way to design my iPhone app.
This app is for viewing a stageplay. It should pretty print the script such that character headings are centered and in small caps, say, and stage directions are in italics etc. It should also allow one character's lines to be highlighted (i.e. dynamic formatting).
Looking at this question it looks like NSTextView/NSTextStorage will provide the formatting requirements I want, I'm just confused as to how to construct the view from the underlying data.
I'm thinking at the moment my source will be XML in the following form:
<script>
<dialogue character="bob">Hello Sue!</dialogue>
<stageDirection>He moves to the table</stageDirection>
<dialogue character="sue">Hello Bob!</dialogue>
</script>
Which would output something similar to the following:
BOB
Hello Sue!
He moves to the table
SUE
Hello Bob!
How do I go from a document model (XML / CoreData / ...) to a view containing pretty formatted text?
Any advice or pointers would be great; I just can't get my head around this problem!
If interactivity isn't required then the most easy way I can think of is to generate HTML and render it with UIWebView. Dynamic highlighting can be done with stringByEvaluatingJavaScriptFromString:
UPDATE
Next relatively easy option is to compose styled text with individual UILabels. Basically you have an array of text entries (cues, stage directions etc.), each with it's own style. We create an array of corresponding UILabels with styles applied and then layout them on "script view". After that we can put this "script view" in UIScrollView and that's it. Size of label required to fit particular text can be determined with sizeWithFont:constrainedToSize:lineBreakMode: of NSString.
There are also CoreText services available, but this is much more advanced option.
Am using N2 CMS and want to know how I can create an editable item that can be included in the header of every page within the site.
I just want to be able to edit this piece of text in one place and have the text appear on every page.
I understand that I need to create a "Part" but I'm not sure how to create the edit interface for this one "part"
Thanks.
Late answer but IT might help the others. You can use it as following.
#{ Html.DroppableZone(Content.Traverse.StartPage, "EDITABLEPART").Render(); }
A simpler approach (to parts) might be to:
add a property to your homepage ContentItem which is decorated with EditableTextBox or EditableFreeTextBox.
edit the homepage to set the text
then in your layout/masterpage you can simply include the output from this property
We use this technique for storing the Google Analytics tracking code against the homepage and it then gets rendered on every page.
It sounds like you need a recursive zone. Here's an example: https://github.com/jamestharpe/HereSay/blob/master/src/HereSay/Decorators/SectionalZoneDecorator.cs
Using that code, all you need to do is name your zone beginning with "Sectional" (e.g. "SectionalTopZone") and the plug-in will take care of the rest.
For an example of an editable part, you can take a look at the code here: https://github.com/jamestharpe/HereSay/blob/master/src/HereSay/Parts/HtmlContentBlock.cs