Multiple PDF pages and scrollview in two dimensions in xcode - ipad

Super noob here:
I am trying to create a scrollview that will scroll through a number of pdf's in a two dimensional array for use on an iPad. As if I tiled all the pdf's and wanted to be able to scroll from page to page by scrolling up/down/left/right. How can I do that?
Any help is appreciated!

I have to read the PDF pages and write them as image contexts. The big problem here is that it you will use a mechanism to generate the pages lazily keeping a little buffer of advance.
The only thing I don't get is why you need a 2D array to store a PDF if this can be done with a 1D array?

Related

How should i implement continuous scrolling through pages in swift?

could you please give me some advices please. I've been struggled for days.
My goal is implement continuous scrolling to show pages from document. Each page is controlled by a viewController. And user should be able zoom in and out.
Should i do it from scratch with scrollView or collectionView? which is better and more memory efficient?
Or there are any off-the-shelf solution for this? (i've searched in Github without success, UIPageViewController is definitive not a solution because it doesn't allow continuous scrolling and only show a whole page)
Thank you very much
Image:
example continuous scrolling
A collection view works just fine for continuous scrolling, and makes efficient use of memory. (Cells are recycled.) If the total contents of your scrolling area are too much to fit into memory you will want to load each page's contents into memory as it scrolls into view, and release it when it scrolls off. (Perhaps have your model store file URLs to each page's contents, and save the page contents into the cell.)
As for zooming, the best way to do that depends on what you mean. If the contents are vector contents like a PDF, you could simply re-render the vector image as the user scrolls. If the contents are very high resolution images you might need to create a mipmapped tiled rendering framework, or use somebody else's. I've written my own mipmapped tiled rendering framework before. It's doable, but a lot of work.
(You take the original huge image and break it into smaller square tiles. You then render the original image into tiles at 50% scale and save those, and then 25%, and then 12.5%, etc, until you get to a size where a single image fills the screen.)

Best way around displaying multiple images from URLs in an NSString

I'm currently working on an application that downloads posts from a Wordpress blog and displays them for a user to view. The current obstacle I've run into is that the blog uses a large number of images within their posts, and the wording of text is quite dependent on having those images in the right place (so they can't be at the bottom of the view, for example).
The solution I've come up with so far would be to use one of the NSString methods to look through the text and find all the sections containing img and then grab those out and separate the NSString at that point. Then I would use a bunch of if statements to work out how many sections there were, and lay out the UIScrollView from there.
To me this sounds like a horrible solution, so I'm hoping there is a better one out there someone could recommend.
Thanks!
OK. First take a look at DTCoreText Framework (parse HTML tagged text and can handle 'img'-tags).
The second: Easly all images have the same size (e.g. images must groped or so). Count the img-tags and you now the needed space.
A good way is to load the images asynchronous....

How can I load an existing PDF

i asked this previously but I think people got the wrong idea:
I'm not trying to generate a PDF from scratch; I'm trying to load and draw onto the screen using Quartz 2d an existing PDF file : any guidance / examples would be very much appreciated
This was my previous post :
How to open and View PDF using Quartz 2d
https://www.cocoacontrols.com/controls/pdf-reader-core
Use this control. It does a lot of the heavy lifting for you.
Here is a great tutorial how to render PDF using CoreGraphics
If you're happy with rendering the PDF into an UIImage and displaying that (a good solution if you don't provide zooming functionality, or if you are happy to constrain zooming to a limited extent using the UIImage inside a UIScrollView), then this project is very good and does disk caching for improved performance:
https://github.com/mindbrix/UIImage-PDF

iOS - How to add text on top of PDF Document?

I've loaded a PDF Document into a UIView Class, and displayed it on screen using CGDrawRect. So Now I can visually see the PDF: What I want to do is have the user click certain points of the file, which will bring up the key board, allowing the user to directly add text to the PDF, which will later need to be rendered - some direction or guide would be very helpful ?
I understand its a lot simpler to draw a PDF from scratch then to manipulate it
I also understand Quartz 2d may be the way to go, but a bit confused with the samples
There are two possible scenarios here:
Editing existing PDF text is very difficult, even with something like PSPDFKit. It is no accident that there are no PDF-based word processors.
Annotating PDF content is more straightforward:
Add any additional content as subviews to the UIView that contains the PDF document. Additional content can be in the form of text, vectors or images - anything that can be added to a UIView. At this point you do not need to worry whether the added content is "part of" the PDF.
When you want to render the added content to the PDF, simply render the container view (which contains both the original document and annotations) to a PDF Context using UIGraphicsBeginPDFContextToFile and UIGraphicsBeginPDFPage.
Check this question and answer for a simple example and a method for ensuring that the PDF is rendered as vectors, not as a bitmap: Rendering a UIView into a PDF as vectors on an iPad - Sometimes renders as bitmap, sometimes as vectors

What is the easiest way to create complex PDF in iOS?

I am trying to generate some complex invoice data in PDF format. I know two Technique:-
By converting Data into HTML data via UIWebView and generate its PDF accordingly. But it is having issue of showing data Blur or unreadable if Zoom, when data is long in size. Cause it actually first create Image from HTML data and generate pdf.
Using QuartzCore technique mentioned in Ray-Wenderlich tutorial:-
http://www.raywenderlich.com/6818/how-to-create-a-pdf-with-quartz-2d-in-ios-5-tutorial-part-2
Is there any way other then these above two? Also is it possible in the First technique to get data in UIWebView as vector based so that when it zoom it will not blur the data?
Thanks in Advance,
Vivek
Use the Quartz 2D framework as described in the tutorial. You don't want to create a pixel image from the html because it does not scale and can get large.
You can use a tableview with multi sections to create your invoice and convert it to an image(uiview----> image) and After that print that image to pdf (image--->pdf).

Resources