Support Center

Using ImageMan ActiveX V8 with Image Attributes and VBScript

Last Updated: Apr 22, 2011 05:19PM EDT

 

The following VBScript illustrates how to use the ImageMan ActiveX controls to load a picture, set ImageAttributes and save a file using those attributes.  In this example we are converting a TIF to an encrypted PDF.

Copy and paste the following code into a file called TIF2PDF.vbs and execute it in the command line.  Please be sure to change the image location and output location to directories that exist on your computer.

Dim image1

Set image1 = CreateObject("IMActX8.ImageControl")

image1.Picture = "C:\images\TIF\bad1.tif"

MsgBox "Image name is " & image1.Picture

Dim Attrs
Set Attrs = CreateObject("IMActX8.Attributes")
   
Attrs.Add "EXTENSION", "PDF", 256
Attrs.Add "SOFTWARE", "software", 256
Attrs.Add "TITLE", "title", 256
Attrs.Add "DESCRIPTION", "description", 256
Attrs.Add "COPYRIGHT", "copyright", 256
Attrs.Add "KEYWORDS", "keywords", 256
Attrs.Add "COMMENT", "comment", 256

Attrs.Add "ENCRYPT_128", "test123", 256
Attrs.Add "ENCRYPT_USER", "testing123", 256

Attrs.Add "PDF_PRINT", "OFF", 256
Attrs.Add "PDF_MODIFY", "OFF", 256
Attrs.Add "PDF_COPY", "OFF", 256

image1.Overwrite = Yes
image1.SaveAs "C:\Images\temp1.pdf", Attrs

MsgBox ("Finished saving")

The 256 parameter is the enumerated value of the data type for the attribute.  Here are the other values you can use:

        IMBinary = 0x01 (1)
        IMChar = 0x02 (2)
        IMInt8 = 0x04 (4)
        IMInt16 = 0x08 (8)
        IMInt32 = 0x10 (16)
        IMRational = 0x20 (32)
        IMFloat = 0x40 (64)
        IMDouble = 0x80 (128)
        IMString = 0x100 (256)
        IMBool = 0x200 (512)       

Contact Us