Skip to content

Instantly share code, notes, and snippets.

@arika
Created December 21, 2010 13:16
Show Gist options
  • Select an option

  • Save arika/749919 to your computer and use it in GitHub Desktop.

Select an option

Save arika/749919 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'origami'
include Origami
pdf = PDF.read(ARGV.first)
pdf.pages.each do |page|
xobjs = page.Resources[:XObject]
xname = xobjs.keys.first
obj = xobjs[xname].solve
open("new-image.jpg", "r") do |i|
obj.Length = i.stat.size
obj.data = i.read
end
obj.Width = 12345 # new-image.jpg¤ÎÉý
obj.Height = 54321 # new-image.jpg¤Î¹â¤µ
break
end
pdf.saveas("new.pdf")
@usku

usku commented Oct 12, 2016

Copy link
Copy Markdown

cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment