Python module pptx and formatted input text - python-3.7

I'm using python pptx to present data form a MS Acesss database. In the Assess database I've a long text field with formatted text. When writing this text to ppt the HTML tags are in the text. F.e. text Foo bold in the long text filed gives Foo with the strong-tags in the ppt.
I want the text as formatted in the long text field in the same format in the PPT file and not with the tags. How can I do this?
Used code
for row in cursor.fetchall():
# create 1 slide ------
slide = prs.slides.add_slide(prs.slide_layouts[5])
slide.shapes.title.text = row[1]
shapes = slide.shapes
body_shape = shapes.placeholders[1]
body_shape.text_frame.text = row[3]

Related

in access when a Report containging tabulated data exported to word all table borders/lines disappears

I made a Report containing rows and column. When Exported it to word document ([EXternal Dat tab->export section-> more->). All the text data exported except border lines of tabulated data.
Is there any solution to keep intect the borders of table in expored word/rtf document.
I have also tried "activedocument.tables. borders.enable = true " [earlier suggested][1] but no table object found in expored rtf word file. Images- output in pdf format and output in rtf .
[1]: https://stackoverflow.com/questions/43366381/in-access-how-to-draw-tables-on-report-and-then-export-it-on-word![enter image description here](https://i.stack.imgur.com/Bruru.jpg)

How to display rich text editor value?

I'm new to JasperReports. In my database we saved the rich text editor value in particular column. That value contains raw html. I want to display this value in JasperReports's report without markup language for that i have set the properties 'markup' as html. But in that output the table and header didn't come as actual format.

Printing RTF Text in PDFLib 9 Table Cell

I am using Perl and PDFLib 9 to dynamically create a PDF document. I read some data from a DB and print a table with the data onto the PDF. One field in my DB contains RTF text. How can i print RTF text in a PDFLib table cell? I can't find any example in the PDFLib cookbook.
you can not use RTF text for PDFlib textflow/table cells. So you have to parse your RTF text and "translate" this into textflow notation. Afterwards you can format text within a multiline text by using inline options within create_textflow() or by calling multiple add_textflow() calls.

Writing CR+LF into Open XML from a Database

I'm trying to take some data stored in a database and populate a Word template's Content Controls with it using the Open XML SDK. The data contains paragraphs and so there are carriage return and line feed characters in it. The data is stored in the database as nvarchar.
When I open the generated document, the CR+LF combination shows up as a question mark with a box around it (not sure the name of this character). This is actually two sequences back to back, so CR+LF CR+LF equals two strange characters:
If I unzip the .docx, take the Custom XML part and do a hex dump, I can clearly see 0d0a 0d0a so the CR+LF is there. Word is just printing it weird.
I've tried enforcing UTF-8 encoding in my XmlWriter's settings, but that didn't seem to help:
Dim docStream As New MemoryStream
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Encoding = New UTF8Encoding(False)
Dim docWriter As XmlWriter = XmlTextWriter.Create(docStream, settings)
Does anyone know how I can get Word to render these characters correctly when written to a .docx through the Open XML SDK?
To bind to a Word 2013 rich text control, your XML element has to contain a complete docx. See [MS-DOCX]:
the data stored in the XML element will be an escaped string comprised of a flattened WordprocessingML document representing the formatted data in the structured document tag range.
Earlier versions couldn't bind a rich text control.
Things should work though (with CR/LF, not w:br), if you bind to a plain text control, with multiline set to true.

Conditional Formatting Char vs Numeric in String

I'm trying to do some simple formatting in crystal reports like:
String:
John Smith 212-212-2121
Where the A-Z would be one color and 0-9 would be a different color
I tried this
if NumericText ({myString})
then crRed else crNavy
Any ideas on how to do this ?
As far as I'm aware, you can't have multiple colors in a single string.
You've got a couple of ways of doing this, but they're both kind of clunky, and your string as-is will need to either be parsed or reformatted.
Split your string into two separate formula fields. Color the name field the appropriate color, and the phone number field with the appropriate color, and stick both of these fields into another textbox field. It should look something like this crudely drawn example:
[ [Name formula field] [Phone formula field] ]
Change your string to use HTML, and then format your textbox to use a Text Interpretation of HTML. I can't say this will work 100%, though, because Crystal Reports only supports some HTML.
In any case, your new string would look something like:
< font color='red'>John Smith< /font> < font color='blue'>212-212-2121< /font>
Assuming that they are two fields, embed both in a Text Object. You'll be able to change the text formatting of each field to be the desired color.
Another approach: place both fields on the canvas; color as desired. Add a Text Object to the canvas. Drag each field to the Text Object. This should retain the formatting, but I haven't tested it.
It you need to split the text into name and number create two formula fields. Once created, follow the steps listed earlier.