Full interface index
311 entries across 32 sections. Type to filter by interface name, class or description.
Getting StartedConnection & InitApplicationDocumentPageLayer & ShapesGeometry & TransformGroup / Order / BooleanShape AppearanceTextTextRangeFillOutlinePowerClipFountain FillPattern / Texture FillTransparency & BlendEffectsColorCurve & NodeBitmapFind & TraverseUnits & ConversionImport / ExportEnumerationsObject DataAlign / DistributeLayer AdvancedView & PerformanceEventsRecipesPitfalls
Getting Started 1 entries
Connection & Init 8 entries
- pythoncom.CoInitialize()COM initialization; it goes on the first line of the script. Any thread that tou
- win32com.client.Dispatch("CorelDRAW.Application.21")Connect by version number; 21 is CorelDRAW 2019. If CDR is already running this
- app.Visible = TrueShows the CDR window. Setting it False is faster for batch runs, but keep it Tru
- win32com.client.Dispatch("CorelDRAW.Application")No version number, so it binds to whatever version is registered as default. On
- win32com.client.GetActiveObject("CorelDRAW.Application.21")Attaches to an instance that is already open and never starts a new process. It
- win32com.client.gencache.EnsureDispatch(progid)Once the constant cache exists you can write cdrTextShape instead of 6. Generati
- app.VersionReturns the version as a string. Use it to confirm which version you actually co
- app.Quit()Closes CorelDRAW entirely. Don't call it at the end of a batch job — it takes th
Application 13 entries
- app.DocumentsCollection of every open document. The i-th one is app.Documents.Item(i); the to
- app.ActiveDocumentThe document in front. Returns None when nothing is open, so wrap it in try/exce
- app.CreateDocument()Creates a blank document and returns it.
- app.OpenDocument(path)Opens a .cdr or template file from disk and returns the Document.
- app.ActiveSelectionRange(n)The n-th shape in the current selection, as a single Shape. Use it to grab an im
- app.ActiveSelectionRangeWith no argument it returns the whole selection as a ShapeRange. Iterate it with
- app.ActiveShapeThe first shape in the selection. Same as ActiveSelectionRange(1).
- app.ActivePageThe active page. Shorthand for ActiveDocument.ActivePage.
- app.ActiveLayerThe active layer. Shorthand for ActiveDocument.ActivePage.ActiveLayer.
- app.ActiveWindow / app.ActiveViewWindow and view object. Zoom is a percentage: app.ActiveWindow.Zoom = 50.
- app.CreateRGBColor(r, g, b)Builds an RGB color object you can pass to Fill.ApplyUniformFill(color).
- app.CreateCMYKColor(c, m, y, k)Builds a CMYK color object. Prefer this for anything that goes to press.
- app.WindowState / app.VisibleWindow state (minimized, maximized, restored) and visibility.
Document 20 entries
- doc.PagesThe page collection. doc.Pages.Count for the total, doc.Pages.Item(i) for the i-
- doc.AddPages(n)Appends n pages at the end. The idiom while len(doc.Pages) < page_index: doc.Add
- doc.ActivePageThe current page object.
- doc.ActiveLayerThe active layer of the current page.
- doc.UnitDocument unit (cdrUnit). Every geometric value follows it: shape coordinates and
- doc.ResolutionDocument resolution in dpi. Affects bitmap export and effect rendering.
- doc.ReferencePointReference point for transforms. It anchors SetPosition and SetSize and follows t
- doc.ClearSelection()Deselects everything. Call it before a batch run so you don't accidentally modif
- doc.BeginCommandGroup(commandName)Opens an undo group; everything after it collapses into one entry in the undo li
- doc.EndCommandGroup()Closes the undo group. It must pair with Begin, including in a finally block — i
- doc.Undo() / doc.Redo()Undo or redo one step.
- doc.Save() / doc.SaveAs(path)Save, or save under a new path. Don't save inside a per-page loop; once at the e
- doc.ExportEx(path, filter, options)General-purpose export. filter takes a cdrFilter value (PDF, JPG, PNG and SVG ea
- doc.PublishToPDF(path)Exports a PDF. The simplest export call there is; the defaults are fine.
- doc.ExportBitmap(...)Bitmap export. The signature is long (width, height, dpi, antialiasing, transpar
- doc.PrintOut()Prints. Takes a PrintOptions object; you won't need it day to day.
- doc.Close()Closes the document. With unsaved changes it may raise a dialog and stall the sc
- doc.FileName / doc.DirtyFileName is the file path; Dirty is whether there are unsaved changes (True/Fals
- doc.Grid / doc.SnapToGrid / doc.SnapToShapes / doc.SnapToGuidelinesThe grid and the various snapping switches. Turn them all off for automated layo
- doc.GuidesThe guide collection. Readable and writable.
Page 15 entries
- page.SizeWidthPage width, read/write, in doc.Unit. In the code = 1490/25.4 sets it to 1490 mm.
- page.SizeHeightPage height, same rules. Note that CDR's Y axis points up, so Top is a larger nu
- page.SetSize(w, h)Sets width and height in one call, one COM round trip cheaper than assigning the
- page.OrientationLandscape or portrait.
- page.ActiveLayerThe active layer of this page. Every Create* method lives on a Layer, so get the
- page.LayersThe layer collection: page.Layers.Count and .Item(i). This is how you build a st
- page.ShapesAll top-level shapes on the page. To reach the ones inside groups and containers
- page.Activate()Switches to this page. It moves the UI too, which is slow — skip it in batch cod
- page.Delete()Deletes this page. The indexes of later pages shift down, so deleting in reverse
- page.MoveTo(index)Moves this page to position index. Use it to reorder pages.
- page.Next() / page.Previous()The next and previous page objects, for walking through a document.
- page.NamePage name, for orientation.
- page.BleedBleed settings (for print work).
- page.FindShapes(query, type, recursive)Page-level search. Behaves exactly like Layer.FindShapes.
- page.Guides / page.GridThis page's guides and grid.
Layer & Shapes 14 entries
- layer.CreateRectangle2(x, y, w, h)Draws a rectangle. (x, y) is the bottom-left corner; w and h are width and heigh
- layer.CreateRectangle(l, t, r, b)Rectangle from four edges. t (top) must be a larger number than b (bottom).
- layer.CreateEllipse2(x, y, w, h)Ellipse from bottom-left corner plus size. w == h gives a circle.
- layer.CreateEllipse(l, t, r, b)Ellipse from four edges.
- layer.CreateArtisticText(left, top, text, lang, charset, font, size, bold, italic, underline, align)Creates artistic text (a single-line heading). size is in points, not doc.Unit.
- layer.CreateParagraphText(left, top, right, bottom, text, lang, charset, font, size, bold, italic, underline, align)Creates paragraph text that wraps inside a box. Requirement: top > bottom. The c
- layer.Import(path, filter, options)Imports an image, SVG or other external file. 0 means auto-detect the format; No
- layer.CreateCurve(...) / layer.CreateFreehandCurve(...)Builds a curve from an array of points. Used for procedural artwork (flowers, ma
- layer.Activate()Makes this the active layer.
- layer.NameLayer name, read/write. Batch template jobs look layers up by name.
- layer.Visible / .Printable / .EditableThree switches: visible, printable, editable. A handy pattern — put construction
- layer.ShapesAll shapes on this layer.
- layer.Delete() / layer.MoveTo(page)Deletes the layer, or moves it to another page.
- layer.FindShapes(query, type, recursive)Layer-level search. The three calls worth memorizing: ("", 6, True) text, ("", 7
Geometry & Transform 17 entries
- shape.Left / .Top / .Right / .BottomEdge coordinates. Top > Bottom because Y points up. Children inside a group don'
- shape.PositionX / .PositionYBottom-left corner. Reading and writing these directly is one call cheaper than
- shape.SizeWidth / .SizeHeightWidth and height, read/write. When scaling, read the current size first, then co
- shape.CenterX / .CenterYCenter coordinates. More convenient than Left/Top when you're aligning things.
- shape.RotationAngleRotation in degrees, around RotationCenterX/Y.
- shape.SetPosition(x, y, anchor)The default anchor is bottom-left; the third argument picks a different one. img
- shape.SetSize(w, h, anchor)Scales; the default anchor is top-left. Proportional scaling is on you: s = max(
- shape.Move(dx, dy)Relative offset. Cheaper than SetPosition because it doesn't read the current po
- shape.Rotate(angle)Rotates by a relative angle.
- shape.GetBoundingBox()Returns (x, y, w, h). The only way to read the position of text inside a contain
- shape.Type1 rectangle / 2 ellipse / 3 curve / 5 bitmap / 6 text / 7 group. After convertin
- shape.StaticIDStable ID. Use it to deduplicate when the same object arrives down more than one
- shape.NameObject name, read/write. Name the important elements ("title bar", "image frame"
- shape.Clone()Clones in place — the copy sits exactly on top of the original.
- shape.Duplicate(dx, dy)Copies with an offset; dx and dy are the offset.
- shape.Delete()Deletes. The object is gone afterwards; reading any property on it raises.
- shape.AddToSelection() / .RemoveFromSelection()Add to or drop from the selection. Build up a batch this way, then process it in
Group / Order / Boolean 18 entries
- shape.ConvertToCurves()Convert to curves: text or basic shapes become curve vectors. A converted text o
- shapeRange.Group()Group: packs several shapes into one group and returns it (Type=7).
- shape.Ungroup()Ungroups one level. Nested groups need several calls.
- shape.UngroupAll()Ungroups every level in one go.
- shapeRange.Combine()Combine (Ctrl+L): merges objects into a single curve with the overlaps knocked o
- shape.BreakApart() / .BreakApartEx()Break apart (Ctrl+K): splits a combined curve back into separate objects, or spl
- shape.OrderToFront() / .OrderToBack()Send to front or back.
- shape.ForwardOne() / .BackOne()Move up or down one step in z-order.
- shape.OrderToFrontOf(other) / .OrderToBackOf(other)Place above or below another object. More reliable than counting layers.
- shape.AlignToShape(type, other)Aligns to another shape. In the code, title_text.AlignToShape(-1, in_rectangle);
- shape.AlignToPage(type)Aligns to the page, or to the page center.
- shapeRange.Weld(other)Weld: fuses the shapes into one outline.
- shapeRange.Trim(other)Trim.
- shapeRange.Intersect(other)Intersect: keeps only the overlap.
- shapeRange.Simplify(other)Simplify: separates the overlapping parts out.
- shapeRange.FrontSubtract(other) / .BackSubtract(other)Front minus back, or back minus front.
- shapeRange.CreateBoundary()Creates a boundary — the outer edge of several objects as one curve. Handy for o
- shape.ShapesChild shapes inside a group or container. Recurse through them to reach the bott
Shape Appearance 11 entries
- shape.FillThe fill object. See the Fill section.
- shape.OutlineThe outline object. See the Outline section.
- shape.RectangleThe rectangle sub-object, which owns the corners: .CornerType (0 = square) and .
- shape.TransparencyTransparency: .ApplyTransparency(type, start, end), or set .Transparency directl
- shape.EffectsThe effects collection — drop shadow, extrude, contour, envelope, perspective al
- shape.ShadowShadow properties.
- shape.LensLens (magnify, fisheye, color transform and so on).
- shape.TextThe text object. See the Text section. Accessing it on a non-text shape raises,
- shape.PowerClipThe PowerClip container. See the PowerClip section.
- shape.CurveThe curve object, present only after converting to curves. Exposes .Nodes, .SubP
- shape.Locked / .Editable?Lock state. Unlock before batch-editing, or your changes silently do nothing and
Text 13 entries
- shape.TextEntry point to the text object. Only exists when shape.Type == 6.
- shape.Text.ContentsPlain text, read/write. strip() before you compare — CDR often leaves trailing s
- shape.Text.IsArtisticTextTrue if it's artistic text (a single-line heading).
- shape.Text.IsParagraphTextTrue if it's paragraph text that wraps inside a box.
- shape.Text.StoryThe story object. This is where the real layout properties live.
- shape.Text.Story.CharactersCharacter collection. .Count gives the character count, .Item(i) a single charac
- shape.Text.Story.Characters.AllThe whole-character range, and the only reliable way to set font and size in bul
- shape.Text.Story.CharSpacingCharacter spacing, as a percentage. 180 means 180%, loose; 50 tightens. This is
- shape.Text.Story.WordSpacingWord spacing as a percentage. For Latin headings.
- shape.Text.Story.LineSpacingLine spacing. Paragraph text needs this one.
- shape.Text.Story.AlignmentHorizontal paragraph alignment (cdrAlignment enum).
- shape.Text.Range(start, end)Returns a character range, for local typography like recoloring the first few ch
- shape.Text.FitToPath?Text on a path; needs a Path object to go with it.
TextRange 7 entries
- rng.FontFont name, read/write. Always read it back after writing (see the warning in the
- rng.SizeFont size in points, not doc.Unit.
- rng.Bold / .Italic / .UnderlineBold, italic, underline. Booleans.
- rng.CharSpacingCharacter spacing percentage. More precise than setting it on the Story, because
- rng.FillText fill, same as a shape's Fill.
- rng.OutlineText outline. This is the core of the yellow-text-with-black-edge look.
- rng.CaseCase conversion (all caps, small caps and so on).
Fill 11 entries
- shape.Fill.TypeFill type. 0 none / 1 uniform / 2 fountain / 3 PostScript / 8 texture / 9 patter
- shape.Fill.UniformColorThe color object behind a uniform fill. Requires Fill.Type == 1, otherwise acces
- shape.Fill.UniformColor.RGBAssign(r, g, b)Assigns RGB, each component 0-255. RGBAssign(0, 133, 205) in the code is that bl
- shape.Fill.UniformColor.CMYKAssign(c, m, y, k)Assigns CMYK. More accurate for anything that goes to press.
- shape.Fill.UniformColor.HexValueHex color value, e.g. "#FFFF00". Call .upper() on the way out before comparing —
- shape.Fill.UniformColor.RGBRed / .RGBGreen / .RGBBlueReads one channel at a time.
- shape.Fill.UniformColor.CMYKCyan / .CMYKMagenta / .CMYKYellow / .CMYKBlackReads one CMYK channel at a time.
- shape.Fill.ApplyUniformFill(color)Sets a uniform fill in one call; build the color with app.CreateRGBColor(). Fewe
- shape.Fill.ApplyNoFill()Removes the fill.
- shape.Fill.ApplyFountainFill(...)Gradient fill: start color, end color, type, angle, edge pad, midpoint.
- shape.Fill.FountainThe existing gradient object: .Colors, .Type, .Angle, .CenterX/Y.
Outline 10 entries
- shape.Outline.WidthLine width in doc.Unit. Setting it to 0 removes the outline, which is less bothe
- shape.Outline.TypeOutline type. 0 = no outline.
- shape.Outline.Color.RGBAssign(r, g, b)Outline color in RGB.
- shape.Outline.Color.HexValueOutline color as hex, read/write.
- shape.Outline.LineJoinCorner style. 1 = miter; round and bevel are other values. The code uses 1 throu
- shape.Outline.LineCapsLine caps. 1 = round, 0 flat, 2 square.
- shape.Outline.JustificationWhere the outline sits relative to the path. Setting 2 on text puts the outline
- shape.Outline.StyleDash style (solid or one of the dashes).
- shape.Outline.StartArrow / .EndArrowStart and end arrowheads.
- shape.Outline.VisibleOn/off switch.
PowerClip 5 entries
- shape.AddToPowerClip(clipShape, centerInParent)Puts the current shape inside the clipShape container. The second argument, True
- shape.PowerClipThe container object. A read-only door — you can inspect the contents without en
- shape.PowerClip.ShapesShapes inside the container. From here FindShapes can reach text — that's the on
- shape.PowerClip.Content?The generic entry point for container contents. Naming varies between versions,
- shape.PowerClip.Extract?Pulls the contents out, the API equivalent of Extract Contents. Behaviour varies
Fountain Fill 8 entries
- shape.Fill.ApplyFountainFill(StartColor, EndColor, Type, Angle, Steps, EdgePad, MidPoint)Lays down a gradient in one call. The argument order is fixed: start color, end
- shape.Fill.FountainFetches the gradient sub-object. Requires Fill.Type == 2; otherwise it raises im
- ff.TypeGradient shape, and it is writable: 1 linear / 2 radial / 3 conical / 4 square.
- ff.AngleRead-only. The angle is a parameter of ApplyFountainFill() and nothing else; ass
- ff.MidPointWhere the two stops meet, as a percentage. Lower it (25) and the start color tak
- ff.Colors.Add(Position, Color)Inserts an intermediate stop, for three-color and rainbow gradients. Position is
- ff.StartColor / ff.EndColorThe two end colors on a FountainFill. Reading them is fine; to change one, call
- ff.StepsNumber of steps. 0 means a smooth blend; 5-10 gives banded color rings, which is
Pattern / Texture Fill 8 entries
- shape.Fill.ApplyPatternFill(Type, FileName, CanvasIndex, FrontColor, BackColor, TransformWithShape)Applies a pattern fill. Type: 0 two-color / 1 full-color vector / 2 bitmap. Two-
- shape.Fill.ApplyPatternFill(patternType, filePath)Tiles one of your own images. The path needs forward slashes or doubled backslas
- shape.Fill.PatternThe pattern sub-object. Only reachable when Fill.Type == 9. For bitmap patterns
- shape.Fill.ApplyTextureFill(TextureName, LibraryName)Applies a texture by name. The second argument is the style library; leave it ou
- shape.Fill.PostScript.Select("Bricks")PostScript textures. The old CorelDRAW set — bricks, grids, waves — lives here,
- shape.Fill.ApplyNoFill()Removes the fill, making the shape transparent. Cleaner than filling with white:
- shape.Fill.CopyAssign(source_fill)Copies one shape's fill onto another — the fill half of the format painter. Outl
- shape.Fill.GetCopy() / fill.CompareWith(fill2)Takes a copy of a fill (leaving the original alone), or compares two fills. Usef
Transparency & Blend 7 entries
- shape.Transparency.ApplyUniformTransparency(Value)Even transparency across the shape, 0-100. Watermarks, tint blocks, semi-transpa
- shape.Transparency.ApplyFountainTransparency(Start, End)Gradient transparency: one end transparent, the other not. The most natural way
- shape.Transparency.MergeModeBlend mode (multiply, screen, overlay and so on). The enum values shift between
- shape.Transparency.TypeThe current transparency type (none, uniform, fountain, pattern, texture). Read-
- shape.Transparency.ApplyNoTransparency()Clears transparency back to fully opaque. Handy for normalizing a pile of assets
- shape.Transparency.ApplyPatternTransparency() / ApplyTextureTransparency()Drives transparency from a pattern or texture, for a mottled, frosted, cut-out l
- shape.Transparency.Freeze() / Unfreeze()Freezes the transparency so it no longer follows the shape when you move or scal
Effects 12 entries
- shape.Effect / shape.EffectsEffect is the first effect; Effects is the whole collection. Count Effects to fi
- shape.CreateDropShadow(Type, Opacity, Feather, OffsetX, OffsetY, Color)Adds a drop shadow. Arguments: type (0 flat), opacity 0-100, feather 0-100, x of
- eff.DropShadow.Opacity / Direction / ColorShadow settings you can adjust afterwards: opacity, direction, color. For a subt
- shape.CreateBlend(target_shape)Blend: generates a run of intermediate objects between two shapes. The step coun
- shape.CreateContour(Offset)Contour: rings the shape outward or inward. Neon lettering, sticker edges, map b
- shape.CreateExtrude(Depth)Extrude: pulls a flat shape into depth. 3D lettering, boxes. A larger depth reac
- shape.CreateLens(Type)Lens: drops a piece of filter glass on the shape so whatever sits beneath it cha
- shape.CreateEnvelope()Envelope: bends the shape inside a control cage. Arced text, patterns wrapped on
- shape.CreatePerspective()Perspective: pulls a flat object into a trapezoid, near large and far small. Wal
- shape.CreatePushPullDistortion() / CreateZipperDistortion() / CreateTwisterDistortion()Three distortions: push-pull (inflate and contract), zipper (sawtooth edge), twi
- eff.Separate()Breaks the effect into standalone objects. A separated drop shadow becomes a rea
- shape.ClearEffect()Removes every effect at once, back to a clean shape. Clear effects before a batc
Color 10 entries
- app.CreateRGBColor(Red, Green, Blue)Builds an RGB color, each component 0-255. Screen work, web images, social posts
- app.CreateCMYKColor(Cyan, Magenta, Yellow, Black)Builds a CMYK color, each component 0-100. If the job ends up on press — brochur
- app.CreateGrayColor(Value) / CreateHLSColor(H, L, S) / CreateHSBColor(H, S, B)Three more ways to build a color: gray (0-255), HLS, HSB. For lighter and darker
- color.RGBAssign(R, G, B) / color.CMYKAssign(C, M, Y, K)Changes the components of an existing color in place. No new object — you mutate
- color.HLSAssign(H, L, S) / color.HSBAssign(H, S, B) / color.GrayAssign(V)In-place recolor via HLS, HSB or gray. To generate a scale of one hue at differe
- color.ConvertToCMYK() / ConvertToRGB() / ConvertToGray() / ConvertToHLS()Explicit color model conversion. It mutates the object rather than returning a n
- color.HexValue / color.RGBValueHexValue is a #RRGGBB string you can match against the swatch in the design file
- color.BlendWith(OtherColor, Weight)Mixes two colors into an in-between shade. Automatic palettes and tonal ramps. W
- color.CopyAssign(SourceColor) / color.IsSame(OtherColor)Copies one color's values onto another (without changing object references), or
- color.StringAssign("#0085CD") / color.ToString()Sets a color straight from a hex string. The one that suits designers — paste th
Curve & Node 8 entries
- shape.CurveEntry point to the curve sub-object. Rectangles are 1, ellipses 2, groups 7 — no
- shape.Curve.Nodes.CountTotal node count for the shape. When you're checking node reduction this is the
- node.PositionX / node.PositionYOne node's coordinates, read/write. Values are in document coordinates and follo
- shape.Curve.SubPathsThe sub-path collection. A shape with several separate runs of line has several
- shape.Curve.Length / Area / ClosedCurve length, enclosed area, whether it closes. Cut lines, material estimates, c
- shape.Curve.Segments.CountSegment count. The relationship is segment count = node count minus sub-path cou
- subpath.ReverseDirection()Reverses path direction. Inside/outside tests, holes, and boolean results that c
- subpath.GetCopy() / subpath.Delete()Copies a sub-path out as a standalone Shape, or deletes the part you don't want.
Bitmap 8 entries
- shape.BitmapEntry point to the bitmap sub-object. Check Type == 5 first or access raises. Im
- bitmap.ResolutionX / ResolutionYHorizontal and vertical resolution in dpi. 300 is the floor for print; below 200
- bitmap.SizeWidth / SizeHeightThe bitmap's size in pixels, not document size. This is how you tell whether an
- bitmap.ModeColor mode (CMYK, RGB, grayscale, bitmap and so on). The first thing to check in
- bitmap.Resample(Width, Height, Resolution)Resamples, changing pixel count and resolution. Upscaling invents no detail, it
- shape.ConvertToBitmap(Resolution)Turns a vector object into a bitmap (export and reimport, essentially). You lose
- bitmap.SaveAs(FileName, Filter)Writes the bitmap out to its own file. Batch image extraction, sending a client
- shape.ApplyEffectInvert() / ApplyEffectGamma() / ApplyEffectPosterize()Applies color adjustments to a bitmap: invert, gamma, posterize. These are metho
Find & Traverse 11 entries
- coll.FindShapes(query, shapeType, recursive)The main search call. query is a string condition (empty means anything), shapeT
- coll.FindShapes("", 6, True)Every text object. The most-used call of the lot, and it drills through groups a
- coll.FindShapes("", 7, True)Every group. When a document is huge, searching only the current level for group
- coll.FindShapes("", 5, True)Every bitmap.
- coll.FindShapes("", 3, True)Every curve.
- coll.FindShapes("@fill.color='#FF0000'", 0, True)Search by property condition, SQL-ish syntax. It cuts the amount of data coming
- for i in range(1, coll.Count+1): s = coll.Item(i)Manual iteration. Remember that CDR collections start at 1, so Python's range ne
- shape.Type == 7 → shape.ShapesTest for a group, then descend. Cap the recursion depth (8 levels in the code) t
- shape.PowerClip → .ShapesContainer descent. Containers can sit inside containers, so push those onto the
- Deduplicate shapes by StaticIDThe same object can arrive down more than one path (a group query and a containe
- coll.CountElement count for the collection. More reliable than len(coll), which doesn't al
Units & Conversion 8 entries
- doc.UnitThe current document unit (cdrUnit enum). Every geometry API follows it: page wi
- doc.Unit = cdrMillimeterSwitch to millimetres and you can write millimetres directly instead of dividing
- Font size: points vs document unitsThe one measurement that ignores doc.Unit: the size argument of CreateArtisticTe
- 1 inch = 25.4 mm = 72 pt = 96 pxThe conversion basis. 1490/25.4 in the code converts 1490 mm to inches, which te
- page.SizeWidth * page.SizeHeightPage area in square units. Use it as the denominator when you ask what fraction
- shape.GetBoundingBox() → w*hBounding box area, for overlap tests like "are these two G's the same one": over
- shape.Curve.Area / shape.Curve.LengthTrue area and perimeter. Curve objects only.
- RectIntersect: computing intersection areaOverlap of two rectangles: max(0, min(x1+w1, x2+w2) - max(x1, x2)) * max(0, min(
Import / Export 9 entries
- layer.Import(path, 0, None)Imports an image or SVG. 0 means auto-detect the format. The object ends up sele
- doc.ExportEx(path, filter, options)General export. filter takes a cdrFilter value; pass None to use the default opt
- doc.PublishToPDF(path)PDF export. Fewest arguments, most reliable — the first choice for print deliver
- doc.ExportBitmap(...)Bitmap export with a ten-argument signature (width, height, dpi, antialias, dith
- doc.Save()Saves to the existing path.
- doc.SaveAs(path)Saves under a new path and points the document at it.
- doc.PrintOut()Prints. Takes a PrintOptions object.
- doc.Close()Closes the document. Unsaved changes raise a dialog that blocks the script — sav
- app.OpenDocument(path)Opens an existing file. For batch edits, walk them with app.Documents.Item(i).
Enumerations 9 entries
- shape.Type1 rectangle / 2 ellipse / 3 curve / 4 polygon / 5 bitmap / 6 text / 7 group / 8
- CreateArtisticText: Alignment values1 left / 2 right / 3 center / 4 full justify / 5 force justify.
- Fill.Type0 none / 1 uniform / 2 fountain / 3 PostScript / 8 texture / 9 pattern / 10 bitm
- Outline.Type0 = no outline. For everything else — plain, dashed, artistic — Width = 0 is the
- Outline.LineJoin1 = miter. Round and bevel have their own numbers.
- Outline.LineCaps0 flat / 1 round / 2 square.
- Outline.JustificationWhere the outline sits relative to the path. 2 = outside, which is what you want
- doc.Unit(cdrUnit)Millimetres, inches, points, pixels and so on. The numbers can differ between ve
- AlignToShape: type = -1Centers on both axes. That's what the title text in the code uses.
Object Data 6 entries
- shape.NameThe object name shown in the Object Manager. Read/write — name things in one pas
- shape.StaticIDA unique ID within the file, read-only, and stable across reopening. The most de
- shape.URLA hyperlink attached to the object, carried out on PDF export. Interactive broch
- shape.PowerClipParent / shape.Layer / shape.PageWalks back up: which frame clips this object, which layer, which page. Before cl
- doc.PropertiesFile properties (title, author, keywords, notes). Fill them in consistently befo
- doc.MetadataThe metadata collection, finer-grained than Properties and it takes custom field
Align / Distribute 8 entries
- shape.AlignToPage(AlignType)Aligns to the page. The batch-layout workhorse: align everything left, then ever
- shape.AlignToPageCenter(AlignType)Aligns to the page center, strictly, with each axis specified separately. Same v
- shape.AlignToShape(AlignType, TargetShape)Aligns to another object. The argument order is alignment first, target second;
- shape.AlignToShapeRange(AlignType, ShapeRange)Aligns to a group of objects. Use it when a block of images should align as one
- shape.Rotate(Angle)Rotates around the rotation center, in degrees, counter-clockwise positive. Arou
- shape.SetRotationCenter(X, Y)Sets the rotation center. Put it at the page center and rotate in a loop and you
- shape.Skew(Angle)Skew (shear). Cleaner than dragging an edge for italic signage or speed-line hea
- shape.SetBoundingBox(X, Y, Width, Height)Sets position and size in one call — positioning and scaling merged. The least c
Layer Advanced 8 entries
- page.CreateLayer(Name)Adds a layer to the page. Good habit: background, content, text and annotations
- layer.MoveAbove(OtherLayer) / MoveBelow(OtherLayer)Reorders layers. The text layer has to sit on top or images cover it — set it ex
- layer.Visible / layer.Printable / layer.EditableThree layer switches: visible, printable, editable. Locking a layer means Editab
- page.BleedBleed value in document units. Print work needs 3 mm of bleed; check it before e
- doc.AddPages(Count) / doc.DeletePages(Range)Adds and deletes pages. Price tags, business cards, certificates — adding pages
- layer.CreateGuide(X, Y, Angle)Creates a guide on the layer. For consistent margins and type areas, lay the gui
- page.SelectShapesFromRectangle(X1, Y1, X2, Y2)Selects by rectangle, the scripted version of dragging a marquee. Very useful fo
- layer.Paste() / layer.PasteSpecial()Pastes the clipboard onto the named layer rather than the current one. Moving as
View & Performance 6 entries
- app.OptimizationThe performance switch. Turning off screen redraw makes batch output several tim
- app.Refresh()Forces a redraw. With Optimization suppressing redraws, call this when you want
- doc.UnitDocument unit. Every coordinate and dimension follows it: set millimetres and 10
- doc.DirtyWhether the file has unsaved changes. This is what decides whether you save, and
- doc.CreateView() / doc.ViewsOpens a new view window on the document. Useful for watching the whole page whil
- doc.Rulers / doc.GridRulers and the grid object. Reading the grid settings in a script prevents "the
Events 4 entries
- doc.GetUserClick(Prompt)Pauses the script until the user clicks the canvas, then returns that point. Eve
- doc.GetUserArea(Message)Has the user drag out a rectangle and returns it. The right primitive for "only
- app.EventsEnabledGlobal event switch. Turn it off during batch runs to cut the stutter from callb
- app.AdviseEvents(...) / UnadviseEvents(...)Event hooks are a VBA feature. Reaching them from Python over COM effectively do
Recipes 6 entries
- Throttling: why time.sleep(0.2) appears everywhereCorelDRAW is a single-threaded STA server. Python issues commands far faster tha
- Batch undo groupWrap big jobs in BeginCommandGroup / EndCommandGroup and one Ctrl+Z in CDR undoe
- Set font, read back, then fall backSee the code below. This is the most valuable pattern in the entire script: any
- Verify the font before converting to curvesConverting to curves is irreversible, so the order is fixed: set the font → wait
- Process in index-range batchesWith a lot of JSON records, run start/end slices and print "total / pages built
- Skip missing data instead of raisingif not img_find_in: skip_cnt += 1; continue — a missing image gets counted and s
Pitfalls 12 entries
- Wrong font name fails silentlyNo exception, no font change, no warning. You have to read it back to find out i
- Text.FontProperties swallows the font sizeSetting Size through it does nothing. In batch code you have to go through Story
- Collection indexes start at 1Pages.Item(1) is the first page. In Python that means range(1, n+1).
- Objects inside containers have no Left/TopReading Left/Top on a shape inside a PowerClip raises. GetBoundingBox() is the o
- ConvertToCurves is irreversibleAfter ConvertToCurves every text property is gone, and a wrong font is baked in
- Stale object reference after ConvertToCurvesAfter converting or deleting, re-fetch doc.Pages.Item(i) and ActiveLayer, or the
- Do not read a shape after DeleteAfter Delete, even reading StaticID raises. Wrap traversal bodies in try/except.
- HexValue casing is inconsistentNormalize with .upper() before comparing, or your color filter quietly misses th
- len(doc.Pages) may not workUse doc.Pages.Count instead of len(doc.Pages).
- No sleep: CorelDRAW appears to hangRapid-fire calls trigger COM busy errors. 0.2 s for property work, 0.5 s for ima
- Unclosed undo group freezes CorelDRAWIf an exception escapes after BeginCommandGroup, CDR stays stuck inside the grou
- Saving inside a loop is extremely slowExport and save are heavy operations. Run the loop, then save once at the end.