# Copyright (c) 2019 ActivePDF, Inc. # ActivePDF Toolkit 2018 # Example generated 12/16/19 require 'win32ole' # Get current path strPath = File.expand_path(File.dirname(__FILE__)) + "\\" # Instantiate Object oTK = WIN32OLE.new("APToolkit.Object") # Create the new PDF file intOpenOutputFile = oTK.OpenOutputFile(strPath + 'new.pdf') if intOpenOutputFile != 0 puts "Error in OpenOutputFile: #{intOpenOutputFile}" end # Open the template PDF intOpenInputFile = oTK.OpenInputFile(strPath + 'PDF.pdf') if intOpenInputFile != 0 puts "Error in OpenInputFile: #{intOpenInputFile}" end # Get the reference to the InitialViewInfo object oIVI = oTK.GetInitialViewInfo() # Options for viewer window oIVI.CenterWindow = true oIVI.FullScreen = false oIVI.ResizeWindow = true # 0 = Display the filename # 1 = Display the document title oIVI.Show = 1 # Show or hide UI elements of the viewer oIVI.HideMenuBar = true oIVI.HideToolBars = true oIVI.HideWindowControls = true # 0 = Page only # 1 = Bookmarks Panel and Page # 2 = Pages Panel and Page # 3 = Attachments Panel and Page # 4 = Layers Panel and Page oIVI.NavigationTab = 0 # Page settings # 0 = Default # 1 = Actual Size # 2 = Fit Page # 3 = Fit Width # 4 = Fit Height # 5 = Fit Visible # 6 = 25% # 7 = 50% # 8 = 75% # 9 = 100% # See the documentation for values 10-18. oIVI.Magnification = 150 oIVI.OpenToPage = 2 # 0 = Default Page Layout # 1 = Single Page Page Layout # 2 = Single Page Continoues Page Layout # 3 = Two-Up (Facing) Page Layout # 4 = Two-Up Continous (Facing) Page Layout # 5 = Two-Up (Cover Page) Page Layout # 6 = Two-Up Continous (Cover Page) Page Layout oIVI.PageLayout = 1 # Release Object oIVI = '' # Copy the template (with any changes) to the new file intCopyForm = oTK.CopyForm(0, 0) if intCopyForm != 1 puts "Error in CopyForm: #{intCopyForm}" end # Close the new file to complete PDF creation oTK.CloseOutputFile() # Release Object oTK = '' # Process Complete puts "Done!"