<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hello</p>
    <p>Thanks for your help but it won't really help me<br>
    </p>
    <p>it's doesn't matter the language,  I could translate in python.</p>
    <p>The main problem is to start from a variable (a html string)<br>
    </p>
    <p>Var1="<h2>Lorem Ipsum?</h2><p>Le
      <strong>Lorem Ipsum</strong> est simplement du faux
      texte employé dans la composition et la mise en page avant
      impression. Le Lorem Ipsum </p>"<br>
    </p>
    <p>and you want to paste it in a odt and keep the format<br>
    </p>
    <p>If I want to use only headless mode, i must find a solution
      without using the SystemClipboard because the clipboard does not
      seem to be accessible</p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Le 26/03/2023 à 19:33, Andrew Pitonyak
      a écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:3adb34-64208200-3-1bd59ce0@154407935">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      I have no idea if this will be of any use to you or not, but...<br>
      <br>
      I do not generally use the API using Python so I cannot comment on
      using Python. <br>
      <br>
      I have also not used headless mode so I cannot comment on what is
      and is not available other than knowing that dispatches are not
      available. <br>
      <br>
      Finally, I have done almost nothing using the clipboard, but... <br>
      <br>
      First note that the clipboard should have content of different
      varieties. I assume that you are aware of this because you have a
      line as follows: <br>
      <br>
       copy_with_format(value, 'text/html')<br>
       <br>
       And if I look at the clipboard I see this as an available type<br>
       <br>
         Dim sClipName As String<br>
        Dim oClip As Object<br>
        Dim oFlavors As Variant<br>
        Dim oFlavor As Variant<br>
        Dim i as Integer<br>
        Dim s as String<br>
        <br>
        sClipName =
      "com.sun.star.datatransfer.clipboard.SystemClipboard"<br>
        oClip = createUnoService(sClipName)<br>
        oFlavors = oClip.getContents().getTransferDataFlavors()<br>
        s = ""<br>
        For i = LBound(oFlavors) To UBound(oFlavors)<br>
          oFlavor = oFlavors(i)<br>
          s = s & i & " : " & oFlavor.MimeType<br>
          s = s & CHR$(10)<br>
        Next<br>
        MsgBox s<br>
        <br>
        <br>
        I see that method defined in this code here: <br>
        <br>
       
<a class="moz-txt-link-freetext" href="https://github.com/Probesys/lotemplate/blob/html_formatting/lotemplate/utils.py">https://github.com/Probesys/lotemplate/blob/html_formatting/lotemplate/utils.py</a><br>
        <br>
        I see that you open a pipe. <br>
        <br>
        I did some experiments and I am extracting the actual HTML. I
      assume that this is not really what you want, but this is how I
      extract it and display it. I was simply playing around with it out
      of curiousity.<br>
        <br>
          Dim sClipName As String<br>
        Dim oClip As Object<br>
        Dim oFlavors As Variant<br>
        Dim oFlavor As Variant<br>
        Dim i as Integer<br>
        Dim idx as Integer<br>
        Dim s as String<br>
        <br>
        sClipName =
      "com.sun.star.datatransfer.clipboard.SystemClipboard"<br>
        oClip = createUnoService(sClipName)<br>
        oFlavors = oClip.getContents().getTransferDataFlavors()<br>
        s = ""<br>
        idx = -1<br>
        For i = LBound(oFlavors) To UBound(oFlavors)<br>
          oFlavor = oFlavors(i)<br>
          s = s & i & " : " & oFlavor.MimeType<br>
          If oFlavor.MimeType = "text/html" Then<br>
            idx = i<br>
          End If<br>
          s = s & CHR$(10)<br>
        Next<br>
        'MsgBox s<br>
        <br>
        If idx < 0 Then<br>
          Print "text/html mime type not found"<br>
          Exit Sub<br>
         End If<br>
        <br>
        ' Now print the actual HMTL as a string!<br>
        Dim oData As Variant<br>
        oData = oClip.getContents().getTransferData(oFlavors(idx))<br>
        s = ""<br>
        For i = LBound(oData) To UBound(oData)<br>
          s = s & CHR$(oData(i))<br>
        Next<br>
        MsgBox s<br>
      <br>
      If I kept going, then I would attempt to then use the transferable
      content directly, which is obtained from oClip.getContents() I
      believe. But, one of the real questions is.... Does the clipboard
      have the contents shown in the correct format? I assume it does. <br>
      <br>
      So, perhaps this helps a little anyway. <br>
      <br>
      Andrew Pitonyak<br>
      <br>
      <br>
      On Sunday, March 26, 2023 06:06 EDT, Zorg
      <a class="moz-txt-link-rfc2396E" href="mailto:zorg@probesys.com"><zorg@probesys.com></a> wrote:<br>
       
      <blockquote type="cite"
        cite="84dd1813-7ecc-4191-83e9-fc8ff6248173@probesys.com"> </blockquote>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <p>Hello</p>
      <p>Hope some can help me here</p>
      <p>Here is my  problem</p>
      <p><br>
        We are developing our software using the uno api python</p>
      <p>We re trying to to copy a string formatted in html in a
        libreoffice odt</p>
      <p>We manage to do it but using dispatcher<br>
        The problem is that dispatcher not working in headless mode so
        il force us to use a xserver (xvfb) et Xclip.</p>
      <p>It work but it's far from being optimized.</p>
      <p>here is the code <a class="moz-txt-link-freetext"
href="https://github.com/Probesys/lotemplate/blob/html_formatting/lotemplate/classes.py"
          moz-do-not-send="true">https://github.com/Probesys/lotemplate/blob/html_formatting/lotemplate/classes.py</a>
        line 349-355</p>
      <p>We have try using XTransferable but without any success.</p>
      <p>Thanks in advance for your help</p>
      <p>Sorg</p>
      <div id="grammalecte_menu_main_button_shadow_host" style="width:
        0px; height: 0px;"> </div>
      <div id="grammalecte_gc_panel_shadow_host" style="width: 0px;
        height: 0px;"> </div>
      <div id="grammalecte_message_box_shadow" style="width: 0px;
        height: 0px;"> </div>
      <br>
      <br>
       
    </blockquote>
    <div id="grammalecte_menu_main_button_shadow_host" style="width:
      0px; height: 0px;"></div>
    <div id="grammalecte_gc_panel_shadow_host" style="width: 0px;
      height: 0px;"></div>
    <div id="grammalecte_message_box_shadow" style="width: 0px; height:
      0px;"></div>
  </body>
</html>