How to use license key during unit testing

67 views
Skip to first unread message

muraleek...@multunus.com

unread,
Jun 21, 2016, 5:20:06 PM6/21/16
to PDFTron PDFNet SDK
I am trying to use PDF Tron in ruby service and initializing PDFTron using ENV variable.

require 'PDFNetC/Lib/PDFNetRuby'
include PDFNetRuby

module Converters
class PDFToXODConverter
def self.convert(in_file_path)
out_file_path = "#{ENV['TEMP_DIR']}/#{Time.now.to_i}.xod"
PDFNet.Initialize(ENV['PDFTRON_LICENSE_KEY'])
Convert.ToXod(in_file_path, out_file_path)
File.open(out_file_path, 'rb')
end
end
end


I don't want to set the key in test environment. Bit Initialize throws a Bad licence key exception when running the test without the key or key set to an empty string.

How to use PDFNet.Initialize in unit tests?

Ryan

unread,
Jul 8, 2016, 7:20:03 PM7/8/16
to PDFTron PDFNet SDK
How about the following?

require 'PDFNetC/Lib/PDFNetRuby'
 include
PDFNetRuby

module Converters
 
class PDFToXODConverter
   
def self.convert(in_file_path)
        out_file_path
= "#{ENV['TEMP_DIR']}/#{Time.now.to_i}.xod"

        lic_key  
= ENV['PDFTRON_LICENSE_KEY']
       
if lic_key.nil?
           
PDFNet.Initialize()
       
else
           
PDFNet.Initialize(lic_key)
       
end
Reply all
Reply to author
Forward
0 new messages