Click here to Skip to main content
15,068,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am iterating over a document's paragraphs. I want to copy one paragraph and then paste it on a site, then copy another and then paste it on a different text box on site. I using selenium and docx to do this.

The issue is when the text gets pasted on the website it is in normal plain text and i want it to be formatted with styles like bullets, bolds, underlines etc. How will i achieve this?

I used pyperclip at first then tried using win32clipbard but neither of those seem to work maybe i need to read the documentation of docx correctly but i am a beginner and i can't comprehend that please help this is my first project.


What I have tried:

I used pyperclip at first then tried using win32clipbard but neither of those seem to work maybe i need to read the documentation of docx correctly but i am a beginner and i can't comprehend that.
Posted
Updated 29-Aug-20 4:35am
Comments
Richard MacCutchan 29-Aug-20 7:52am
   
You cannot use simple copy to capture formatted text. Your copy process needs to understand the format of the data you are copying, and capture the format controls. Secondly, the paste process needs to understand the copied data and use the formatting information to produce the same display. But if you are copying from a Word document to a web page it becomes much more complex. This is the sort of project that requires considerably more experience.

1 solution

Have a look at the following python package: klembord · PyPI[^]

Try out - it support setting clipboard with rich text.
   
Comments
Member 14925860 29-Aug-20 12:07pm
   
Yes i am using that but i am a beginner and i am unable to understand how to manipulate text with this module.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900