[Okular-devel] [Bug 151614] store annotations with documents

Franco Bagnoli franco.bagnoli at gmail.com
Tue Nov 4 20:58:41 CET 2008


http://bugs.kde.org/show_bug.cgi?id=151614


Franco Bagnoli franco bagnoli gmail com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |franco.bagnoli at gmail.com




--- Comment #53 from Franco Bagnoli <franco bagnoli gmail com>  2008-11-04 20:58:38 ---
I discovered okular today, and I find it extremely useful... if it could save
annotations. 

I plan to use it for annotating slides during lessons and for sending notes to
collaborators while editing articles. 

So, I wrote the quick perl hack (also attached to the discussion, I hope --
this is also my first bugzilla contribution). Save it as "oku", make it
executable and use it. I choose to let annotation persist even if file changes:
in general annotations may be scrambled (I would love to have them linked to
text, rather than to physical coordinates) but for small changes during editing
they may be still useful -- especially for notes.

#!/usr/bin/perl

=pod
usage: oku [options] <file>\n";
  copies the annotation file <file>.okular to the okular shared kde dir
  (where okular expects it), launch okular and after it exits, copies back the 
  annotations. Notice that if file changes, annotations persist (probably
scrambled). 
options: 
  -x : do not copy the annotations (delete them)
end_message
=cut

use Cwd 'abs_path';
use Getopt::Std;
my %options=();

getopts("x",\%options);

my $file = $ARGV[0];
print "--$file | $options{x} | @ARGV\n";
die "missing file" unless $file;
my $okular = "$file.okular";
my $size = (stat($file))[7];
my $path = abs_path($file);
my $xml = "$ENV{HOME}/.kde4/share/apps/okular/docdata/$size.$file.xml";
my $content; 

if (defined $options{x}) {
  print "deleting annotations\n";  
} else {
  undef $/;

  open OKULAR, $okular;
  $content=<OKULAR>;
  close OKULAR;
  #q&d replacement
  $content =~ s/<documentInfo\s+url=".*?"\s*>/<documentInfo url="$path" >/s;
  print "writing okular data to $xml\n";
  open OUT, ">$xml";
  print OUT $content;
  close OUT;
}
`okular $file`;
print "moving okular data to $okular\n";
`mv $xml $okular`;


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Okular-devel mailing list