pdftoruby 0.0.5 → 0.0.6

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.
Files changed (4) hide show
  1. data/History.txt +4 -1
  2. data/bin/pdftoruby.rb +28 -1
  3. data/lib/pdftoruby.rb +1 -1
  4. metadata +1 -1
@@ -1,6 +1,9 @@
1
+ === 0.0.6 / 2008-05-23
2
+ * Added support "flatdecodeded rgb images
3
+
1
4
  === 0.0.5 / 2008-05-23
2
5
 
3
- * Added support for DeviceRGB or "jpg" images embedded in pdf files
6
+ * Added support for "jpg" images embedded in pdf files
4
7
 
5
8
  === 0.0.4 / 2008-05-20
6
9
 
@@ -554,9 +554,14 @@ class PDFReceiver < PDF::Reader
554
554
  spec.puts specs
555
555
  spec.close
556
556
  colorspace = specs[:ColorSpace]
557
+ filter = specs[:Filter]
557
558
  filename = String.new(name.to_s)
558
559
  width = specs[:Width]
559
560
  height = specs[:Height]
561
+ if filter == :DCTDecode
562
+ external_dct_image(filename,image_data,width,height)
563
+ return
564
+ end
560
565
  if colorspace == :DeviceRGB
561
566
  external_rgb_image(filename,image_data,width,height)
562
567
  return
@@ -594,7 +599,7 @@ class PDFReceiver < PDF::Reader
594
599
 
595
600
 
596
601
 
597
- def external_rgb_image(name,data,width,height)
602
+ def external_dct_image(name,data,width,height)
598
603
  dir_name = @rubyclass.to_s
599
604
  FileUtils.mkdir_p dir_name
600
605
  jpg_name = dir_name + "/" + name + ".jpg"
@@ -603,6 +608,28 @@ class PDFReceiver < PDF::Reader
603
608
  jpg.close
604
609
  end
605
610
 
611
+ def external_rgb_image(name,data,width,height)
612
+ dir_name = @rubyclass.to_s
613
+ FileUtils.mkdir_p dir_name
614
+ raw_name = dir_name + "/" + name + ".raw"
615
+ png_name = dir_name + "/" + name + ".png"
616
+ raw = File.open(raw_name,"wb")
617
+ raw.write data
618
+ raw.close
619
+ #need to convert the RGB file to PNG
620
+ canvas = PNG::Canvas.new width, height
621
+ offset = 0
622
+ for x in (0..height-1)
623
+ offset = offset + 1 # A per line transparrency value?
624
+ for y in (0..width-1)
625
+ canvas[y,x] = PNG::Color.new 255 - data[offset], 255 - data[offset+1], 255 - data[offset+2], 0x00
626
+ offset = offset + 3
627
+ end
628
+ end
629
+ png = PNG.new canvas
630
+ png.save png_name
631
+ end
632
+
606
633
  def external_image(name,data,width,height,cdata)
607
634
  dir_name = @rubyclass.to_s
608
635
  FileUtils.mkdir_p dir_name
@@ -1,3 +1,3 @@
1
1
  class Pdftoruby
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdftoruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - glennswest