General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Clipboard (copy/paste)Javascript Functionality in Xmetal

  • karthic2861

    Clipboard (copy/paste)Javascript Functionality in Xmetal

    Participants 8
    Replies 9
    Last Activity 10 years, 6 months ago

    I am new to Xmetal.  I want write javascript code for Copy/paste Clipboard functionality in xmetal .

    Please help me

    Thanks in advance

    Reply

    Derek Read

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    See the Programmers Guide and search for “clipboard” and “paste”. Various APIs are available.

    If you need more help than is documented there please describe in more detail what you need help with.

    Reply

    karthic2861

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Hi Derek

    Thanks for the reply

    Actually i am using xmetal via .net I have created one application in .net with xmetal (XML) When i open XML File in Xmetal the output was perfect

    I have a PDF file where i have to  copy text data From that file and if i paste it in winword it's creating new line (n) and the format is good.

    If i did the same process in Xmetal (XML) I am not getting the format of winword  if i have clipboard/paste  functionality i can copy from pdf and i can paste it in xmetal

    Thanks in advance

    Reply

    Derek Read

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Yes, so the clipboard object (see Programmers Guide) gives you access to the Windows clipboard.
    For APIs related to pasting search for the “paste” in the Programmers Guide.

    Reply

    karthic2861

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Thanks Derek

    I will look into that Programmers Guide.

    Still if i have any query I will post it.

    Thank you

    Reply

    karthic2861

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Hi Derek

    Thanks for the suggestion.

    Now when I am using clipboard function. It was able to copy the content but here I am was not able to do paste function. When I search it in Programmer Guide There are two types of Paste function is available.

    1)  CanPaste
    2)  Paste

    Is it possible can you able to give an example how this too function can help with clipboard function.

    Thanks in Advance

    Reply

    Derek Read

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    I think there are too many possibilities here (there are also more paste and clipboard related APIs than you have listed). If you can describe how you need to alter the standard paste functionality maybe I can try to give some hints at the logic and APIs you might need to use to accomplish that.

    Reply

    karthic2861

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Hi Derek,

    As I mention earlier in the post. I will be copying the content from PDF / Winword then. I will paste it in the Xmetal (XML File).

    I tried the paste functionality which is available in the PG.  The problem is I am not getting exactly how it is looking like pdf / winword  It was not creating new line it was pasting in a single para tag. Here I am using para tag instead of p tag for content which is available in DTD.

    It would be more helpful if u provided help in this.

    Thanks in advance.

    Reply

    Derek Read

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    I see. So, you want basically this (I'm still guessing a little bit, sorry if this is wrong):

    You have a custom DTD or Schema and that you have created your own customization for (CSS, CTM, MCR files, possibly other things).
    You copy from a PDF document and that text goes onto the clipboard. The text contains newline characters (one or more “lines” separates by newline characters).
    You paste from the clipboard into XMetaL Author (Enterprise? / Essential?).
    When you paste into XMetaL Author you want each of those “lines” to be inserted into its own element. (Can I assume your DTD is DocBook then?)

    The simplest case (if you are working with text only) is to use the event On_Document_Before_DropText.
    See the Programmers Guide topic “When text is dropped” for a discussion and examples.

    I think the basic logic in your case would be:

    Inside an event called On_Document_Before_DropText
    1) Put the text from ActiveDocument.DropText property into a new string.
    2) Put each “line” from the string into an array by breaking the string on newline characters. If it is this simple I would just use the JScript function [url=http://msdn.microsoft.com/en-us/library/windows/apps/t5az126b%28v=vs.85%29.aspx]split()[/url] (the Programmers Guide example loads the text into MSXML which sounds like overkill in your case).
    3) Build a new string by looping through the array and wrapping each item it contains (each “line”) with tags.
    4) Set the property ActiveDocument.DropText equal to the new string.

    If you need to use the HTML (or anything else) that is put onto the clipboard then things get more complicated. The benefit in this case is that you can try to preserve some of the markup in the original HTML by transforming it to whatever markup makes sense for your DTD / Schema. In this case you need to register a “drop format” with XMetaL in order to fire an event that handles that content. See the Programmers Guide topic “When objects are dropped” (“dropped” in the Windows context here includes “pasted”). It discusses how to do this but does not discuss how to transform HTML into any particular form (that will vary widely depending on your DTD / Schema). The DITA authoring functionality in XMetaL Author Enterprise does this so you could adapt part of that code to use as an example for your own DTD.

    Reply

    karthic2861

    Reply to: Clipboard (copy/paste)Javascript Functionality in Xmetal

    Thanks Derek,

    I got the solution.

    Thank you Very Much

    Reply

  • You must be logged in to reply to this topic.

Lost Your Password?

Products
Downloads
Support