Create pdf using cocoa? - cocoa

There is some tutorial about how to create a pdf using cocoa? I can't find anything. I looked for it on the web and it seems that I need Quartz to do it, but there aren't practical examples.
Can you help me? Thank you in advance.
—Albé

See Cocoa Printing Architecture documentation. Basically, any printing operation creates a PDF and, in general, the best way to create PDF documents is to implement custom printing layouts.
Alternatively, NSView has printing related methods for grabbing the PDF within a rectangle.

Related

Processing – What is the fastest way to generate an animated .gif-file out of Processing 2?

i am not shure, if there are many Processing-people inside Stackoverflow, anyway:
What is the fastest way to generate an animated .gif-file out of Processing 2?
Thanks in advance!
You've got a couple of options:
Use the gifAnimation library
Save an image sequence from Processing, then encode a gif with an external tool (like ImageMagick,GIMP, Photoshop, etc.)
Also check out this answer for more details
George's answer is correct if you want to do this programatically, and it's what you should do if you care about gif quality.
Another quick and dirty alternative is to capture your screen directly.
I use a tool called ScreenToGif. You can record your sketch directly, without any exporting or encoding on your end.
Here is another question with a bunch of similar tools.

How to translate between user mouse coordinates and PDFDocument coordinates?

I'm working on an app for Macintosh. I want to have the user be able to click inside a PDF rendered onscreen and have an annotation appear where they clicked (or selected). Should/can I use PDFKit for this? I looked at the classes, but PDFSelection seems to deal with text, not coordinates. Specifically, I want to know which classes I should use to achieve this. I've read the PDFKit programming guide, but I'm still not quite clear as to the path forward.
Apple provides sample code, PDF Annotation Editor, its description is:
This sample application uses PDF Kit to examine, edit, and create PDF annotations. It has an inspector panel that shows various attributes of supported annotations. The inspector allows users to edit those values. Additionally, annotations can be created and the code demonstrates how to use PDF Kit to do this. Also, the sample code demonstrates subclassing of PDFAnnotationStamp in order to override the draw method and draw your own custom annotation content. Finally, the sample code demonstrates subclassing PDFView in order to overlay your own content over the PDF content being displayed.
This would appear to answer your questions, in particular look at mouseDown in PDFEditView.
HTH

find similar image in library to photo

I work at a printer where we generate thumbnails of artwork for orders and store them in a folder before printing.
I'm looking for a code library that will allow us to take a photo of a printed item and look through the library of thumbnails for the design.
Just wondered if anyone knows of a library or api that could do this?
Thanks
David
pHash is one solution.
There are others but that mainly depends on your requirements: do you only want to identify identical images, if not, what types of transformations do you want to be able to capture etc.
In general you should look for near duplicate image search.
#david-jennings there are numerous methods to look for similar images in libraries. Remember that google already does this in google images.
Your problem falls under the scope of Content Based Image Retrieval (CBIR), which aims at looking for images with similarities in their content. MPEG-7 is a standard established many years ago to address these issues and the research field is very active with new techniques being developed constantly.
The main idea in CBIR is to extract some kind of a signature from an image and try to match it with all previously extracted signatures of all images in your database. Which method to use depends upon the specifics of your problem... According to your initial post I suppose that probably the use of SHIFT is going to do the work for you...
You may implement such a system using OpenCV with C/C++/Java/etc., or something more "scientific" using MATLAB.

Code to Draw simple PushButton in Quartz?

I know that, Cocoa uses quartz underneath to render the UI.
Thus can anybody share source code underneath that generates this PushButton displayed on screen?
I need this as a part of my research where I am trying to figure out if its possible to have all the UI elements on Mac using quartz (Of-course all 2D elements). I have been able to render others elements but Buttons and its variants still blocks me.
Thank you.
You can use HIThemeDrawButton, documented in /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Headers/HITheme.h.

Creating nice pdfs with ruby

I would like to create pdfs with ruby. One special need is embedding a picture into text (or a textblock), which means I need to be able to let the text flow around the image. E.g. the image should be in the rigth upper corner and the text should start left of the image and continue after the image by using the whole width of the page. How can I do this in ruby? Thank you for any suggestions!
In the past to get print quality PDFs in Ruby, I used rtex.
It's fast too, which is a real bonus.
Prawn to the rescue?
I like the html -> pdf approach. Although it is probably not the best option (prawn is) it makes it easy to design the pdf. See this website. You could also go for the approach documented at jimneath.org.
Good luck
iText is the heavyweight that will allow you to do anything you want with PDFs you can bridge to it with jRuby.
Another option I used was driving open office (it has a ui less option which you can automate from Ruby)
How about having Ruby generate some LaTeX code, then use pdflatex to produce the PDF?
Although I haven't done it myself I've seen people use a headless Open Office. You can control it from Ruby and use it to generate PDF files. You can even use an Open Office template and just fill in some elements into it.

Resources