OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 23-01-2004, 12:58
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default exporting to jpg

I have been looking through the help files and the file converter, but am becoming more confused with all the added subs that it has. I want to export the ActiveDocument to a jpeg and AI with the following settings:

JPG - Height=288px, width=?px, resolution=96, colorspace=RGB, antialiased=true

Where width scale is constrained to height.

AI - compatibility=ai.7, destination=mac, exportTextAs=curves, simulateComplexFilledCurves=true, allElse=False

The settings will always be the same, no matter what.

The file names for the exports will be provided by a textBox in the form.
I have attached the form to show what it looks like. The gray image box will be a temp.jpg that will be exported and used to fill the box when the form initializes.
Attached Images
 
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #2  
Old 23-01-2004, 15:41
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Simple Example

Here is a simple example to get you started. It doesn't answer all your questions. But gives you somthing to build on.

Code:
Sub JPGExportExample()

Dim opt As New StructExportOptions
Dim s As Shape

Set s = ActiveDocument.ActiveShape

opt.AntiAliasingType = cdrNormalAntiAliasing
opt.ImageType = cdrRGBColorImage
opt.Overwrite = True
opt.ResolutionX = 96
opt.ResolutionY = 96
opt.SizeX = opt.ResolutionX * s.SizeWidth
opt.SizeY = opt.ResolutionY * s.SizeHeight

ActiveDocument.Export "C:\ExportedFile.jpg", cdrJPEG, cdrSelection, opt

End Sub
Reply With Quote
  #3  
Old 23-01-2004, 15:42
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Here is what I have so far...
Code:
Sub UserForm_initialize()
    ' Sets Page Orientation and Imports Dump.ai
    Dim doc As Document
    Dim Filter As ExportFilter
    Set doc = CreateDocument()
    With ActivePage
        .Orientation = cdrPortrait
        .SizeWidth = 8.5
        .SizeHeight = 11
        .PrintExportBackground = False
        .Bleed = 0#
        .Background = cdrPageBackgroundNone
    End With
    
    ' Import the AI
    Dim s5 As Shape
    Dim x As Double, y As Double
    ActiveLayer.Import "C:\Documents and Settings\Artist\Desktop\dump.ai", 1283
    Set s5 = ActiveSelection
    s5.Move 0#, 0#
    ActiveDocument.ReferencePoint = cdrCenter
    s5.GetPosition x, y
    's5.SetSizeEx x, y
    s5.PositionX = 4.25
    s5.PositionY = 5.5
    
    ' Export to temp JPG
    'ActiveDocument.Export "C:\temp\temp.jpg", cdrJPEG, cdrSelection, opt
    Set Filter = doc.ExportBitmap("d:\Temp\preview.jpg", cdrJPEG, cdrCurrentPage, cdrRGBColorImage, 0, 0, 96, 96)

    With Filter
        .Compression = 80
        .Optimized = True
        .Smoothing = 50
        .SubFormat = 1
        .Progressive = False
        .Finish
    End With
    
    With ImageBox
        .Picture = LoadPicture("d:\Temp\preview.jpg")
        .PictureAlignment = fmPictureAlignmentCenter
        .PictureSizeMode = fmPictureSizeModeZoom
    End With
    
    ActiveWindow.ActiveView.ToFitAllObjects
End Sub
Private Sub cmdCanel_Click()
    Unload Me
End Sub
When I get to the
Code:
.Picture = LoadPicture("d:\Temp\preview.jpg")
I get the following MsgBox:
Attached Images
 
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #4  
Old 23-01-2004, 16:10
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

OK! I have the image box thing squared away, now i just need to know how to constrain the width and height.
Code:
Set Filter = doc.ExportBitmap("d:\Temp\preview.jpeg", cdrJPEG, cdrCurrentPage, cdrRGBColorImage, 0, 288, 96, 96)

    With Filter
        .Compression = 0
        .Optimized = True
        .Smoothing = 0
        .SubFormat = 1
        .Progressive = True
        .Finish
    End With
I was hoping that the 0, 288 would make the W follow the H, but no luck. It's just "squished"

Also can someone tell me where to find a list of ".operators" for the AIFilter like the .Compression = 0 stuff above?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #5  
Old 26-01-2004, 10:12
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

Sean,

To resolve your first problem with Permission denied error when you try to load the JPG image into the image box, make sure you dispose of the filter object:

Code:
With Filter
    ....
    .Finish
End With

Set Filter = Nothing

With ImageBox
    .Picture = LoadPicture("d:\Temp\preview.jpg")
    ....
End With
Setting the filter object to Nothing will destory it and free some associated resources including closing the export file. There is a bug in the code which doesn't close the file until you destroy the filter object.

Now, to help you calculate the width of your image if you know its target height, you just need to get the size of the objects you are exporting first:

Code:
Dim sx As Double, sy As Double
ActivePage.Shapes.All.GetSize sx, sy
Now that you know the original object dimensions as well as your designer height, you can easily calculate the image width:

Code:
width = sx * 288 / sy
Finally, for the information about all the filter properties (for AI and other filters) you can read the following page:

http://www.oberonplace.com/vba/filter10vba.htm

Some additional information you might find useful is here:

http://www.oberonplace.com/vba/exportex.htm

The above pages are written for Draw 10, but they still apply to Draw 11 (the only difference is that in Draw 11, ExportFilter and ImportFilter objects are introduced, while in the past you had to declare them as a generic Object).

I hope this helps.
Reply With Quote
  #6  
Old 26-01-2004, 11:55
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

Now with the AI export I am having this problem. I'm not sure if the syntax that I'm using is correct or what.
Code:
Sub cmdGo_Click()
    Dim JF As ExportFilter
    Dim d1 As Document
    Dim opt As StructExportOptions
    ' Check for Jpeg
    Set JF = Nothing
    Set d1 = ActiveDocument
    If cbxJPG.Value = True Then
        Set JF = d1.ExportBitmap("c:\Documents and Settings\Artist\Desktop\" & txbFile.Text & _
        ".jpg", cdrJPEG, cdrCurrentPage, cdrRGBColorImage, 0, 0, 72, 72)
    
    With JF
        .Compression = 100
        .Optimized = True
        .Smoothing = 100
        .SubFormat = 1
        .Progressive = False
        .Finish
    End With
    Set JF = Nothing
    End If
    
    If cbxAI.Value = True Then
        opt.ConvertSpotColors = False
        opt.HasDialog = False
        opt.IncludePreview = False
        opt.IncludePlacedImages = False
        opt.Platform = 1
        opt.SimulateFills = True
        opt.SimulateOutlines = False
        opt.TextAsCurves = True
        opt.UseColorProfile = False
        opt.Version = 0
        Set JF = d1.Export("c:\Documents and Settings\Artist\Desktop\" & txbFile.Text & _
        ".ai", cdrAI, cdrCurrentPage, opt)
    End If
    
End Sub
When it gets to the
Code:
Set JF = d1.Export("c:\Documents and Settings\Artist\Desktop\" & txbFile.Text & _
        ".ai", cdrAI, cdrCurrentPage, opt)
It gives me the error shown below and highlights the ".Export" portion of that argument.

Am I just using the wrong export argument or what?
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #7  
Old 26-01-2004, 11:55
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

forgot to attach the error msg
Attached Images
 
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
  #8  
Old 26-01-2004, 12:53
ddonnahoe's Avatar
ddonnahoe ddonnahoe is offline
Senior Member
 
Join Date: Jan 2004
Location: Louisville, KY
Posts: 552
Send a message via ICQ to ddonnahoe Send a message via AIM to ddonnahoe Send a message via MSN to ddonnahoe Send a message via Yahoo to ddonnahoe
Default

I have found my errors and the project is completed. Thank you all for all of your help. It is much appreciated!!!
__________________
Sean
Waiting for a ride in the T.A.R.D.I.S.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Exporting Illustrator files bbolte CorelDRAW/Corel DESIGNER VBA 8 15-03-2005 12:22
Exporting Vectors Anonymous Jigsaw Puzzle Creator 3 18-11-2004 14:31
exporting text object co-ordinates. vr_driver CorelDRAW/Corel DESIGNER VBA 2 20-08-2004 00:20
Exporting Grouped Objects ddonnahoe CorelDRAW/Corel DESIGNER VBA 4 15-05-2004 10:12
Exporting Transparent GIFs RobC CorelDRAW/Corel DESIGNER VBA 5 14-01-2004 15:31


All times are GMT -5. The time now is 09:05.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com