Skip to content

Commit

Permalink
Merge pull request #347 from tibor-mirnic/master
Browse files Browse the repository at this point in the history
support for non-latin characters
  • Loading branch information
VadimDez authored Jul 13, 2018
2 parents 35959f9 + 5ff489b commit a9ec56f
Show file tree
Hide file tree
Showing 171 changed files with 83 additions and 1 deletion.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ npm install ng2-pdf-viewer --save
*Note: For angular 4 or less use version `3.0.8`*


## Support for non-latin characters

For this feature to work you need to copy ```node_modules/pdfjs-dist/cmaps``` to ```assets/cmaps```.

## Usage

In case you're using ```systemjs``` see configuration [here](https://github.com/VadimDez/ng2-pdf-viewer/blob/master/SYSTEMJS.md).
Expand Down Expand Up @@ -103,6 +107,7 @@ export class AppComponent {
## Options

* [[src]](#src)
* [[c-maps-url]](#c-maps-url)
* [[(page)]](#page)
* [[stick-to-page]](#stick-to-page)
* [[external-link-target]](#external-link-target)
Expand Down Expand Up @@ -143,6 +148,16 @@ Options object for loading protected PDF would be

See more attributes [here](https://github.com/mozilla/pdf.js/blob/master/src/display/api.js#L107-L186).

#### [c-maps-url]

| Property | Type | Required |
| --- | ---- | --- |
| [c-maps-url] | *string* | Optional |

Url for non-latin characters source maps
```
[c-maps-url]="'assets/cmaps/'"
```

#### [page]

Expand Down
23 changes: 22 additions & 1 deletion src/app/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class PdfViewerComponent implements OnChanges, OnInit, OnDestroy {
public pdfViewer: any;
public pdfFindController: any;

private _cMapsUrl: string = 'assets/cmaps/';
private _renderText: boolean = true;
private _stickToPage: boolean = false;
private _originalSize: boolean = true;
Expand Down Expand Up @@ -117,6 +118,11 @@ export class PdfViewerComponent implements OnChanges, OnInit, OnDestroy {
@Input()
src: string | Uint8Array | PDFSource;

@Input('c-maps-url')
set cMapsUrl(cMapsUrl: string) {
this._cMapsUrl = cMapsUrl;
}

@Input('page')
set page(_page) {
_page = parseInt(_page, 10) || 1;
Expand Down Expand Up @@ -275,7 +281,22 @@ export class PdfViewerComponent implements OnChanges, OnInit, OnDestroy {
return;
}

let loadingTask: any = (PDFJS as any).getDocument(this.src as any);
let params: any = {
cMapUrl: this._cMapsUrl,
cMapPacked: true
};

if (typeof(this.src) === 'string') {
params.url = this.src;
}
else if (typeof(this.src) === 'object' && (this.src as any).byteLength !== undefined) {
params.data = this.src;
}
else if (typeof(this.src) === 'object') {
Object.assign(params, this.src);
}

let loadingTask: any = (PDFJS as any).getDocument(params);

loadingTask.onProgress = (progressData: PDFProgressData) => {
this.onProgress.emit(progressData);
Expand Down
Binary file added src/assets/cmaps/78-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78ms-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/78ms-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/83pv-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90ms-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90ms-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90msp-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90msp-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90pv-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/90pv-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Add-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Add-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Add-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Add-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-0.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-1.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-3.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-4.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-5.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-6.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-CNS1-UCS2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-0.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-1.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-3.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-4.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-5.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-GB1-UCS2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-0.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-1.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-3.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-4.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-5.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-6.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Japan1-UCS2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Korea1-0.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Korea1-1.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Korea1-2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Adobe-Korea1-UCS2.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/B5pc-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/B5pc-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/CNS-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/CNS-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/CNS1-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/CNS1-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/CNS2-H.bcmap
Binary file not shown.
3 changes: 3 additions & 0 deletions src/assets/cmaps/CNS2-V.bcmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
�RCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSE�CNS2-H
Binary file added src/assets/cmaps/ETHK-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/ETHK-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/ETen-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/ETen-B5-V.bcmap
Binary file not shown.
3 changes: 3 additions & 0 deletions src/assets/cmaps/ETenms-B5-H.bcmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
�RCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSE� ETen-B5-H` ^
Binary file added src/assets/cmaps/ETenms-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Ext-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Ext-RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Ext-RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Ext-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GB-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GB-EUC-V.bcmap
Binary file not shown.
4 changes: 4 additions & 0 deletions src/assets/cmaps/GB-H.bcmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
�RCopyright 1990-2009 Adobe Systems Incorporated.
All rights reserved.
See ./LICENSE!!��]aX!!]`�21�> �p �z�$]��"R�d�-U�7�*�4�%�+ �Z �{�/�%�<�9K�b�1]�.�"� �`]�,�"]�
�"]�h�"]�F�"]�$�"]��"]�`�"]�>�"]��"]�z�"]�X�"]�6�"]��"]�r�"]�P�"]�.�"]� �"]�j�"]�H�"]�&�"]��"]�b�"]�@�"]��"]�|�"]�Z�"]�8�"]��"]�t�"]�R�"]�0�"]��"]�l�"]�J�"]�(�"]��"]�d�"]�B�"]� �"X�~�']�W�"]�5�"]��"]�q�"]�O�"]�-�"]� �"]�i�"]�G�"]�%�"]��"]�a�"]�?�"]��"]�{�"]�Y�"]�7�"]��"]�s�"]�Q�"]�/�"]��"]�k�"]�I�"]�'�"]��"]�c�"]�A�"]��"]�}�"]�[�"]�9
Expand Down
Binary file added src/assets/cmaps/GB-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBK-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBK-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBK2K-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBK2K-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBKp-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBKp-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBT-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBT-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBT-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBT-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBTpc-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBTpc-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBpc-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/GBpc-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKdla-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKdla-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKdlb-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKdlb-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKgccs-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKgccs-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKm314-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKm314-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKm471-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKm471-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKscs-B5-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/HKscs-B5-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Hankaku.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Hiragana.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-Johab-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-Johab-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCms-UHC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCms-UHC-HW-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCms-UHC-HW-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCms-UHC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCpc-EUC-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/KSCpc-EUC-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Katakana.bcmap
Binary file not shown.
36 changes: 36 additions & 0 deletions src/assets/cmaps/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
%%Copyright: -----------------------------------------------------------
%%Copyright: Copyright 1990-2009 Adobe Systems Incorporated.
%%Copyright: All rights reserved.
%%Copyright:
%%Copyright: Redistribution and use in source and binary forms, with or
%%Copyright: without modification, are permitted provided that the
%%Copyright: following conditions are met:
%%Copyright:
%%Copyright: Redistributions of source code must retain the above
%%Copyright: copyright notice, this list of conditions and the following
%%Copyright: disclaimer.
%%Copyright:
%%Copyright: Redistributions in binary form must reproduce the above
%%Copyright: copyright notice, this list of conditions and the following
%%Copyright: disclaimer in the documentation and/or other materials
%%Copyright: provided with the distribution.
%%Copyright:
%%Copyright: Neither the name of Adobe Systems Incorporated nor the names
%%Copyright: of its contributors may be used to endorse or promote
%%Copyright: products derived from this software without specific prior
%%Copyright: written permission.
%%Copyright:
%%Copyright: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
%%Copyright: CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
%%Copyright: INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
%%Copyright: MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
%%Copyright: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
%%Copyright: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
%%Copyright: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
%%Copyright: NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
%%Copyright: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
%%Copyright: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
%%Copyright: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
%%Copyright: OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
%%Copyright: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
%%Copyright: -----------------------------------------------------------
Binary file added src/assets/cmaps/NWP-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/NWP-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/RKSJ-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/RKSJ-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/Roman.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UCS2-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UCS2-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF16-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF16-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF8-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniCNS-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UCS2-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UCS2-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF16-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF16-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF8-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniGB-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UCS2-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UCS2-HW-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UCS2-HW-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UCS2-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF16-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF16-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF8-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF16-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF16-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF8-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJIS2004-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISPro-UCS2-HW-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISPro-UCS2-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISPro-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISX0213-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISX0213-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISX02132004-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniJISX02132004-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UCS2-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UCS2-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF16-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF16-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF32-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF32-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF8-H.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/UniKS-UTF8-V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/V.bcmap
Binary file not shown.
Binary file added src/assets/cmaps/WP-Symbol.bcmap
Binary file not shown.

0 comments on commit a9ec56f

Please sign in to comment.