I am trying to copy a graphic stored in a vb.net picturebox.image into an activeLayer of an illustrator document. Can anyone supply me with code as to how to do it. Also is there a way to lookup a swatch by name and not have to rely on knowing it's index as in this line of code : pathRef.StrokeColor = docRef.Swatches(3).Color. I know the swatch's name is "CutContour" I would like to assign it by name. And lastly does anybody know any good books, links, etc.. that show you how to do this kind of stuff.
Thanks,
Bruce
------------------------------------------------------------------------------------------ ----------------------------------------------------------------------------------------
Imports IDAutomation.Windows.Forms.LinearBarCode
Imports Illustrator
Public Class FormMain
Dim barcode As IDAutomation.Windows.Forms.LinearBarCode.Barcode = New Barcode()
Dim illustrator As Illustrator.Application = CreateObject("Illustrator.Application")
Dim filePath As String = My.Application.Info.DirectoryPath
Private Sub FormMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
barcode.SymbologyID = barcode.Symbologies.Code39Ext
barcode.BarHeightCM = 1
barcode.XDimensionCM = 0.03
barcode.NarrowToWideRatio = 2
barcode.LeftMarginCM = 0.201
barcode.TopMarginCM = 0.201
barcode.TextMarginCM = 0.051
barcode.ShowText = False
barcode.CaptionBottomAlignment = StringAlignment.Center
barcode.CaptionBottomSpace = 0.03
Dim barcodeText As String = "CODE39UPC" 'hard code barcode content for this test
barcode.DataToEncode = "*" + barcodeText + "*"
barcode.CaptionBelow = barcodeText
PictureBox1.Image = barcode.BMPPicture 'Display Barcode
barcode.SaveImageAs(".\upc.png", System.Drawing.Imaging.ImageFormat.Png)
Dim fileName As String = filePath + "\Roland VersaWorks.eps"
Try
illustrator.Open(fileName)
Catch err As Exception
MsgBox("Missing File: " + fileName)
illustrator.Quit()
Me.Close()
End Try
Dim docRef As Illustrator.Document = illustrator.ActiveDocument
Dim pathRef As Illustrator.PathItem = docRef.ActiveLayer.PathItems.Rectangle(100, 0, 300, 100)
pathRef.StrokeColor = docRef.Swatches(3).Color 'Set strokeColor to CutContour Swatch
pathRef.Filled = False ' Don't Fill rectangle with anything
docRef.ActiveLayer = docRef.Layers(2) 'Activate UPC Layer
'############## I need to copy PictureBox1.image into this activeLayer! How do I do it? ###########
Dim epsOptions As Illustrator.EPSSaveOptions = CreateObject("Illustrator.EPSSaveOptions")
epsOptions.CMYKPostScript = True
docRef.SaveAs(filePath + "\test.eps", epsOptions)
illustrator.Quit()
Me.Close()
End Sub
End Class