Rasterizer 2017

NumPages

# Copyright (c) 2019 ActivePDF, Inc.
# ActivePDF Rasterizer 2017
# Example generated 09/16/19 

require 'win32ole'

# Get current path
strPath = File.expand_path(File.dirname(__FILE__)) + "\\"

# Instantiate Object
oRAS = WIN32OLE.new("APRasterizer.Object")

# Open PDF
oRAS.OpenFile(strPath + 'doc.pdf')

# Get page count of open file
pageCount = oRAS.NumPages()

currentPage = 1
for currentPage in currentPage..pageCount
  # Image Format
  # 1 = RGB
  # 2 = JPEG
  # 3 = TIFF
  # 4 = PNG
  # 5 = BMP
  oRAS.ImageFormat = 2
  
  # Output Type
  # 1 = Stream
  # 2 = File
  oRAS.OutputFormat = 2
  
  # Other settings
  oRAS.OutputFileName = strPath + 'doc' + currentPage.to_s + '.jpg'
  oRAS.JPEGQuality = 72
  oRAS.IncludeAnnotations = true
  
  # Render the current page
  oRAS.RenderPage(currentPage)
end

# Finished rendering pages, close file
oRAS.CloseFile()

# Release Object
oRAS = ''

# Process Complete
puts "Done!"

Copyright © 2019 ActivePDF, Inc