We need a Macro for CorelDraw X8 (or X6) that will export to an XML file defining 2 lines of text and the coordinates of each character on the page. The page is 4" x 2" and the text will be located in the lower third of the page. The Fonts are (Arial and Arial Narrow 18 point). This is for iStamp software that drives a foil letter stamping machine.
iStamp sent us the attached PDF file to use as a guide.
This is a paid project.
PDF
The entire thing is not clear to me:The x and y value in the XML shall be the offset to a defined point. But: what point of a character is the reference? The centre of an character? The upper/lower left/right position? And what position in the character? Shall have e.g. in the word Egg the 'g' have the same BottomY and / or TopY than the 'E'?To split a string into particular sub shapes is not easy, to keep the string as one item not that difficult, but it's also a problem if you have a string with and without descenders or only small lower case characters ('go' versus 'no', 'no' versus 'No') you face a lot of problems. The description you sent did not gave the answer to this questions.
You make valid points. Since I'm not a coder, I didn't think of all the things you mentioned.
We would be happy with just having the 2 lines of text defined as 2 single strings if that's easier.
As for decenders, these will always be ALL CAPS. That's standard for leather name tags.
Thanks!
This simplifies the work dramatically!
Nevertheless some things has to be clarified before:What is the reference point for the Y-Value on the page and on the text? Is it always the lower side or the upper?Does your Corel document contain the text one by one or do we need to consider a scale?
Using the simplest conditions a solution could be like this:
Sub MkXml()Dim fOutN As String, fOut As IntegerDim Cmd1 As String, Cmd2 As StringDim CurSH As ShapeDim n1 As Integer, n2 As Integer, Ch1 As String, Ch2 As StringActiveDocument.Unit = cdrInchfOutN = ActiveDocument.FullFileNamen1 = InStrRev(fOutN, ".")fOutN = Left(fOutN, n1) + "Txt"fOut = FreeFileOpen fOutN For Output As #fOutPrint #fOut, " <stamp_data>"Print #fOut, " <lines>"For Each CurSH In ActiveLayer.Shapes Cmd1 = "<line" AddXMLValue Cmd1, "X", Format(CurSH.LeftX, "#.00") AddXMLValue Cmd1, "Y", Format(CurSH.BottomY, "#.00") Ch1 = Trim(Str(CurSH.Text.Story.Size)) + "pt " Ch1 = Ch1 + CurSH.Text.Story.Font AddXMLValue Cmd1, "font", Ch1 AddXMLValue Cmd1, "foil", "Gold" Cmd1 = Cmd1 + ">" + CurSH.Text.Story.Characters.All Cmd1 = Cmd1 + "</line>" Print #fOut, " " + Cmd1Next CurSHPrint #fOut, " </lines>"Print #fOut, " </stamp_data>"Close #fOutCmd1 = "notepad " + Chr(34) + fOutN + Chr(34)Shell Cmd1, vbNormalFocusEnd SubSub AddXMLValue(ByRef iLine As String, pName As String, pValue As String)iLine = iLine + " " + pName + "='" + pValue + "'"End Sub
Please be aware that the style of the dot in the values is depending on your local settings of your computer. It may be that it needs to be replaced to a dot. The fine tuning is for such a project the huger effort, but for that you need to know a lot of local details. Maybe you are able to use this sample as base and adapt it for your needs.
clever subroutine- Why not export as ".html" or ".xml" instead of ".txt" or was it just random?
Since this is no fully usable XML-File (<XML ....> ... </XML> is missing), so .Xml is misleading. It is only a text block ready to be copied into an existing XML-File (maybe with more information).If I would know the entire XML-declaration (was not given in the PDF) I could make it complete, then I would name it .Xml!
Excellent point, I figured there was a reason I was not immediately seeing and am glad it is not some surprise 'feature' of Corel lol