Skip to content

Commit 4b87b86

Browse files
committed
Merge branch 'release/alpha/master'
2 parents 3f313a2 + b36cd50 commit 4b87b86

27 files changed

+980
-127
lines changed

Manifest.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
![Screenshot](/docs/images/screenshot_alpha.png)
44

5-
If you use Kindle to read PDF books or documents, you might have seen that the highlights and notes
6-
made on the Kindle are not saved on the PDF file itself. This means, that if you take the PDF file
7-
from your Kindle and read on another device, you will not see those highlights and notes there.
5+
I sometimes read PDF documents on my Kindle and anyone who does the same, knows that highlights and
6+
notes taken on the Kindle are not saved on the PDF file itself. This presents a huge problem
7+
archiving my notes and to redo the highlights and copy the notes manually on to the PDF later on
8+
is not practical for me.
89

9-
This software tries to provide a solution. The basis is the Clippings.txt file on your Kindle.
10-
Kindle saves the page numbers and content of the highlights and notes in the text file. So in
11-
theory, one can read the Clippings file and reapply the highlights and notes on the PDF separately.
12-
This software automates the process.
10+
This software tries to provide a solution. **kpdfsync** reads the ‘My Clippings.txt’ text file for
11+
the highlights and notes and then applies them in the correct place on a PDF file.
1312

14-
Currently it is in development, so not all the features work or even present. There can also be
15-
serious bugs present, so I request you to keep backup of the files you give to kpdfsync (the
16-
clippings file and pdf files)
13+
Currently it is **under development**, so all the features may not work or be present.
14+
There can also be serious bugs present, so I **request you to keep backup of the files you give to
15+
kpdfsync (the clippings file and pdf files)**.
1716

1817
Here is the rough roadmap of the development.
1918

@@ -30,7 +29,14 @@ Here is the rough roadmap of the development.
3029
manually by the user.
3130
- [X] GUI finalizing for the Alpha release.
3231
- [X] Debug loggings
33-
- [X] **Alpha Release**
32+
- [X] **Alpha Release 1**
33+
34+
----
35+
36+
- [X] Bug Fixes
37+
- [X] Feature: Fixing common PDF errors.
38+
- [X] Usage guide for the end user.
39+
- [X] **Alpha Release 2**
3440

3541
----
3642

@@ -41,7 +47,16 @@ Here is the rough roadmap of the development.
4147

4248
## Requirements
4349
- JRE 1.8 or higher
44-
- Linux, Mac, Windows
50+
- Linux, Windows
51+
52+
Can probably work on macOS, but I do not own one, so not able to test.
53+
54+
#### For fixing feature to work, you require the following:
55+
* Linux: poppler-utils
56+
* Windows: poppler-utils is included with the release.
57+
58+
**Note:** This is a new feature, which can resolve few of the PDF errors, but not all. New fixes
59+
will be added later on.
4560

4661
## 3rd-party License
4762

TODO

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ Kpdfsync
5555
Highlighting = 12 67 (Expected, Much more accepatble
5656
highlighting)
5757

58-
[ ] For some PDF files, org.pdfclown.tools.TextExtractor.extract() is returning null.
58+
[ ] (GitHub Issue #2)
59+
Book: Concrete Mathematics original PDF file.
60+
61+
For some PDF files, org.pdfclown.tools.TextExtractor.extract() is returning null.
5962
This is seen with the Concrete Mathematics original PDF file. May be a TrueType font issue.
6063
Here is the stack trace:
6164
java.lang.NullPointerException
@@ -87,6 +90,10 @@ Kpdfsync
8790
at org.pdfclown.tools.TextExtractor.extract(TextExtractor.java:296)
8891
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.highlight(PdfAnnotatorV1.java:62)
8992
at coderarjob.kpdfsync.poc.MainFrame$2.run(MainFrame.java:172)
93+
94+
Solution:
95+
Running pdftocairo tool (from poppler-utils package), solves this error.
96+
Command: pdftocairo -pdf <in pdf file> <out pdf file>
9097

9198
[ ] Highlight is not visible on the output PDF file. This was seen on the Concrete Mathematics
9299
cropped PDF file.
@@ -103,7 +110,8 @@ Kpdfsync
103110

104111
The times, this exception occures, it occures around the 73% mark.
105112

106-
[ ] EOFException at org.pdfclown.tools.TextExtractor.extract() method. This is seen on
113+
[ ] (GitHub Issue #1)
114+
EOFException at org.pdfclown.tools.TextExtractor.extract() method. This is seen on
107115
'the_evolution_of_operating_system_cropped.pdf' file. Could also be a font issue.
108116
Here is the stack trace
109117
java.lang.RuntimeException: java.io.EOFException
@@ -173,3 +181,60 @@ java.io.EOFException
173181
at org.pdfclown.tools.TextExtractor.extract(TextExtractor.java:296)
174182
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.highlight(PdfAnnotatorV1.java:62)
175183
at coderarjob.kpdfsync.poc.MainFrame$2.run(MainFrame.java:172)
184+
185+
Solution:
186+
Running pdftocairo tool (from poppler-utils package), solves this error.
187+
Command: pdftocairo -pdf <in pdf file> <out pdf file>
188+
189+
[ ] (GitHub Issue #4)
190+
Book: MMURTL
191+
org.pdfclown.util.NotImplementedException: LZWDecode
192+
193+
Stack trace:
194+
org.pdfclown.util.NotImplementedException: LZWDecode
195+
at org.pdfclown.bytes.filters.Filter.get(Filter.java:74)
196+
at org.pdfclown.objects.PdfStream.getBody(PdfStream.java:193)
197+
at org.pdfclown.objects.PdfStream.getBody(PdfStream.java:155)
198+
at org.pdfclown.documents.contents.Contents$ContentStream.moveNextStream(Contents.java:279)
199+
at org.pdfclown.documents.contents.Contents$ContentStream.(Contents.java:86)
200+
at org.pdfclown.documents.contents.Contents.load(Contents.java:591)
201+
at org.pdfclown.documents.contents.Contents.(Contents.java:366)
202+
at org.pdfclown.documents.contents.Contents.wrap(Contents.java:345)
203+
at org.pdfclown.documents.Page.getContents(Page.java:571)
204+
at org.pdfclown.documents.contents.ContentScanner.(ContentScanner.java:1033)
205+
at org.pdfclown.tools.TextExtractor.extract(TextExtractor.java:297)
206+
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.highlight(PdfAnnotatorV1.java:62)
207+
at coderarjob.kpdfsync.poc.MainFrame$2.run(MainFrame.java:202)
208+
at java.base/java.lang.Thread.run(Thread.java:833)
209+
210+
Solution:
211+
Running pdftocairo tool (from poppler-utils package), solves this error.
212+
Command: pdftocairo -pdf <in pdf file> <out pdf file>
213+
214+
[ ] (GitHub Issue #3)
215+
Book: https://plan9.io/sys/doc/lexnames.pdf
216+
217+
Cannot invoke "org.pdfclown.documents.contents.IContentContext.getContents()"
218+
because "contentContext" is null
219+
220+
Stack Trace:
221+
Exception :Cannot invoke "org.pdfclown.documents.contents.IContentContext.getContents()" because "contentContext" is null
222+
java.lang.NullPointerException: Cannot invoke "org.pdfclown.documents.contents.IContentContext.getContents()" because "contentContext" is null
223+
at org.pdfclown.documents.contents.ContentScanner.(ContentScanner.java:1033)
224+
at org.pdfclown.tools.TextExtractor.extract(TextExtractor.java:297)
225+
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.highlight(PdfAnnotatorV1.java:62)
226+
at coderarjob.kpdfsync.poc.MainFrame$2.run(MainFrame.java:202)
227+
at java.base/java.lang.Thread.run(Thread.java:833)
228+
229+
[ ] Index Out Of Bounds in PdfAnnotatorV1
230+
PDF souce :/home/coder/kpdfsync/test-files/Books/Classic Operating Systems_ From Batch Processing To Distributed Systems_cropped.pdf
231+
232+
Exception :index -1, length 0
233+
java.lang.StringIndexOutOfBoundsException: index -1, length 0
234+
at java.base/java.lang.String.checkIndex(String.java:4560)
235+
at java.base/java.lang.AbstractStringBuilder.deleteCharAt(AbstractStringBuilder.java:970)
236+
at java.base/java.lang.StringBuilder.deleteCharAt(StringBuilder.java:298)
237+
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.doHighlight(PdfAnnotatorV1.java:96)
238+
at coderarjob.kpdfsync.lib.annotator.PdfAnnotatorV1.highlight(PdfAnnotatorV1.java:65)
239+
at coderarjob.kpdfsync.poc.MainFrame$2.run(MainFrame.java:201)
240+
at java.base/java.lang.Thread.run(Thread.java:833)

build.sh

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
#!/bin/sh
2+
# -----------------------------------------------------------------------------
3+
# Compiles .java files and version string creator script kpdfsync
4+
# -----------------------------------------------------------------------------
5+
# This script is responsible for taking the source code and creating a complete
6+
# runnable program.
7+
#
8+
# Creates file system and then builds kpdfsync. It creates the version string
9+
# for each of the packages and puts them to their respective app.settings
10+
# files. It packs the resource files for each of the packages in the end.
11+
# -----------------------------------------------------------------------------
212

313
BIN_DIR=build/classes
414

515
mkdir -p $BIN_DIR
616
rm -rf $BIN_DIR/*
717

18+
# -----------------------------------------------------------------------------
819
# Remove trailing spaces from java source files
20+
# -----------------------------------------------------------------------------
921
find src -name "*.java" -exec sed -i s/\ \*$//g {} \; || exit
1022

23+
# -----------------------------------------------------------------------------
24+
# Building
25+
# -----------------------------------------------------------------------------
1126
export CLASSPATH="lib/pdfclown.jar:$BIN_DIR"
12-
1327
JDK_VER_TARGET=8
1428

1529
# Build AJL
1630
javac --release $JDK_VER_TARGET -Xlint -d "$BIN_DIR/" \
17-
src/coderarjob/ajl/file/*.java || exit
31+
src/coderarjob/ajl/file/*.java \
32+
src/coderarjob/ajl/*.java || exit
1833

1934
# Build Pattern Matcher
2035
javac --release $JDK_VER_TARGET -Xlint -d "$BIN_DIR/" \
@@ -34,20 +49,51 @@ javac --release $JDK_VER_TARGET -Xlint -d "$BIN_DIR/" \
3449

3550
# Build POC
3651
javac --release $JDK_VER_TARGET -Xlint -d "$BIN_DIR/" \
37-
src/coderarjob/kpdfsync/poc/*.java || exit
52+
src/coderarjob/kpdfsync/poc/*.java \
53+
src/coderarjob/kpdfsync/poc/pdffixes/*.java \
54+
|| exit
3855

56+
# -----------------------------------------------------------------------------
3957
# Copy resources
58+
# -----------------------------------------------------------------------------
59+
cp -r src/coderarjob/ajl/res $BIN_DIR/coderarjob/ajl || exit
60+
cp -r src/coderarjob/kpdfsync/lib/res $BIN_DIR/coderarjob/kpdfsync/lib || exit
4061
cp -r src/coderarjob/kpdfsync/poc/res $BIN_DIR/coderarjob/kpdfsync/poc || exit
4162

63+
# -----------------------------------------------------------------------------
64+
# Replace placeholder information in resource files.
65+
# -----------------------------------------------------------------------------
66+
buildid=$(date +%y%m%d)
67+
find $BIN_DIR -type f -name app.settings \
68+
-exec sed -i "s/<build>/$buildid/g" {} \;
69+
70+
command -v git > /dev/null && (
71+
path=coderarjob/ajl
72+
commitid=$(git log --format="%h" -n 1 src/$path)
73+
find $BIN_DIR/$path -type f -name app.settings \
74+
-exec sed -i "s/<commitid>/$commitid/g" {} \;
75+
76+
path=coderarjob/kpdfsync/lib
77+
commitid=$(git log --format="%h" -n 1 src/$path)
78+
find $BIN_DIR/$path -type f -name app.settings \
79+
-exec sed -i "s/<commitid>/$commitid/g" {} \;
80+
81+
path=coderarjob/kpdfsync/poc
82+
commitid=$(git log --format="%h" -n 1 src/$path)
83+
find $BIN_DIR/$path -type f -name app.settings \
84+
-exec sed -i "s/<commitid>/$commitid/g" {} \;
85+
) || exit
86+
87+
# -----------------------------------------------------------------------------
4288
# Generate tags file
43-
ctags --recurse ./src || exit
44-
45-
# Run
46-
GTKLOOK="com.sun.java.swing.plaf.gtk.GTKLookAndFeel"
47-
MOTIFLOOK="com.sun.java.swing.plaf.motif.MotifLookAndFeel"
48-
METALLOOK="javax.swing.plaf.metal.MetalLookAndFeel"
49-
WINLOOK="com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
50-
NIMBUSLLOOK="com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"
51-
LOOK=$METALLOOK
52-
#java -Dswing.defaultlaf=$LOOK \
53-
java coderarjob.kpdfsync.poc.Main
89+
# -----------------------------------------------------------------------------
90+
command -v ctags > /dev/null && (
91+
ctags --recurse ./src || exit
92+
)
93+
94+
# -----------------------------------------------------------------------------
95+
# Call pack.sh, to generate the jar files.
96+
# -----------------------------------------------------------------------------
97+
cd build
98+
./pack.sh
99+
cd -

build/Manifest.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Main-Class: coderarjob.kpdfsync.poc.Main
2+
Class-Path: pdfclown.jar ajl.jar libkpdfsync.jar

build/kpdfsync.bat

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
:: -----------------------------------------------------------------------------
2+
:: Windows Start script kpdfsync
3+
:: -----------------------------------------------------------------------------
4+
:: Changes directory to the application path and runs kpdfsync
5+
:: -----------------------------------------------------------------------------
6+
@echo off
7+
set BASEDIR=%~dp0
8+
start /D "%BASEDIR%\bin" /B java -jar kpdfsync.jar

build/kpdfsync.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# -----------------------------------------------------------------------------
3+
# Unix Start script kpdfsync
4+
# -----------------------------------------------------------------------------
5+
# Changes directory to the application path and runs kpdfsync
6+
# -----------------------------------------------------------------------------
7+
BASEDIR=$(dirname $0)
8+
cd "$BASEDIR/bin"
9+
java -jar kpdfsync.jar&

build/pack.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
# -----------------------------------------------------------------------------
3+
# Package creation script kpdfsync
4+
# -----------------------------------------------------------------------------
5+
# This script is responsible for packing all the java .class files,
6+
# dependencies and scripts and place them in correct places.
7+
#
8+
# This placement also ensures, that when distributed on different systems,
9+
# kpdfsync can be run using the two helper scripts, kpdfsync.sh and
10+
# kpdfsync.bat.
11+
# -----------------------------------------------------------------------------
12+
13+
echo :: Building packages
14+
15+
# -----------------------------------------------------------------------------
16+
# Create destination folder
17+
# -----------------------------------------------------------------------------
18+
DIST_DIR=kpdfsync
19+
rm -rf $DIST_DIR || exit
20+
mkdir -p $DIST_DIR/bin || exit
21+
22+
pushd classes
23+
24+
# -----------------------------------------------------------------------------
25+
# Create .jar files for individual packages.
26+
# -----------------------------------------------------------------------------
27+
28+
# Package Arjob's Java Library
29+
echo :: Building ajl.jar
30+
jar cf ajl.jar coderarjob/ajl || exit
31+
32+
# Package kpdfsync library
33+
echo :: Building libkpdfsync.jar
34+
jar cf libkpdfsync.jar coderarjob/kpdfsync/lib || exit
35+
36+
# Package kpdfsync gui
37+
echo :: Building kpdfsync.jar
38+
jar cfm kpdfsync.jar ../Manifest.txt coderarjob/kpdfsync/poc || exit
39+
popd
40+
41+
# -----------------------------------------------------------------------------
42+
# Move .jar files and scripts to proper places under the kpdfsync dist folder.
43+
# -----------------------------------------------------------------------------
44+
45+
# Move the jar files to kpdfsync/bin folder.
46+
mv classes/*.jar ./$DIST_DIR/bin || exit
47+
cp ../lib/pdfclown.jar ./$DIST_DIR/bin || exit
48+
cp -r ../tools ./$DIST_DIR/bin || exit
49+
50+
# Copy the kpdfsync.sh and kpdfsync.bat to kpdfsync dist folder.
51+
cp kpdfsync.sh ./$DIST_DIR || exit
52+
cp kpdfsync.bat ./$DIST_DIR || exit
53+
54+
# Copy LICENSE Readme.md and HowTo.pdf to kpdfsync dist folder.
55+
cp ../docs/QuickReference.pdf ./$DIST_DIR || exit
56+
cp ../README.md ./$DIST_DIR || exit
57+
cp ../LICENSE ./$DIST_DIR || exit
58+
59+
echo :: Building packages completed

docs/HowToSImplified.odt

490 KB
Binary file not shown.

docs/images/screenshot_alpha.png

-8.17 KB
Loading

0 commit comments

Comments
 (0)