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.
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.
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.
I must confess I do not understand very well what exactly needed, even looking at pdf file...
So, can you post a corel file containing a sample text (with more lines, if this is the case) and xml necessary file to be the output? Even if it is created manually by somebody knowing the real need of the stamping machine... Can you ask that to iStamp?
Is that 'specification' made based on the machine written requirements or by somebody really knowing the machine needs, knowing also something about Corel?
In addition to that:
The text may contain only one row? And for each so named 'line' there is an Artistic Text? Or Artistic Text may contain many lines?
All the text of an Artistic Text will contain the same font and size for all characters? If the text is bold or italic it doesn't matter? If matters, in which tag and how to fill this piece of information?
Where from the information regarding the 'foil' color parameter will be taken? Should the application ask and somebody will fill it? Directly or selecting a text from a ComboBox?
If the jpg/png/bmp file containing the picture of the text to be stamped will have an element containing its path, where in the XML file to be that element and how to be named?
Which is the meaning of the next request?: "In addition, any control information that would be helpful to the operator (account number, order number, number of tags, due date, tag type code, etc.) could be included and displayed to the operator." Al this pieces of information should be contained in the XML file? If yes from where the application should take the information (except due date)? If not, in which phase and how to be they filled?
Should this application be used in Order Entry having an interface where the operator will manually introduce 'account number', 'order number'? That ''numbers of tags' does refer to line numbers? If not what does it mean? What does 'tag type code' mean?
If the two linked files cannot be provided, at least clarification about the rest of the issues should be necessary before starting such a project... And you will test the code and resulted file according to your needs and give feedback.
If I will understand all that I will maybe take it like a challenge and I will do it for free...
Attached is the CorelDraw X8 file with the text and the positioning. It's just 2 lines of text. The fonts will always be either Arial or Arial Narrow, Centered, and positioned as they are in this file. Thanks for all the help.
XML Test 1.zip