i want to write a bullet list of texts in a table cell and langue is right to left but bullet stay at left of my text
i tried TextDirection in my code but didnt work
- Code: Select all
section.TextDirection = TextDirection.TopToBottomRotated
cell.CellFormat.TextDirection = TextDirection.TopToBottomRotated
paragraph.TextDirection = TextDirection.TopToBottomRotated
here is bullet list style from tutorial
- Code: Select all
# Create a bulleted list style
listStyle = ListStyle(document, ListType.Bulleted)
listStyle.Name = "bulletedList"
listStyle.Levels[0].BulletCharacter = "\u00B7"
listStyle.Levels[0].CharacterFormat.FontName = "Symbol"
listStyle.Levels[0].TextPosition = 20
document.ListStyles.Add(listStyle)
at first i wonder why do TopToBottomRotated work properly for writing hoerizentaly
at second i dont know what should i do to set bullets at right
here is full code
- Code: Select all
# report function
def ExportWord(self, ):
print("report")
# check DraftCheckBox
IsDraft = self.ui.DraftCheckBox.isChecked()
print(IsDraft)
# Create an object of the Document class
document = Document()
# Create a bulleted list style
listStyle = ListStyle(document, ListType.Bulleted)
listStyle.Name = "bulletedList"
listStyle.Levels[0].BulletCharacter = "\u00B7"
listStyle.Levels[0].CharacterFormat.FontName = "Symbol"
listStyle.Levels[0].TextPosition = 20
document.ListStyles.Add(listStyle)
# Add blank page section
section = document.AddSection()
# Add header page section
section = document.AddSection()
section.TextDirection = TextDirection.TopToBottomRotated
# Add a title
titleParagraph = section.AddParagraph()
titleParagraph.AppendText("اطلاعات سربرگ")
titleParagraph.Format.HorizontalAlignment = HorizontalAlignment.Right
# Apply heading1 to the title
titleParagraph.ApplyStyle(BuiltinStyle.Heading1)
# blank line
bodyParagraph_1 = section.AddParagraph()
# load assesment data
i = self.FindAssesmntData(self.current_assesment.AssesmentID)
AssesmentData = self.AssesmentsList[i]
print(AssesmentData)
# add table
# Create a table
table = section.AddTable(True)
# Set the width of table
table.PreferredWidth = PreferredWidth(WidthType.Percentage, int(100))
# Set the border of table
table.TableFormat.Borders.BorderType = BorderStyle.Single
table.TableFormat.Borders.LineWidth = 1.0
table.TableFormat.Borders.Color = Color.get_Black()
# Add first row
row = table.AddRow(False, 4)
row.Height = 20.0
# Add data to the cells
cell = row.Cells[0]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText(AssesmentData[2])
cell = row.Cells[1]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("سازمان")
cell = row.Cells[2]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText(AssesmentData[1])
cell = row.Cells[3]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("نام")
# Add the second row
row = table.AddRow(False, 4)
row.Height = 20.0
cell = row.Cells[0]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText(AssesmentData[4])
cell = row.Cells[1]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("تاریخ پایان")
cell = row.Cells[2]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText(AssesmentData[3])
cell = row.Cells[3]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("تاریخ شروع")
# Add the third row
row = table.AddRow(False, 4)
row.Height = 20.0
# merge celes
table.ApplyHorizontalMerge(2, 0, 1)
table.ApplyHorizontalMerge(2, 2, 3)
# add data
cell = row.Cells[0]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("ممیزین")
cell = row.Cells[2]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText("تأمین کنندگان")
# Add the forth row
row = table.AddRow(False, 4)
row.Height = 20.0
# merge celes
table.ApplyHorizontalMerge(3, 0, 1)
table.ApplyHorizontalMerge(3, 2, 3)
# add data
cell = row.Cells[0]
cell.CellFormat.HorizontalAlignment = HorizontalAlignment.Right
cell.CellFormat.TextDirection = TextDirection.TopToBottomRotated
auditors_list = eval(AssesmentData[6])
for person_info in auditors_list:
print(person_info)
paragraph = cell.AddParagraph()
paragraph.TextDirection = TextDirection.TopToBottomRotated
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Right
paragraph.AppendText(f"{person_info[0]} | {person_info[1]}")
paragraph.ListFormat.ApplyStyle("bulletedList")
paragraph.ListFormat.ListLevelNumber = 0
# paragraph = cell.AddParagraph()
# paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
# paragraph.AppendText()
cell = row.Cells[2]
cell.CellFormat.VerticalAlignment = VerticalAlignment.Middle
paragraph = cell.AddParagraph()
paragraph.Format.HorizontalAlignment = HorizontalAlignment.Center
paragraph.AppendText(AssesmentData[7])
# # Add the table to the section
# section.Tables.Add(table)
# Add Report for quality capability section
section = document.AddSection()
# Add two paragraphs
bodyParagraph_1 = section.AddParagraph()
bodyParagraph_1.AppendText("'گزارش کیفیت")
bodyParagraph_1.Format.HorizontalAlignment = HorizontalAlignment.Right
# add header
# Get the first section
section = document.Sections[0]
# Get header
header = section.HeadersFooters.Header
# Add a paragraph to the header and set its alignment style
headerParagraph = header.AddParagraph()
headerParagraph.Format.HorizontalAlignment = HorizontalAlignment.Center
# Add text to the header paragraph and set its font style
text = headerParagraph.AppendText("گزارش ممیزی فرآیند\n")
text.CharacterFormat.FontName = "IRANSansX"
text.CharacterFormat.FontSize = 15
# text.CharacterFormat.Bold = True
# text.CharacterFormat.TextColor = Color.get_Blue()
# Set the border of the header paragraph
headerParagraph.Format.Borders.Bottom.BorderType = BorderStyle.Single
headerParagraph.Format.Borders.Bottom.Space = 0.05
# Save the resulting document
document.SaveToFile("output/TextWatermark.docx")
# # Close the Document object
# document.Close()
print("dpcumnet closed")
# wateermark
# # Create an object of the TextWatermark class
# txtWatermark = TextWatermark()
# # Set watermark text, font size, text color and layout
# txtWatermark.Text = "پیش نویس"
# txtWatermark.FontSize = 95
# # txtWatermark.Color = Color.get_Red()
# # txtWatermark.Layout = WatermarkLayout.Diagonal
# # Set the text watermark as the watermark of the document
# document.Watermark = txtWatermark
here is bullet list image
regrads