156 Commits

Author SHA1 Message Date
Devon Govett
33920c3f2a Merge pull request #301 from ef4/center-spacing
Fix center-aligned character spacing
2014-09-11 19:51:10 -04:00
Edward Faulkner
3e19194802 Fix center-aligned character spacing 2014-09-11 16:09:54 -04:00
Edward Faulkner
5b433d808a fix indent with continued 2014-09-11 13:34:51 -04:00
Devon Govett
09ed15b2e4 Fix unicode annotations 2014-08-29 11:49:20 -04:00
Devon Govett
3418299ac7 Merge pull request #277 from mishoo/fix-reading-uint32
Fix reading UInt32
2014-08-16 09:52:56 -04:00
Mihai Bazon
b60fe860e0 Fix reading UInt32
In JS, 0x80 << 24 yields a negative result.  Also, 0x80000000|0 < 0.
Bitwise ops should be avoided for very long unsigned ints.
2014-08-16 11:57:54 +03:00
Mihai Bazon
e61366b37f Fix reading cmap table
The data offset must be saved before parsing one entry and restored
thereafter.  Otherwise only the first table is parsed properly, and garbage
is returned for the rest.  Fails on i.e. georgiai.ttf.

When reading the glyphIds, divide count by 2 (we read 16-bit words).
2014-08-16 11:50:52 +03:00
Devon Govett
1241997715 Refactor font loading code and add support for ArrayBuffers 2014-07-29 09:42:48 -07:00
Aaron Fischer
c2c61bb2e2 added support for add font as Uint8Array 2014-07-29 09:15:39 -07:00
Devon Govett
e58a7ce809 Formatting 2014-07-14 20:48:00 -07:00
jkol
64df00fa13 Added "valign" option to image "fit" scaling
valign can be set to "center" or "bottom" now and when "valign" === "center" is combined with "align" === "center" any aspect ratio image can be centered into a bounding area.
2014-07-14 18:23:11 -05:00
Ryan Wersal
c77add8f56 Remove text state handling as it doesn't surive graphic stack saves/restores
Saving and/or restoring the graphics state causes each text object to have to
reinitialize that text state. As a result, the mode/characterSpacing commands
would not get re-added until their value(s) had changed.
2014-05-10 01:11:06 -05:00
Ryan Wersal
aadc589a62 Improve sizing of text underline 2014-05-09 00:05:17 -05:00
Ryan Wersal
acc0a2e4ba Use a regex to capture the base64 encoded string 2014-05-06 00:43:02 -05:00
Ryan Wersal
2b34173dec Add ability to add base64 URI images 2014-05-05 22:47:33 -05:00
Devon Govett
a6f6f4df8a Don't use trimRight since it isn't supported in IE 2014-04-14 09:58:26 -07:00
Devon Govett
6e447cae7a Don't embed fonts that haven't been referenced 2014-04-13 19:54:18 -07:00
Devon Govett
22499ee4bd Include a static list of standard fonts so they can be included by browserify/brfs 2014-04-12 20:48:29 -07:00
Devon Govett
78946e97fc Rework mixin so it can be statically compiled by browserify 2014-04-12 20:47:54 -07:00
Devon Govett
98489d64a8 Store the font name 2014-04-12 20:45:42 -07:00
Devon Govett
4b8b031188 Don't embed fonts until they are actually used 2014-04-12 20:45:15 -07:00
Devon Govett
bb9b77cb82 Allow loading fonts from Buffers in addition to filenames 2014-04-12 20:44:19 -07:00
Devon Govett
801981728c Make AFMFont.open different from constructor 2014-04-12 20:35:14 -07:00
Devon Govett
8c51ee077f Make sure that sfnt key exists in dfont so we don't throw random errors 2014-04-09 23:44:31 -07:00
Devon Govett
f463512b2f Don't embed fonts more than once 2014-04-09 23:41:40 -07:00
Devon Govett
87fd69b7e5 Don't overwrite cmap method 2014-04-09 23:41:06 -07:00
Devon Govett
ae28782eb1 Fix writing indexed PNG palettes 2014-04-09 09:51:59 -07:00
Devon Govett
876db9e067 Don't set the Length key on images. It will be set by the PDFReference class automatically 2014-04-09 09:51:43 -07:00
Devon Govett
665fd935ef Make loading images from buffers way faster by not converting to a string inadvertently 2014-04-06 19:19:17 -07:00
Devon Govett
8eece7e9ea Make sure heightOfString doesn't break pages 2014-03-29 20:36:10 -07:00
Devon Govett
c72b50927c Add heightOfString method that uses the line wrapper without actually adding content to the document.
Very useful for layout purposes
2014-03-29 20:22:21 -07:00
Devon Govett
cf564ac3da Fixes for text justification 2014-03-29 19:56:36 -07:00
Devon Govett
16e00aa9e2 Allow setting compress option from constructor 2014-03-29 19:45:41 -07:00
Devon Govett
0907968905 Don't store all objects in memory, just offsets once they are written 2014-03-23 18:16:42 -07:00
Devon Govett
f6c4b2c226 Free memory after embedding images 2014-03-23 17:37:13 -07:00
Devon Govett
b570ac219e Simplify image loading 2014-03-23 17:31:07 -07:00
Devon Govett
f8a40dba76 Make PDFDocument a node stream 2014-03-23 17:11:48 -07:00
Devon Govett
1305a9592a Switch to 2 space indentation 2014-03-23 12:25:09 -07:00
Devon Govett
fda5b400e6 Another path parser fix 2014-02-25 00:42:25 -08:00
Devon Govett
06e6419533 Handle reused commands in path parser for last command 2014-02-25 00:08:41 -08:00
Devon Govett
67e6640b92 Fix bug in path parser 2014-02-24 23:44:50 -08:00
Devon Govett
350863bfda Fix the ellipse method 2014-02-24 23:25:41 -08:00
Devon Govett
c1319acff8 Allow 0 opacities 2014-02-24 01:09:27 -08:00
Devon Govett
4257e69e07 Fix typo 2014-02-19 12:02:57 -08:00
Devon Govett
8139b4fa30 Add missing word count 2014-02-19 12:02:53 -08:00
Darius Kazemi
d7336a4bd0 "Dangling" single word lines now get emitted
This commit adds an extra emit to a required line break if there's a "dangling" word on the end.
2014-02-19 14:54:47 -05:00
Darius Kazemi
6637dca8eb Correcting for edge case in line wrapping
If you look at the flow of the `eachWord` function, you'll notice that we add the word to the buffer if the width of the word `w` is less than the space available.

There's an edge case where `linebreaker` says that a line break is required on a word (because of a manual break: `theword\n`) and the width of the word being considered is greater than `spaceLeft`. In the current pdfkit, if this is the case:

 * we do not append the word to the buffer
 * we emit the line
 * we break and move on to the next line, starting with a clean line

This omits the word entirely.

This commit makes it so that we only break the line and start with a clean line if we already had the space to write the line to the buffer. Otherwise, we append the word to the buffer and go to a new line.
2014-02-19 13:38:50 -05:00
Devon Govett
a0901c75a0 Make sure we use global.setImmediate 2014-02-17 23:20:32 -08:00
Devon Govett
cb81273b49 Trim spaces from the ends of lines when right aligning 2014-02-17 22:02:55 -08:00
Devon Govett
18512661b5 Apply current transformation to annotations 2014-02-17 22:01:49 -08:00