PDF file basic usage in cocoa(objective c) - cocoa

Can anybody please give me a step by step guide on how to use a locally saved pdf file in a cocoa application and display its contents?
P.S.I am basically a noob in cocoa , and I want to have a proper idea of what I am learning.Therefore I need a step to guide on this.
Thanks,
Animesh

I do not know of any step by step guide. Apple has the PDFKit framework to display PDF files. Read the PDFKit Programming Guide, which is part of Apple's developer documentation. For the user interface you need a window and a PDF view to display the contents of the PDF file.
Keep in mind that PDFKit is not a beginning technology. If you are learning Cocoa and Objective-C, you should start with a simpler project before you move on to displaying PDF files. An example of a simpler project would be an app that converts temperature from Celsius to Fahrenheit or the other way around.

Related

pdf importer with maroto

I am trying to develop a pdf generator. The pdf generator has multiple page. First page has some specific value with is working fine. But the second page has invoice which user uploads, In this case the user can upload a image file or pdf file.
For this I am using maroto library which works great when it comes to image or content generation but there is no support for import another pdf and merge with current one.
Now i know maroto uses gofpdf library and gofpdf has pdi importer so in my mind it should be possible to implement such feature. I didn't get any reply from their git issue board so asking it here.
Can anyone help me with this?? or my only choice is to change the library and do the coding again?
I could not find a solution for this. So i had to improvise the system
the way I solved the problem is:
generate a pdf using marotopdf library
load the second pdf
use unidoc library and merge 2 pdfs (its just merging 2 pdfs 1 after another)
This is not solving my problem 100% as i would like to have the ability to add company logo on the second pdf which is not editable atm. But its dining the main work (merge 2 pdf).
I've created a simple library to help you with this. It adds two methods to the gofpdf Fpdf class:
importPdf imports a PDF into the current PDF document
linkPdf creates a hyperlink to a PDF document
It uses cgo to use the pdsys, pdflib and pdflib_pllibraries.
You can find it here: https://github.com/jung-kurt/gofpdf

Previews of matlab figures in Windows explorer (utility to set an image as the thumbnail for another file)

Has anyone come up with a way to make thumbnail type previews for matlab figures in windows?
I'm getting tired of saving a .png along with the .fig file just so I know what was in it.
A useful helper for this would be a command line utility for windows that can be provided with an image file and told to use that as the basis for the preview for a given file.
I could write a helper function in matlab that saved the .fig, made a temporary image file, then pushed that into the thumbnail using the command line utility.
You can write a function in C++ that tells Windows how to generate thumbnails from your file.
This link explains about it. Check out the section about Thumbnail Image handler. This is the function that you will need to implement.
From what I managed to understand, the procedure is this:
Write a in-process COM server (DLL) that implements IThumbnailProvider interface
Put the DLL file somewhere on your computer.
Write an entry to the registry, by using the procedure described in this page.
That still leaves you with the problem of thumbnail extraction from .fig file. As far as I know, fig files are nothing but mat files. I am fairly sure that it is possible.
You will need a custom save function for all figures. It will print a thumbnail of the image (by using the print command), and save it inside the figure.
I know that it isn't much information, but it can help you to get started. You might as well ask someone who is highly proficient in COM technology for more help. Thus, I recommend adding a COM tag to the question.
Edit(1) - I've found a good tutorial on the subject:

Converting an Image type PDF to an OCR enabled PDF

I'm not sure if my title is overly descriptive of what I'm trying to do so I will try and elabarate.
I've been asked to develop a small application where someone can upload a PDF to the website. The website is coded in ASP classic but I don't mind going down the route of .net.
Once uploaded the code needs to check if the PDF is text based if it is not it needs to then convert the document over to the text type PDF.
Does anyone have an idea of a component that can do this image PDF to text PDF conversion? So far i've looked into:
http://pages.cs.wisc.edu/~ghost/
http://www.websupergoo.com/abcocr-1.htm
I didn't overly understand what the ghost thing was doing and the websupergoo solution appeared to be converting images into text files?
I think you could use one of several websites that let you upload an image and send you back an OCR'ed data. Try www.ocrsdk.com, it is a cloud based OCR SDK recently launched by ABBYY. It's now in closed beta so it's completely free to use.
If you can afford a commercial option, you could use Amyuni PDF Creator .Net with asp.net, or Amyuni PDF Creator ActiveX if you want to stay on asp-classic. Take a look on the OCR module for PDF-Image to PDF-Text processing.
Usual disclaimer applies

Apple's PDFKit (or anything else), extract positions of images

I need to extract the positions of all images from a pdf-file on the Mac. For now I am considering PDFKit, but that if there is a better way of doing that, i'm open to suggestions.
So the question is, how can i parse a PDF file on the Mac, receiving (images, not necessarily), their positions within a page and page numbers using PDFKit or, probably, another library or even a program (I don't have to build it into my program, i just need it done).
UPD Seems like it is possible to do that using Adobe's Acrobat SDK.
Thanks in advance,
Timofey.

How to convert pdf and doc files to html using Cocoa

I would like to convert pdf, doc files to html files using Cocoa
Please help me in this.
Thanks in advance,
You can convert Word files to HTML using NSAttributedString. You can't do this in pure Cocoa for PDF files; you'll have to use a conversion tool, such as stigi suggested. To do that, use NSTask.
Cocoa's PDFKit framework can convert a PDF file to text, through PDFDocument's -string method for example. Of course this won't copy images or formatting though, and it depends on PDFKit being able to recognize text in the file.
there are a couple of tools for the unix commandline that do such kind of conversions.
check out http://pdftohtml.sourceforge.net/ & http://rtf2html.sourceforge.net/
you may see if there are other tools like this.
but to get back to your question. these command line tools can be called from within your cocoa app (won't work on the iphone) and produce the html result.
check out this link for a guide on how to embed such command line tools within your app.

Resources