|
|
|
|
|
"""
|
|
|
Create a simple test DOCX document for testing the converter
|
|
|
"""
|
|
|
|
|
|
from docx import Document
|
|
|
|
|
|
|
|
|
doc = Document()
|
|
|
|
|
|
|
|
|
doc.add_heading('Document Title', 0)
|
|
|
|
|
|
|
|
|
p = doc.add_paragraph('This is a simple test document to test the DOCX to PDF converter. ')
|
|
|
p.add_run('This text is in bold.').bold = True
|
|
|
p.add_run(' And this is ')
|
|
|
p.add_run('italic text.').italic = True
|
|
|
|
|
|
|
|
|
doc.add_heading('Heading 1', level=1)
|
|
|
doc.add_paragraph('This is a paragraph under Heading 1.')
|
|
|
|
|
|
|
|
|
table = doc.add_table(rows=3, cols=3)
|
|
|
table.style = 'Table Grid'
|
|
|
hdr_cells = table.rows[0].cells
|
|
|
hdr_cells[0].text = 'Header 1'
|
|
|
hdr_cells[1].text = 'Header 2'
|
|
|
hdr_cells[2].text = 'Header 3'
|
|
|
|
|
|
|
|
|
for i in range(1, 3):
|
|
|
row_cells = table.rows[i].cells
|
|
|
row_cells[0].text = f'Row {i}, Col 1'
|
|
|
row_cells[1].text = f'Row {i}, Col 2'
|
|
|
row_cells[2].text = f'Row {i}, Col 3'
|
|
|
|
|
|
|
|
|
doc.add_paragraph('This document contains:')
|
|
|
doc.add_paragraph('• A title', style='List Bullet')
|
|
|
doc.add_paragraph('• Some formatted text', style='List Bullet')
|
|
|
doc.add_paragraph('• A table', style='List Bullet')
|
|
|
|
|
|
|
|
|
doc.save('test_document.docx')
|
|
|
print("Test document created: test_document.docx") |