pdf-writer 1.1.7 → 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -17,7 +17,7 @@ Please read the file LICENCE for licensing restrictions on this library, as
17
17
  well as important patent considerations.
18
18
 
19
19
  == Requirements
20
- PDF::Writer requires Ruby 1.8.2 or better, color-tools 1.3.0 or better, and
20
+ PDF::Writer requires Ruby 1.8.2 or better, Color 1.4.0 or better, and
21
21
  Transaction::Simple 1.3.0 or better.
22
22
 
23
23
  #--
@@ -28,6 +28,6 @@ Transaction::Simple 1.3.0 or better.
28
28
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
29
29
  # for full licensing information.
30
30
  #
31
- # $Id: README 153 2007-02-07 02:28:41Z austin $
31
+ # $Id: README 196 2008-01-04 23:15:50Z sandal $
32
32
  #++
33
33
  # vim: sts=2 sw=2 ts=4 et ai tw=77
@@ -6,7 +6,7 @@
6
6
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
7
  # for full licensing information.
8
8
  #
9
- # $Id: writer.rb 194 2007-12-13 18:19:02Z sandal $
9
+ # $Id: writer.rb 202 2008-03-16 23:30:11Z sandal $
10
10
  #++
11
11
  require 'thread'
12
12
  require 'open-uri'
@@ -19,7 +19,7 @@ require 'color'
19
19
  module PDF
20
20
  class Writer
21
21
  # The version of PDF::Writer.
22
- VERSION = '1.1.7'
22
+ VERSION = '1.1.8'
23
23
 
24
24
  # Escape the text so that it's safe for insertion into the PDF
25
25
  # document.
@@ -800,7 +800,7 @@ class PDF::Writer
800
800
  break if fontfile
801
801
  end
802
802
  end
803
-
803
+
804
804
  if font =~ /afm/o and fontfile
805
805
  # Find the array of font widths, and put that into an object.
806
806
  first_char = -1
@@ -823,10 +823,12 @@ class PDF::Writer
823
823
  encoding_diff.each do |cnum, cname|
824
824
  (cnum - last_char).times { widths << 0 } if cnum > last_char
825
825
  last_char = cnum
826
- widths[cnum - firstchar] = fonts.c[cname]['WX'] if metrics.c[cname]
826
+ widths[cnum - first_char] = metrics.c[cname]['WX'] if metrics.c[cname]
827
827
  end
828
828
  end
829
829
 
830
+ raise RuntimeError, 'Font metrics file (.afm) invalid - no charcters described' if first_char == -1 and last_char == 0
831
+
830
832
  widthid = PDF::Writer::Object::Contents.new(self, :raw)
831
833
  widthid << "["
832
834
  (first_char .. last_char).each do |ii|
@@ -841,38 +843,7 @@ class PDF::Writer
841
843
  # Load the pfb file, and put that into an object too. Note that PDF
842
844
  # supports only binary format Type1 font files and TrueType font
843
845
  # files. There is a simple utility to convert Type1 from pfa to pfb.
844
- data = File.open(fbfile, "rb") { |ff| ff.read }
845
-
846
- # Check to see if the font licence allows embedding.
847
- if fbtype =~ /\.ttf$/o
848
- offset = 4
849
- tables = data[offset, 2].unpack('n')[0]
850
- offset += 8
851
-
852
- found = false
853
- tables.times do
854
- if data[offset, 4] == 'OS/2'
855
- found = true
856
- break
857
- end
858
- offset += 4 + 12
859
- end
860
-
861
- if found
862
- offset += 4
863
- newoff = data[offset, 4].unpack('N')[0]
864
- offset = newoff + 8
865
- licence = data[offset, 2].unpack('n')[0]
866
-
867
- rl = ((licence & 0x02) != 0)
868
- pp = ((licence & 0x04) != 0)
869
- ee = ((licence & 0x08) != 0)
870
-
871
- if rl and pp and ee
872
- warn PDF::Writer::Lang[:ttf_licence_no_embedding] % name
873
- end
874
- end
875
- end
846
+ data = File.open(fontfile, "rb") { |ff| ff.read }
876
847
 
877
848
  # Create the font descriptor.
878
849
  fdsc = PDF::Writer::Object::FontDescriptor.new(self)
@@ -938,13 +909,13 @@ class PDF::Writer
938
909
  end
939
910
 
940
911
  # Determine the cruicial lengths within this file
941
- if fbtype =~ /\.pfb$/o
912
+ if fontfile =~ /\.pfb$/o
942
913
  fdopt['FontFile'] = pfbc.oid
943
914
  i1 = data.index('eexec') + 6
944
915
  i2 = data.index('00000000') - i1
945
916
  i3 = data.size - i2 - i1
946
917
  pfbc.add('Length1' => i1, 'Length2' => i2, 'Length3' => i3)
947
- elsif fbtype =~ /\.ttf$/o
918
+ elsif fontfile =~ /\.ttf$/o
948
919
  fdopt['FontFile2'] = pfbc.oid
949
920
  pfbc.add('Length1' => data.size)
950
921
  end
@@ -961,7 +932,7 @@ class PDF::Writer
961
932
  'LastChar' => last_char,
962
933
  'FontDescriptor' => fdsc.oid
963
934
  }
964
- tmp['SubType'] = 'TrueType' if fbtype == "ttf"
935
+ tmp['SubType'] = 'TrueType' if fontfile =~ /\.ttf/
965
936
 
966
937
  tmp.each { |kk, vv| wfo.__send__("#{kk.downcase}=".intern, vv) }
967
938
  end
@@ -2240,7 +2211,7 @@ class PDF::Writer
2240
2211
  end
2241
2212
  private :page_number_search
2242
2213
 
2243
- def add_page_numbers
2214
+ def add_page_numbers
2244
2215
  # This will go through the @page_numbering array and add the page
2245
2216
  # numbers are required.
2246
2217
  if @page_numbering
@@ -2252,14 +2223,14 @@ class PDF::Writer
2252
2223
  # First, find the total pages for this schemes.
2253
2224
  page = page_number_search(:stop_total, scheme)
2254
2225
 
2255
- if page
2226
+ if page
2256
2227
  total_pages = page
2257
2228
  else
2258
2229
  page = page_number_search(:stop_total_next, scheme)
2259
- if page
2230
+ if page
2260
2231
  total_pages = page
2261
- else
2262
- total_pages = page_count
2232
+ else
2233
+ total_pages = page_count - 1
2263
2234
  end
2264
2235
  end
2265
2236
 
@@ -6,7 +6,7 @@
6
6
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
7
  # for full licensing information.
8
8
  #
9
- # $Id: font.rb 101 2005-06-28 21:32:17Z austin $
9
+ # $Id: font.rb 198 2008-03-03 15:26:31Z jh $
10
10
  #++
11
11
  # An object to hold the font description
12
12
  class PDF::Writer::Object::Font < PDF::Writer::Object
@@ -42,11 +42,15 @@ class PDF::Writer::Object::Font < PDF::Writer::Object
42
42
  # Valid values: WinAnsiEncoding, MacRomanEncoding, MacExpertEncoding,
43
43
  # none, +nil+, or an instance of PDF::Writer::Object::FontEncoding.
44
44
  attr_reader :encoding
45
- attr_reader :basefont
45
+
46
46
  def basefont #:nodoc:
47
47
  @name
48
48
  end
49
49
 
50
+ def basefont=(val) #:nodoc:
51
+ @name = val
52
+ end
53
+
50
54
  Details.each do |d|
51
55
  attr_accessor d.downcase.intern
52
56
  end
@@ -6,7 +6,7 @@
6
6
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
7
7
  # for full licensing information.
8
8
  #
9
- # $Id: fontdescriptor.rb 50 2005-05-16 03:59:21Z austin $
9
+ # $Id: fontdescriptor.rb 198 2008-03-03 15:26:31Z jh $
10
10
  #++
11
11
  # A font descriptor, needed for including additional fonts. +options+ is a
12
12
  # Hash with one of the following keys: Ascent, CapHeight, Descent, Flags,
@@ -29,6 +29,6 @@ class PDF::Writer::Object::FontDescriptor < PDF::Writer::Object
29
29
  res << "/#{k} [#{v.join(' ')}]\n" if k == "FontBBox"
30
30
  res << "/#{k} /#{v}\n" if k == "FontName"
31
31
  end
32
- res << "\n>>\nendobj"
32
+ res << ">>\nendobj"
33
33
  end
34
34
  end
data/manual.pwd CHANGED
@@ -2889,7 +2889,7 @@ the binary contents of a PNG or JPEG file <i>or</i> it must be a PDF image
2889
2889
  that has previously been inserted by one of the image insertion methods
2890
2890
  (including this one).
2891
2891
 
2892
- The loaded image will be placed with its <i>upper left-hand corner</i> at
2892
+ The loaded image will be placed with its <i>lower left-hand corner</i> at
2893
2893
  <b>(x, y)</b> on the current page. The size of the image will be determined
2894
2894
  by the <b>width</b> and <b>height</b> parameters. If neither width nor height
2895
2895
  are provided, the image will be inserted at its �natural� size.
@@ -5960,6 +5960,6 @@ pdf.stop_page_numbering(true, :current)
5960
5960
  # Licensed under a MIT-style licence. See LICENCE in the main distribution
5961
5961
  # for full licensing information.
5962
5962
  #
5963
- # $Id: manual.pwd 153 2007-02-07 02:28:41Z austin $
5963
+ # $Id: manual.pwd 196 2008-01-04 23:15:50Z sandal $
5964
5964
  # vim: sts=2 sw=2 ts=4 et ai tw=77 foldmethod=marker foldcolumn=2
5965
5965
  #++
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: pdf-writer
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.7
7
- date: 2007-12-13 00:00:00 -05:00
6
+ version: 1.1.8
7
+ date: 2008-03-16 00:00:00 -04:00
8
8
  summary: A pure Ruby PDF document creation library.
9
9
  require_paths:
10
10
  - lib