Skip to content Skip to sidebar Skip to footer

Is There A Way To Format The Clipboard With Italics Through Python?

I'm looking to automate the formatting of sources in a Microsoft word document(.docx). The problem is that some of the text in the new format has to be in italics. Is there a way i

Solution 1:

It is possible with klembord.

Installation

pip install klembord

Code to set italic text to clipboard

import klembord
klembord.init()

# Set HTML formatted clipboard
klembord.set_with_rich_text('', 'Normal text, <i>Italic text</i>')

Short explanation

The set_with_rich_text() takes two arguments. The first argument is what is set to the "plain text" clipboard, which is then used if user pastes for example to Notepad. The second argument is the "HTML formatted clipboard", which is uses if user pastes to a rich text editor, such as Word.

Output when pasted to Word

example output

Post a Comment for "Is There A Way To Format The Clipboard With Italics Through Python?"