Skip to content

Commit

Permalink
Initial reduction and conversion to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Macsadi committed Jun 23, 2015
1 parent 018bde8 commit e31cf9f
Show file tree
Hide file tree
Showing 243 changed files with 239 additions and 488,309 deletions.
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
PdfBox-Android
pdfbox-android-lite
==============

A port of Apache's PdfBox library to be usable on Android. Most features should be implemented by now. If you find any issues or want to request a feature that you need for your project, please use the issue tracker. Stable releases can be added as a Gradle by declaring ``` org.apache:pdfbox-android:1.8.9.0 ``` as a dependency with jcenter set as a repository. The latest releases can be built by cloning the repo and running Gradle. The tasks for building are set as default, so running ```gradlew.bat``` or ```./gradlew``` will take care of all necessary tasks.
A lightweight port of Apache's PdfBox library to be usable on Android.
This implementation is forked from the PdfBox-Android project.

The main code of this project is licensed under the Apache 2.0 License, found at http://www.apache.org/licenses/LICENSE-2.0.html Code released under other licenses will be stated in the header.

#### Important notes:

-Based on PdfBox v1.8.9
It's main goal is to reduce the size
of the library. Therefore I've removed the PDF encryption and security support as well as some unused resources.
The size of the library is reduced from approximately 7.4MB to almost 1.1MB.

-This is still a work in progress

-Unavailable classes, such as awt, are replaced with their closest Android approximation

#### Libraries:
SpongyCastle core, prov, and pkiv: https://github.com/rtyley/spongycastle/
The main code of this project is licensed under the Apache 2.0 License, found at http://www.apache.org/licenses/LICENSE-2.0.html Code released under other licenses will be stated in the header.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ VERSION_CODE=1

ANDROID_BUILD_MIN_SDK_VERSION=9
ANDROID_BUILD_TARGET_SDK_VERSION=21
ANDROID_BUILD_SDK_VERSION=21
ANDROID_BUILD_SDK_VERSION=15
ANDROID_BUILD_TOOLS_VERSION=21.1.2
8 changes: 3 additions & 5 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ apply plugin: 'com.android.library'

ext {
PUBLISH_GROUP_ID = 'org.apache'
PUBLISH_ARTIFACT_ID = 'pdfbox-android'
PUBLISH_ARTIFACT_ID = 'pdfbox-android-lite'
PUBLISH_VERSION = VERSION_NAME
}

android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
compileOptions.encoding = 'windows-1251'
compileOptions.encoding = 'UTF-8'

defaultConfig {
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
Expand All @@ -30,9 +30,7 @@ android {
}

dependencies {
compile 'com.madgag.spongycastle:core:1.51.0.0'
compile 'com.madgag.spongycastle:pkix:1.51.0.0'
compile 'com.madgag.spongycastle:prov:1.51.0.0'

}

//apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
Expand Down
4 changes: 2 additions & 2 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
android:versionName="1.0" >

<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="21" />
android:minSdkVersion="15"
android:targetSdkVersion="15" />

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
%!PS-Adobe-3.0 Resource-CMap
%%DocumentNeededResources: ProcSet (CIDInit)
%%IncludeResource: ProcSet (CIDInit)
%%BeginResource: CMap (Identity)
%%Title: (Identity Adobe GB1 5)
%%Version: 1.002
%%BeginResource: CMap (Identity-H)
%%Title: (Identity-H Adobe Identity 0)
%%Version: 10.003
%%Copyright: -----------------------------------------------------------
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
%%Copyright: All rights reserved.
Expand Down Expand Up @@ -50,22 +50,20 @@ begincmap

/CIDSystemInfo 3 dict dup begin
/Registry (Adobe) def
/Ordering (GB1) def
/Supplement 5 def
/Ordering (Identity) def
/Supplement 0 def
end def

/CMapName /Adobe-GB1-5 def
/CMapVersion 1.002 def
/CMapName /Identity-H def
/CMapVersion 10.003 def
/CMapType 1 def

/XUID [1 10 25605] def
/XUID [1 10 25404 9999] def

/WMode 0 def

/CIDCount 30284 def

1 begincodespacerange
<0000> <76FF>
<0000> <FFFF>
endcodespacerange

100 begincidrange
Expand Down Expand Up @@ -171,7 +169,7 @@ endcodespacerange
<6300> <63ff> 25344
endcidrange

19 begincidrange
100 begincidrange
<6400> <64ff> 25600
<6500> <65ff> 25856
<6600> <66ff> 26112
Expand All @@ -190,10 +188,149 @@ endcidrange
<7300> <73ff> 29440
<7400> <74ff> 29696
<7500> <75ff> 29952
<7600> <764b> 30208
<7600> <76ff> 30208
<7700> <77ff> 30464
<7800> <78ff> 30720
<7900> <79ff> 30976
<7a00> <7aff> 31232
<7b00> <7bff> 31488
<7c00> <7cff> 31744
<7d00> <7dff> 32000
<7e00> <7eff> 32256
<7f00> <7fff> 32512
<8000> <80ff> 32768
<8100> <81ff> 33024
<8200> <82ff> 33280
<8300> <83ff> 33536
<8400> <84ff> 33792
<8500> <85ff> 34048
<8600> <86ff> 34304
<8700> <87ff> 34560
<8800> <88ff> 34816
<8900> <89ff> 35072
<8a00> <8aff> 35328
<8b00> <8bff> 35584
<8c00> <8cff> 35840
<8d00> <8dff> 36096
<8e00> <8eff> 36352
<8f00> <8fff> 36608
<9000> <90ff> 36864
<9100> <91ff> 37120
<9200> <92ff> 37376
<9300> <93ff> 37632
<9400> <94ff> 37888
<9500> <95ff> 38144
<9600> <96ff> 38400
<9700> <97ff> 38656
<9800> <98ff> 38912
<9900> <99ff> 39168
<9a00> <9aff> 39424
<9b00> <9bff> 39680
<9c00> <9cff> 39936
<9d00> <9dff> 40192
<9e00> <9eff> 40448
<9f00> <9fff> 40704
<a000> <a0ff> 40960
<a100> <a1ff> 41216
<a200> <a2ff> 41472
<a300> <a3ff> 41728
<a400> <a4ff> 41984
<a500> <a5ff> 42240
<a600> <a6ff> 42496
<a700> <a7ff> 42752
<a800> <a8ff> 43008
<a900> <a9ff> 43264
<aa00> <aaff> 43520
<ab00> <abff> 43776
<ac00> <acff> 44032
<ad00> <adff> 44288
<ae00> <aeff> 44544
<af00> <afff> 44800
<b000> <b0ff> 45056
<b100> <b1ff> 45312
<b200> <b2ff> 45568
<b300> <b3ff> 45824
<b400> <b4ff> 46080
<b500> <b5ff> 46336
<b600> <b6ff> 46592
<b700> <b7ff> 46848
<b800> <b8ff> 47104
<b900> <b9ff> 47360
<ba00> <baff> 47616
<bb00> <bbff> 47872
<bc00> <bcff> 48128
<bd00> <bdff> 48384
<be00> <beff> 48640
<bf00> <bfff> 48896
<c000> <c0ff> 49152
<c100> <c1ff> 49408
<c200> <c2ff> 49664
<c300> <c3ff> 49920
<c400> <c4ff> 50176
<c500> <c5ff> 50432
<c600> <c6ff> 50688
<c700> <c7ff> 50944
endcidrange
endcmap

56 begincidrange
<c800> <c8ff> 51200
<c900> <c9ff> 51456
<ca00> <caff> 51712
<cb00> <cbff> 51968
<cc00> <ccff> 52224
<cd00> <cdff> 52480
<ce00> <ceff> 52736
<cf00> <cfff> 52992
<d000> <d0ff> 53248
<d100> <d1ff> 53504
<d200> <d2ff> 53760
<d300> <d3ff> 54016
<d400> <d4ff> 54272
<d500> <d5ff> 54528
<d600> <d6ff> 54784
<d700> <d7ff> 55040
<d800> <d8ff> 55296
<d900> <d9ff> 55552
<da00> <daff> 55808
<db00> <dbff> 56064
<dc00> <dcff> 56320
<dd00> <ddff> 56576
<de00> <deff> 56832
<df00> <dfff> 57088
<e000> <e0ff> 57344
<e100> <e1ff> 57600
<e200> <e2ff> 57856
<e300> <e3ff> 58112
<e400> <e4ff> 58368
<e500> <e5ff> 58624
<e600> <e6ff> 58880
<e700> <e7ff> 59136
<e800> <e8ff> 59392
<e900> <e9ff> 59648
<ea00> <eaff> 59904
<eb00> <ebff> 60160
<ec00> <ecff> 60416
<ed00> <edff> 60672
<ee00> <eeff> 60928
<ef00> <efff> 61184
<f000> <f0ff> 61440
<f100> <f1ff> 61696
<f200> <f2ff> 61952
<f300> <f3ff> 62208
<f400> <f4ff> 62464
<f500> <f5ff> 62720
<f600> <f6ff> 62976
<f700> <f7ff> 63232
<f800> <f8ff> 63488
<f900> <f9ff> 63744
<fa00> <faff> 64000
<fb00> <fbff> 64256
<fc00> <fcff> 64512
<fd00> <fdff> 64768
<fe00> <feff> 65024
<ff00> <ffff> 65280
endcidrange
endcmap
CMapName currentdict /CMap defineresource pop
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ protected String[] getSearchableDirectories()
};
}

/**
* {@inheritDoc}
*/
public Map<String, String> getCommonTTFMapping()
{
HashMap<String,String> map = new HashMap<String,String>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ protected void processAnnotation(PDAnnotation annotation, PDAppearanceStream app
a.concatenate(Matrix.getTranslateInstance((float) -transformedBox.left,
(float) -transformedBox.top));

// Matrix shall be concatenated with A to form a matrix AA that maps from the appearance’s
// coordinate system to the annotation’s rectangle in default user space
// Matrix shall be concatenated with A to form a matrix AA that maps from the appearance's
// coordinate system to the annotation's rectangle in default user space
Matrix aa = Matrix.concatenate(matrix, a);

// make matrix AA the CTM
Expand Down
14 changes: 0 additions & 14 deletions library/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.pdfbox.cos.COSStream;
import org.apache.pdfbox.io.IOUtils;
import org.apache.pdfbox.pdfparser.XrefTrailerResolver.XRefType;
import org.apache.pdfbox.pdmodel.encryption.SecurityHandler;

import android.util.Log;

Expand Down Expand Up @@ -110,11 +109,6 @@ public class COSParser extends BaseParser
private List<Long> bfSearchXRefTablesOffsets = null;
private List<Long> bfSearchXRefStreamsOffsets = null;

/**
* The security handler.
*/
protected SecurityHandler securityHandler = null;

/**
* how many trailing bytes to read for EOF marker
*/
Expand Down Expand Up @@ -705,10 +699,6 @@ else if (offsetOrObjstmObNr > 0)
{
COSStream stream = parseCOSStream((COSDictionary) pb);

if (securityHandler != null)
{
securityHandler.decryptStream(stream, objNr, objGenNr);
}
pb = stream;
}
else
Expand All @@ -734,10 +724,6 @@ else if (offsetOrObjstmObNr > 0)
}
}
}
else if (securityHandler != null)
{
securityHandler.decrypt(pb, objNr, objGenNr);
}

pdfObject.setObject(pb);

Expand Down
Loading

0 comments on commit e31cf9f

Please sign in to comment.