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 15-11-2011, 12:49
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default Skip blank pages in PDF

Hi Everyone,
I'm wondering if someone can help me out here.

I have my own script that I've made for exporting PDF's... works great.

Now... I have a need to have pages in a Corel drawing that doesn't print, or show in the PDF output... for which I turn off the print setting in the object manager for the appropriate layers. Again... this is all fine.

Where I run into the problem is that if I have two pages, and the second page has the items I don't want to appear in the PDF... the page still exists in the PDF... just with nothing in it.

Technically the page does have things on it, they just don't appear on a printable layer. Is there a way to make the PDF ignore a page without any "printable" data on it?

Any suggestions would be appreciated.

Thanks!
Reply With Quote
  #2  
Old 16-11-2011, 00:24
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 13
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 Printable Pages

Here is what I came up with, basically you look at each of the layers on a page and if the page has no printable layer your exclude it.
Code:
Sub CreatePDFwithPrintablePages()
    With ActiveDocument.PDFSettings
        .PublishRange = 3 'Prints a PageRange
        .PageRange = GetPrintablePages 'Printable pages returned from function
    End With

    ActiveDocument.PublishToPDF "D:\Temp\MyPDF.pdf"
End Sub

Private Function GetPrintablePages() As String
    Dim p As Page
    Dim strPrintablePages
    
    For Each p In ActiveDocument.Pages
        If SearchForPrintablePages(p) Then strPrintablePages = strPrintablePages & p.Index & ","
    Next p
    
    GetPrintablePages = Left(strPrintablePages, Len(strPrintablePages) - 1) 'Trim off the last comma
End Function

Private Function SearchForPrintablePages(ByVal p As Page) As Boolean
    Dim l As Layer
    
    For Each l In p.Layers
        If l.Printable Then
            SearchForPrintablePages = True
            Exit Function
        End If
    Next l
    
    SearchForPrintablePages = False
End Function
It should work, a few ideas for improvement would be to convert the string "1,2,3,6" to "1-3,6" also you could have a printable layer with no shapes on it, and currently it would print that page thus giving you a blank page, so you might want to add a check for this.

Hopefully it gets you started and shows it is possible,

-Shelby
Reply With Quote
  #3  
Old 18-11-2011, 09:10
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default

Much appreciated Sir! I'll try it out!
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
Fill in the blank (TextRange) runflacruiser CorelDRAW/Corel DESIGNER VBA 5 18-05-2011 10:54
Remove blank space in Paragraph text runflacruiser CorelDRAW/Corel DESIGNER VBA 8 20-10-2010 19:01
Convert Paragraph to Artistic - error on blank Paragraph Text Field gorgo2 Macros/Add-ons 3 14-09-2010 06:53
Macro - loading a blank template file *.cdt for Grahic and Text styles gorgo2 Macros/Add-ons 5 28-04-2010 00:25
How I can create blank GMS in CDX3? geHucKa CorelDRAW/Corel DESIGNER VBA 2 10-04-2006 17:16


All times are GMT -5. The time now is 11:55.


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