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
Related
I want to make an electron app that is similar to scratch in which it uses drag and drop features. I want to make these features using canvas. However, I don't know if this is a good idea as I tried searching it up and never got Electron and HTML5 Canvas in the same sentence.
I'm using canvas for rendering charts in my project and it works correctly. I have been researching a bit and I have not found any better alternative to replace it
I am currently working on an app where we would like to download a PDF from a remote server and then draw on it. We would like to draw Google Maps pin-like annotations on the PDF (the static draw part). Furthermore, we would like to detect if a user has touched a pin and then draw a calloutBox over this PDF (dynamic draw part). We obviously would like the pdf to be scrollable/zoomable. Does anyone know of a good way to achieve this?
Things I have researched:
1) Render in a UIWebView. This seems like a great solution but its not clear to me how to then implement the draw code on the PDF. I have heard people say create a transparent UIView above the UIWebView for the drawing. This seems to come with its issues, how will it handle zooming and scrolling?
2) Use Quartz 2D and generate my own PDF from the PDF I fetch from the server. As I draw my own PDF content I can draw the static marker pins. Once I have this PDF, I can then shove it in a WebView. The problem with this approach however is I still need to handle the dynamic drawing of the call-out boxes when a user taps on the pin and this then kinda takes me back to problem 1.
You're correct that Apple does not offer much in terms of this issue. There's UIWebView which can preview and show PDF documents, but it's really not suited to adding annotations, and any "solution" with views will be very fragile, if you manage to do it at all. It's meant as a black box to read PDF documents, not for annotating.
You have to go all the way back to CGContextRef and take over the scrolling, zooming and touch handling/drawing yourself. Apple's ZoomingPDFViewer example is a good start.
I have been working on this problem since 2010 and we offer a commercial solution for PDF annotating for iOS, Android and Web called PSPDFKit. We ship a custom renderer which is better and more exact than Apple's CoreGraphics renderer, but the more interesting part is that we can deal with all common PDF annotation types. You can use note annotations to represent your pins and move them around, add notes, interact/override the default tap handling (and e.g. show your own popover when people tap on them). They are also always the same size - so they can be anchored at an exact point in the PDF and then you can zoom in while they stay the same size. The best part is that this is all part of the PDF spec, so they will also work with Apple's Preview app or Adobe Acrobat, so people can save/customize the markup and then everything can be saved in the PDF. The architecture is flexible so you can also simply save everything in a database or sync it back up to your server and simply use it for touch handling.
You can also build that yourself - the basic architecture is a UIScrollView and views that are managed. It quickly gets tricky when you do zooming and have views that need to stay the same size + touch handling and maybe you also want things like multi-select or regular ink drawing. You will also want to add some sort of image caching layer, since rendering PDF documents can be quite slow on mobile devices. Oh, and if you want to make text selectable or implement search, be ready for a rabbit hole that is called the Adobe CMap and CIDFont
Files Specification.
excuse me,my english is poor however i would try to describe my questions clearly.
first i want to operate (read,zoom,move,zoom with rectangle) some image whose format like jpg,tiff and img .
i have try to do this by gdal,using rasterio to zoom and move ,but the result is quite strange.it's slow than i do it with gdi+.i have asked other people,however ,the answer may be rasterio read image direct from hard disk, but gdi+ do things in ram. and maybe the images i operated are small images ,small than 4000*3000.
so now i operate images in gdi+.but i think if i can do same things in directx?
i mean i use directx instead gdi+.because i think it will be more fast.
and because i can only use c#,so i think there are some people could give me some suggestion with managed dx or xna
thx~~~
There is already a fast image viewer called TuiView that is simple to install and use.
Documentation is here: http://tuiview.org
If I understood your question, you are trying to build a simple image viewer.
If so you can easily do it with XNA and it will work very fast.
All you need to do is to load the image and display it to the screen, and the pan and zoom are also very simple.
Read this tutorial :
http://rbwhitaker.wikidot.com/spritebatch-basics
I am working on this project where I am required to display PDF files. I have two options to do this.
Using the UIWebView
Using Core Graphics
I've done some reading regarding both the approaches and found that both of them have their own advantages and disadvantages. For example,
UIWebview is slow and takes up a lot of memory because it loads the entire PDF at once but handles the pinch and Tap zoom.
Core Graphics gives low level controls but the onus of implementing zoom is on me.
I am downloading the PDF from a server in form of individual pages. So I dont stand the problem of using up too much memory. But I need to display thumbnails for which I'll have to use Quartz (Core Graphics). Would it be better if I combine the two i.e; webview for displaying PDF and Core Graphics for thumbnails?
I am not able to come to a conclusion as to which technology I want to go with considering the long run. Any help regarding this would be highly appreciated.
I have got one image like this
to only black and white colored image.
And I come across this ImageMagick resource
Does this can be used to generate black and white image from the above given image?
Does it is good to use this one?
If it is good one then does there is any documentation or tutorial on "How to use?".
UPDATE
SO GOT THE BEST SOLUTION FROM #ale0xB's SUGGESTION.
No third party api is required for doing this as apple's COREIMAGE.FRAMEWORK is the best for doing what I want to do. It's filters are working like charm :)
Thanks for the suggestion :)
I use this image filter. And it is great in speed and provides great output :)
Why would you want to use imageMagick instead of the standard Core Image to produce black and White images? I haven't used it before, but I doubt it's gonna give a much better performance than the native framework when it's just about creating a filter.
Since iOS 6 you have it really easy, have a look: Core Image filters, specially to CIColorMonochrome, which is the one you may be interested in.
If you're playing with images in your app, this is definitely worth checking: Core Image Programming Guide