kindlepdfviewer icon indicating copy to clipboard operation
kindlepdfviewer copied to clipboard

pdf highlight

Open aliabbasjp opened this issue 12 years ago • 9 comments

Why is the highlight not preserved in pdfs across readers? Can anyone please add this feature+note taking too

aliabbasjp avatar Jun 27 '12 18:06 aliabbasjp

you mean why are annotations not saved directly into pdf files? If I'm not mistaken there was a discussion on mobileread that it would be difficult to accomplish on the kindle.

A workaround would be to write a program (in Windows, Linux) that takes highlight information from corresponding lua files and adds to the pdf file on your computer.

The following project seems to be abandoned -> http://code.google.com/p/kindle-annotations/ But maybe someone or the author would be willing to make adjustments to the program to this end.

eLiNK2gl avatar Jun 28 '12 07:06 eLiNK2gl

so can someone integrate that code with kpdfv ?

aliabbasjp avatar Jul 02 '12 07:07 aliabbasjp

@aliabbasjp project which you are pointing at depends on huge Java pdf library, so porting it is not feasible, at least for me.

If I'm not mistaken Kindle's pdf viewer is saving annotations in .pdr file and not .pdf itself.

Note-taking would be useful feature to add, but we would first need some way to export our highlights so that they are useful outside reader itself.

dpavlin avatar Aug 29 '12 14:08 dpavlin

I do not see any need to port that application at all. The application is a standalone and because it is written in Jave can be used under Windows, Linux and most probably MacOS. I can ask the author if he is interested in making adjustments to his program. But first, kpdfviewer should be able to export notes.

eLiNK2gl avatar Aug 30 '12 12:08 eLiNK2gl

Highlights are saved in kindlepdfviewer/history/mungled-name-of-original-document.lua folder together with file settings. It's lua syntax but it should be possible to parse it within Java code I think.

Since we don't have arbitrary notes attached to highlights (yet) we are not exporting those, although I would love to implement Amazon Kindle reader compatible format for it once we have note-taking because there are various useful sites around internet which know how to reformat this format into different other format.

dpavlin avatar Aug 30 '12 13:08 dpavlin

Zotero's plugin zotfile allows to fetch pdf annotations from pdf seamlessly but it can be tweaked for kindle pdfs too

aliabbasjp avatar Sep 14 '12 06:09 aliabbasjp

zotfile author replied as follows:

You should start by writing a function that takes the path to the pdf file as an argument and returns an array of annotation objects as defined by zotfile (see below). I can take care of integrating this function in zotfile so that you actually don't have to spend your time understanding the zotfile code.

function getLuaAnnotations(filepath) { // replace pdf with lua in the filepath // read lua file // save annotations in annotation object as defined below // return array with annotation object }

The annotation object just contains the filename, page number for the annotation, the ID (not sure whether lua files have an annotation ID), the type ("Highlight", "Underline" or "Note"), the content (content of the note) and the highlighted text (markup). Below is the structure but start by figuring out how to read the file and get the content. Here is some documentation about file streams in FF javascript but you might find something better. Just make it work with a hard coded filepath argument. As long as the function works, I will integrate it in zotfile and make sure the correct file path is used for the call. I also recommend setting up a environment for development that gives you immediate feedback. I am still using Chickenfood but that is pretty outdated and only runs in FF 3.0. I am sure there are much better alternatives....

var annotations = []; a = { filename:XX, page:XXXX, ID:XXX, type:XX:, content:XX, markup:XX }; // add each annotation to the array annotations.push(a);

return(annotations)

aliabbasjp avatar Sep 14 '12 06:09 aliabbasjp

That will be great, I use zotero too :)

I am not sure what an annotation ID is. And does markup means the content of highlighted text?

Do they have a document for this? I failed to find one on their official website...

houqp avatar Sep 14 '12 12:09 houqp

annotation id seems to be unique # assigned to an annotation

aliabbasjp avatar Nov 24 '12 10:11 aliabbasjp