CorelDRAW Community
CorelDRAW Community
  • Site
  • User
  • Site
  • Search
  • User
Wikis
Wikis
Links and Resources Per Page PDF Export
  • Wikis
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • -Links and Resources
    • Per Page PDF Export
  • CORELCLUB.org
  • CorelDRAW & Photo-PAINT Macros
  • Handcrafted with care in CorelDraw
  • +Hardcover, dissertation inside covers
  • SEND LARGE CDR FILES RIGHT FROM CORELDRAW
  • Third Party Thumbnail Viewers List for DRAW

Per Page PDF Export

I have been playing around with scripts in CorelDraw and this is one I found pretty useful

Say you have 10 Pages but you need each page to be induvidually exported, all you need to do is add this macro/script save your file as a.cdr file and run it, the script exports the PDFs per page and even uses the page name as the.pdf file name where the .cdr file is saved. So no more publish to pdf and going one by one.


Just copy and paste the macro down below.

Sub PublishAllPagesAsPDF()
Dim doc As Document
Dim pg As Page
Dim fullPath As String
Dim exportPath As String
Dim pos As Long
Dim FileName As String
Dim outputPath As String

Set doc = ActiveDocument

fullPath = doc.FullFileName
If fullPath = "" Then
MsgBox "Please save your document first!", vbExclamation
Exit Sub
End If

pos = InStrRev(fullPath, "\")
If pos > 0 Then
exportPath = Left(fullPath, pos)
Else
MsgBox "Unable to determine folder path.", vbCritical
Exit Sub
End If

' Loop through all pages
For Each pg In doc.Pages
pg.Activate

' Get safe file name from page name or fallback
FileName = Trim(pg.Name)
If FileName = "" Then FileName = "Page_" & pg.Index

' Sanitize file name
FileName = Replace(FileName, "\", "_")
FileName = Replace(FileName, "/", "_")
FileName = Replace(FileName, ":", "_")
FileName = Replace(FileName, "*", "_")
FileName = Replace(FileName, "?", "_")
FileName = Replace(FileName, """", "_")
FileName = Replace(FileName, "<", "_")
FileName = Replace(FileName, ">", "_")
FileName = Replace(FileName, "|", "_")

outputPath = exportPath & FileName & ".pdf"

' Set PDF settings for current page
With doc.PDFSettings
.PageRange = CStr(pg.Index) ' Set export to only this page
.PublishRange = 1 ' 1 = use PageRange
.Author = "Jaco Coetzee"
.EmbedFonts = True
' Add any additional settings here if needed
End With

' Export the page
doc.PublishToPDF outputPath
Next pg

MsgBox "All pages have been exported to PDF in:" & vbCrLf & exportPath, vbInformation
End Sub

  • Share
  • History
  • More
  • Cancel
Related
Recommended

© Corel Corporation. All rights reserved. The content herein is in the form of a personal web log ("Blog") or forum posting. As such, the views expressed in this site are those of the participants and do not necessarily reflect the views of Corel Corporation, or its affiliates and their respective officers, directors, employees and agents. Terms of Use / Privacy​ ​/ ​Cookies / Terms and Conditions / User Guidelines.