Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Use Unicode on PDFObject.s for CJK metadata #89

Merged
merged 1 commit into from

4 participants

@kirisetsz

As a Chinese user,
I want Use Unicode to store PDF metadata,
So that I can read a Chinese Title&Author...

Not so familiar with coffeescript re-organize may be required

@kirisetsz kirisetsz Use Unicode on PDFObject.s for CJK metadata
As a Chinese user,
I want Use Unicode to store PDF metadata,
So that I can read a Chinese Title&Author...

Not so familiar with coffeescript re-organize may be required
05b25cf
@disfated

+1 Works for cyrillic perfectly

@ruvasik

+1

@devongovett devongovett merged commit 57e50f3 into devongovett:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 29, 2012
  1. @kirisetsz

    Use Unicode on PDFObject.s for CJK metadata

    kirisetsz authored
    As a Chinese user,
    I want Use Unicode to store PDF metadata,
    So that I can read a Chinese Title&Author...
    
    Not so familiar with coffeescript re-organize may be required
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/object.coffee
View
14 lib/object.coffee
@@ -42,6 +42,20 @@ class PDFObject
'' + object
@s: (string) ->
+
+ # Convert Big-endian UCS-2 to Little-endian to support most PDFRreaders
+ swapBytes = (buff) ->
+ l = buff.length
+ if l & 0x01
+ throw new Error("Buffer length must be even")
+ else
+ for i in [0...l - 1] by 2
+ a = buff[i]
+ buff[i] = buff[i+1]
+ buff[i+1] = a
+ buff
+ string = swapBytes(new Buffer('\ufeff' + string, 'ucs-2')).toString('binary')
+
string = string.replace(/\\/g, '\\\\\\\\')
.replace(/\(/g, '\\(')
.replace(/\)/g, '\\)')
Something went wrong with that request. Please try again.