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 28-04-2005, 13:18
applepaul
Guest
 
Posts: n/a
Unhappy Exporting to pdf and jpg with "one click"

Hi all!
I'm new to VBA (did only basic scripts).
Can anyone give me a hint in the following problem:

I would like the script to:
1. Export - whatever is within page border - as PDF and also as JPG, without prompting user for anything (that's the part I am clueless)
2. File name doesn't really matter as long as it will be saved in the same directory as the *.cdr file.

Thanks in advance for any help!
Paul
Reply With Quote
  #2  
Old 28-04-2005, 14:35
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Here is something for you to start with:

Code:
Sub ExportToPDFandJPG()
    Dim fltJPEG As ExportFilter
    Dim strBaseFileName As String
    Dim nPos As Integer
    
    If ActiveDocument.FileName = "" Then
        MsgBox "The document is not saved yet", vbCritical
        Exit Sub
    End If
    
    strBaseFileName = ActiveDocument.FileName
    nPos = InStrRev(strBaseFileName, ".")
    If nPos Then strBaseFileName = Left$(strBaseFileName, nPos - 1)
    
    ' Publish to PDF
    With ActiveDocument.PDFSettings
        .Bleed = 0
        .PublishRange = pdfWholeDocument
        .Encoding = pdfBinary
        .UseColorProfile = True
        ' Set other PDF settings here if you want
    End With
    ActiveDocument.PublishToPDF strBaseFileName & ".pdf"
    
    ' Export to JPEG
    Set fltJPEG = ActiveDocument.ExportBitmap(strBaseFileName & ".jpg", cdrJPEG, cdrCurrentPage, _
                                    ResolutionX:=72, ResolutionY:=72, _
                                    AntiAliasingType:=cdrNormalAntiAliasing, _
                                    UseColorProfile:=True)
    With fltJPEG
        .Progressive = False
        .Optimized = True
        .SubFormat = 0
        .Compression = 20
        .Smoothing = 10
    End With
    fltJPEG.Finish
End Sub
Reply With Quote
  #3  
Old 29-04-2005, 09:31
applepaul
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Alex
Code:
' Export to JPEG
    Set fltJPEG = ActiveDocument.ExportBitmap(strBaseFileName & ".jpg", cdrJPEG, cdrCurrentPage, _
                                    ResolutionX:=72, ResolutionY:=72, _
                                    AntiAliasingType:=cdrNormalAntiAliasing, _
                                    UseColorProfile:=True)
End Sub
Thanks Alex a lot for help!
At least now I won't have to do so many clicks everyday
I changed only one thing [cdrSelection], just to make sure that Exporting to JPEG will export whatever I selected. I wonder why "publishing to PDF" doesn't work the same way...

Code:
Set expflt = ActiveDocument.ExportBitmap(strBaseFileName & ".jpg", cdrJPEG, cdrSelection, _
                                    ResolutionX:=72, ResolutionY:=72, _
                                    AntiAliasingType:=cdrNormalAntiAliasing, _
                                    UseColorProfile:=True)
Reply With Quote
  #4  
Old 29-04-2005, 09:43
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Quote:
Originally Posted by applepaul
I wonder why "publishing to PDF" doesn't work the same way...
Have you tried replacing ".PublishRange = pdfWholeDocument" with ".PublishRange = pdfSelection"?
Reply With Quote
  #5  
Old 29-04-2005, 10:01
applepaul
Guest
 
Posts: n/a
Default

I think I found a bug... or at least it looks like it.
Whenever there is a space " " in the file name (another words: document is not
saved as "web-safe") the scripts doesn't work.

I will try to to fix it somehow... maybe there is some way to reformat filename to "websafe" within the script.

Quote:
Originally Posted by Alex
Have you tried replacing ".PublishRange = pdfWholeDocument" with ".PublishRange = pdfSelection"?
Hmmm... I didn't. I will check it out now
For some reason I always thought PDF format *requires* page border.

UPDATE
I just tried ".PublishRange = pdfSelection" but PDF I got is all the time blank...

Last edited by applepaul; 29-04-2005 at 10:14.
Reply With Quote
  #6  
Old 29-04-2005, 12:02
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

Do you have a selection actually?
Reply With Quote
  #7  
Old 29-04-2005, 13:21
applepaul
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Alex
Do you have a selection actually?
Yes.
I select a couple of objects before running the script.
All I receive after running the script, is the empty PDF with nothing on it. The size of this PDF matches "page border" size and orientation...

So far I didn't find the solution... :/
Reply With Quote
  #8  
Old 07-07-2005, 14:41
jconnor
Guest
 
Posts: n/a
Question Incremental naming

Any suggestion to modify the basic procedure allowing incremental naming?
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


All times are GMT -5. The time now is 03:36.


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