rubypdfnet

How to use PDFNet instance across the ruby app


I have to initialize the PDFNet library once in my app. I did it in my app.rb which is run first

# app.rb
require 'PDFNetC/Lib/PDFNetRuby'
include PDFNetRuby
PDFNet.Initialize(ENV['PDFTRON_LICENSE_KEY'])

Later in my controller I need to convert pdf to xod for which I will require the initialized PDFNet instance

# SomeController.rb
out_file_path = "#{ENV['TEMP_DIR']}/#{Time.now.to_i}.xod"
::PDFNetRuby::Convert.ToXod(in_file_path, out_file_path)
File.open(out_file_path, 'rb')

Will the above method get the license registerd instance of PDFNet?


Solution

  • PDFNet.Initialize is a process wide call, so if both code snippets are in the same process, both will be in licensed mode.