How to put two pictures on the same level in a word file (.docx) python












3















I want to put the logo and the barcode on the same level and not one on top of the other.The logo should stay at the very left and the barcode at the very right of the word file.Here is my code , thank you:enter image description here



import uuid 
import pandas as pd
import pyqrcode
from docx import Document
from docx.shared import Inches


qr=pyqrcode.create(str(uuid.uuid4()).replace('-',''))
qr.png('somecode.png')

df=pd.DataFrame(pd.read_excel('Komplette-
GastAccountFHZugangsdatenFertig.xlsx'))

Attributes=['Name', 'Vorname ', 'Geschlecht', 'Adresse (in Marokko)',
'Telefonnummer', 'E-Mailadresse', 'Studiengang', 'Semester']


document = Document()

document.add_heading('Informationen.',level=0)

document.add_picture('Informatik_Logo.png',height=Inches(1.0))


p = document.add_paragraph()
r = p.add_run()


p_format=p.paragraph_format

p_format.left_indent=Inches(4.5)
r.add_picture('somecode.png',width=Inches(1.0))


table=document.add_table(len(Attributes),2,style='LightGrid-Accent1')


for i in range(len(Attributes)):
row=table.rows[i]
row.cells[0].text=Attributes[i]
Infos=df[Attributes[i]]
string=str(Infos[49])
row.cells[1].text=string



document.save('sample.docx')









share|improve this question



























    3















    I want to put the logo and the barcode on the same level and not one on top of the other.The logo should stay at the very left and the barcode at the very right of the word file.Here is my code , thank you:enter image description here



    import uuid 
    import pandas as pd
    import pyqrcode
    from docx import Document
    from docx.shared import Inches


    qr=pyqrcode.create(str(uuid.uuid4()).replace('-',''))
    qr.png('somecode.png')

    df=pd.DataFrame(pd.read_excel('Komplette-
    GastAccountFHZugangsdatenFertig.xlsx'))

    Attributes=['Name', 'Vorname ', 'Geschlecht', 'Adresse (in Marokko)',
    'Telefonnummer', 'E-Mailadresse', 'Studiengang', 'Semester']


    document = Document()

    document.add_heading('Informationen.',level=0)

    document.add_picture('Informatik_Logo.png',height=Inches(1.0))


    p = document.add_paragraph()
    r = p.add_run()


    p_format=p.paragraph_format

    p_format.left_indent=Inches(4.5)
    r.add_picture('somecode.png',width=Inches(1.0))


    table=document.add_table(len(Attributes),2,style='LightGrid-Accent1')


    for i in range(len(Attributes)):
    row=table.rows[i]
    row.cells[0].text=Attributes[i]
    Infos=df[Attributes[i]]
    string=str(Infos[49])
    row.cells[1].text=string



    document.save('sample.docx')









    share|improve this question

























      3












      3








      3








      I want to put the logo and the barcode on the same level and not one on top of the other.The logo should stay at the very left and the barcode at the very right of the word file.Here is my code , thank you:enter image description here



      import uuid 
      import pandas as pd
      import pyqrcode
      from docx import Document
      from docx.shared import Inches


      qr=pyqrcode.create(str(uuid.uuid4()).replace('-',''))
      qr.png('somecode.png')

      df=pd.DataFrame(pd.read_excel('Komplette-
      GastAccountFHZugangsdatenFertig.xlsx'))

      Attributes=['Name', 'Vorname ', 'Geschlecht', 'Adresse (in Marokko)',
      'Telefonnummer', 'E-Mailadresse', 'Studiengang', 'Semester']


      document = Document()

      document.add_heading('Informationen.',level=0)

      document.add_picture('Informatik_Logo.png',height=Inches(1.0))


      p = document.add_paragraph()
      r = p.add_run()


      p_format=p.paragraph_format

      p_format.left_indent=Inches(4.5)
      r.add_picture('somecode.png',width=Inches(1.0))


      table=document.add_table(len(Attributes),2,style='LightGrid-Accent1')


      for i in range(len(Attributes)):
      row=table.rows[i]
      row.cells[0].text=Attributes[i]
      Infos=df[Attributes[i]]
      string=str(Infos[49])
      row.cells[1].text=string



      document.save('sample.docx')









      share|improve this question














      I want to put the logo and the barcode on the same level and not one on top of the other.The logo should stay at the very left and the barcode at the very right of the word file.Here is my code , thank you:enter image description here



      import uuid 
      import pandas as pd
      import pyqrcode
      from docx import Document
      from docx.shared import Inches


      qr=pyqrcode.create(str(uuid.uuid4()).replace('-',''))
      qr.png('somecode.png')

      df=pd.DataFrame(pd.read_excel('Komplette-
      GastAccountFHZugangsdatenFertig.xlsx'))

      Attributes=['Name', 'Vorname ', 'Geschlecht', 'Adresse (in Marokko)',
      'Telefonnummer', 'E-Mailadresse', 'Studiengang', 'Semester']


      document = Document()

      document.add_heading('Informationen.',level=0)

      document.add_picture('Informatik_Logo.png',height=Inches(1.0))


      p = document.add_paragraph()
      r = p.add_run()


      p_format=p.paragraph_format

      p_format.left_indent=Inches(4.5)
      r.add_picture('somecode.png',width=Inches(1.0))


      table=document.add_table(len(Attributes),2,style='LightGrid-Accent1')


      for i in range(len(Attributes)):
      row=table.rows[i]
      row.cells[0].text=Attributes[i]
      Infos=df[Attributes[i]]
      string=str(Infos[49])
      row.cells[1].text=string



      document.save('sample.docx')






      python docx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 14:10









      Yassine El BaajYassine El Baaj

      376




      376
























          1 Answer
          1






          active

          oldest

          votes


















          1














          From what I see in the documentation, python-docx only currently supports inline pictures, not floating pictures, which means that you can only get the look you currently have. From the docs:




          At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own.




          Based on that last sentence, I think what you're trying to do is currently impossible. A workaround might be to insert a table with one row and two columns, and insert an image in each cell.






          share|improve this answer
























          • Maybe i can create a table and put the 2 pictures on it

            – Yassine El Baaj
            Nov 20 '18 at 14:30











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394878%2fhow-to-put-two-pictures-on-the-same-level-in-a-word-file-docx-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          From what I see in the documentation, python-docx only currently supports inline pictures, not floating pictures, which means that you can only get the look you currently have. From the docs:




          At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own.




          Based on that last sentence, I think what you're trying to do is currently impossible. A workaround might be to insert a table with one row and two columns, and insert an image in each cell.






          share|improve this answer
























          • Maybe i can create a table and put the 2 pictures on it

            – Yassine El Baaj
            Nov 20 '18 at 14:30
















          1














          From what I see in the documentation, python-docx only currently supports inline pictures, not floating pictures, which means that you can only get the look you currently have. From the docs:




          At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own.




          Based on that last sentence, I think what you're trying to do is currently impossible. A workaround might be to insert a table with one row and two columns, and insert an image in each cell.






          share|improve this answer
























          • Maybe i can create a table and put the 2 pictures on it

            – Yassine El Baaj
            Nov 20 '18 at 14:30














          1












          1








          1







          From what I see in the documentation, python-docx only currently supports inline pictures, not floating pictures, which means that you can only get the look you currently have. From the docs:




          At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own.




          Based on that last sentence, I think what you're trying to do is currently impossible. A workaround might be to insert a table with one row and two columns, and insert an image in each cell.






          share|improve this answer













          From what I see in the documentation, python-docx only currently supports inline pictures, not floating pictures, which means that you can only get the look you currently have. From the docs:




          At the time of writing, python-docx only supports inline pictures. Floating pictures can be added. If you have an active use case, submit a feature request on the issue tracker. The Document.add_picture() method adds a specified picture to the end of the document in a paragraph of its own.




          Based on that last sentence, I think what you're trying to do is currently impossible. A workaround might be to insert a table with one row and two columns, and insert an image in each cell.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 20 '18 at 14:16









          Jonah BishopJonah Bishop

          9,02933357




          9,02933357













          • Maybe i can create a table and put the 2 pictures on it

            – Yassine El Baaj
            Nov 20 '18 at 14:30



















          • Maybe i can create a table and put the 2 pictures on it

            – Yassine El Baaj
            Nov 20 '18 at 14:30

















          Maybe i can create a table and put the 2 pictures on it

          – Yassine El Baaj
          Nov 20 '18 at 14:30





          Maybe i can create a table and put the 2 pictures on it

          – Yassine El Baaj
          Nov 20 '18 at 14:30




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53394878%2fhow-to-put-two-pictures-on-the-same-level-in-a-word-file-docx-python%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Guess what letter conforming each word

          Port of Spain

          Run scheduled task as local user group (not BUILTIN)