Convert this file into word file without changing any format any colour or any font
Do it
mkdir -p /tmp/workspace/pptx-to-docx && python3 << 'EOF' from pptx import Presentation from pptx.util import Pt from pptx.dml.color import RGBColor import json pptx_path = "/tmp/workspace/attachments/75aeb8ce-0f29-4738-82a0-169e235d288f/PRINCIPLES AND OBJECTIVES OF SKIN.pptx" prs = Presentation(pptx_path) slides_data = [] for slide_num, slide in enumerate(prs.slides, 1): shapes_data = [] for shape in slide.shapes: if shape.has_text_frame: paras = [] for para in shape.text_frame.paragraphs: runs = [] for run in para.runs: font = run.font color = None try: if font.color and font.color.type is not None: rgb = font.color.rgb color = str(rgb) except: pass runs.append({ "text": run.text, "bold": font.bold, "italic": font.italic, "underline": font.underline, "size": font.size.pt if font.size else None, "color": color, "name": font.name }) # paragraph alignment align = None if para.alignment: align = str(para.alignment) paras.append({"runs": runs, "alignment": align, "text": para.text}) shapes_data.append({"paras": paras, "shape_name": shape.name}) slides_data.append({"slide_num": slide_num, "shapes": shapes_data}) print(json.dumps(slides_data, indent=2)) EOF
python3 << 'EOF' from pptx import Presentation from pptx.dml.color import RGBColor from pptx.util import Pt import json pptx_path = "/tmp/workspace/attachments/75aeb8ce-0f29-4738-82a0-169e235d288f/PRINCIPLES AND OBJECTIVES OF SKIN.pptx" prs = Presentation(pptx_path) # Check slide backgrounds and theme colors slide_info = [] for i, slide in enumerate(prs.slides, 1): bg = slide.background fill = bg.fill bg_color = None try: if fill.type is not None: if hasattr(fill, 'fore_color') and fill.fore_color: try: bg_color = str(fill.fore_color.rgb) except: pass except: pass # Check for images has_images = [] for shape in slide.shapes: if shape.shape_type == 13: # MSO_SHAPE_TYPE.PICTURE has_images.append(shape.name) slide_info.append({ "slide": i, "bg_color": bg_color, "images": has_images }) print(json.dumps(slide_info, indent=2)) # Check theme colors theme_xml = prs.core_properties print("\nSlide width:", prs.slide_width.inches, "inches") print("Slide height:", prs.slide_height.inches, "inches") EOF
python3 << 'EOF' from pptx import Presentation from pptx.util import Pt, Inches, Emu from pptx.dml.color import RGBColor from docx import Document from docx.shared import Pt as DocxPt, Inches as DocxInches, RGBColor as DocxRGB from docx.enum.text import WD_ALIGN_PARAGRAPH from docx.oxml.ns import qn from docx.oxml import OxmlElement import io import copy pptx_path = "/tmp/workspace/attachments/75aeb8ce-0f29-4738-82a0-169e235d288f/PRINCIPLES AND OBJECTIVES OF SKIN.pptx" output_path = "/tmp/workspace/pptx-to-docx/PRINCIPLES AND OBJECTIVES OF SKIN.docx" prs = Presentation(pptx_path) doc = Document() # Set page to landscape (widescreen like slides) from docx.oxml.ns import nsmap section = doc.sections[0] section.page_width = DocxInches(11) section.page_height = DocxInches(8.5) section.left_margin = DocxInches(0.75) section.right_margin = DocxInches(0.75) section.top_margin = DocxInches(0.5) section.bottom_margin = DocxInches(0.5) def map_alignment(align_str): if align_str is None: return None if "CENTER" in align_str: return WD_ALIGN_PARAGRAPH.CENTER if "RIGHT" in align_str: return WD_ALIGN_PARAGRAPH.RIGHT if "JUSTIFY" in align_str: return WD_ALIGN_PARAGRAPH.JUSTIFY return WD_ALIGN_PARAGRAPH.LEFT def add_horizontal_rule(doc): """Add a horizontal line as a separator between slides.""" p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(2) p.paragraph_format.space_after = DocxPt(2) pPr = p._p.get_or_add_pPr() pBdr = OxmlElement('w:pBdr') bottom = OxmlElement('w:bottom') bottom.set(qn('w:val'), 'single') bottom.set(qn('w:sz'), '6') bottom.set(qn('w:space'), '1') bottom.set(qn('w:color'), 'AAAAAA') pBdr.append(bottom) pPr.append(pBdr) slide_count = 0 for slide_num, slide in enumerate(prs.slides, 1): has_content = False # Check if slide has any text or images has_text = any( shape.has_text_frame and shape.text_frame.text.strip() for shape in slide.shapes ) has_images = any(shape.shape_type == 13 for shape in slide.shapes) if not has_text and not has_images: continue if slide_count > 0: add_horizontal_rule(doc) slide_count += 1 # Add slide number marker as small gray text slide_marker = doc.add_paragraph() slide_marker.paragraph_format.space_before = DocxPt(4) slide_marker.paragraph_format.space_after = DocxPt(0) run = slide_marker.add_run(f"Slide {slide_num}") run.font.size = DocxPt(8) run.font.color.rgb = DocxRGB(0x99, 0x99, 0x99) run.font.italic = True # Process shapes in order for shape in slide.shapes: # Handle images if shape.shape_type == 13: try: img_stream = io.BytesIO(shape.image.blob) img_para = doc.add_paragraph() img_para.alignment = WD_ALIGN_PARAGRAPH.CENTER img_para.paragraph_format.space_before = DocxPt(4) img_para.paragraph_format.space_after = DocxPt(4) run = img_para.add_run() # Scale image to fit within page width img_width = min(DocxInches(5), DocxInches(shape.width.inches if shape.width else 5)) run.add_picture(img_stream, width=img_width) has_content = True except Exception as e: pass # Handle text if shape.has_text_frame: tf = shape.text_frame if not tf.text.strip(): continue is_title = "Title" in shape.name for para in tf.paragraphs: if not para.text.strip() and not para.runs: # Empty paragraph - add a small space sp = doc.add_paragraph() sp.paragraph_format.space_before = DocxPt(2) sp.paragraph_format.space_after = DocxPt(2) continue # Create paragraph p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(3) p.paragraph_format.space_after = DocxPt(3) # Alignment if para.alignment: p.alignment = map_alignment(str(para.alignment)) elif is_title: p.alignment = WD_ALIGN_PARAGRAPH.LEFT # Add runs for run_data in para.runs: if not run_data.text: continue # Handle vertical tab (slide title line break in pptx) texts = run_data.text.split('\x0b') for idx, text_part in enumerate(texts): if idx > 0: # Add a new paragraph for line break p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(3) p.paragraph_format.space_after = DocxPt(3) if not text_part: continue r = p.add_run(text_part) # Font size if run_data.font.size: r.font.size = DocxPt(run_data.font.size.pt if hasattr(run_data.font.size, 'pt') else run_data.font.size) elif is_title: r.font.size = DocxPt(18) else: r.font.size = DocxPt(12) # Bold if run_data.font.bold is not None: r.font.bold = run_data.font.bold elif is_title: r.font.bold = True # Italic if run_data.font.italic is not None: r.font.italic = run_data.font.italic # Underline if run_data.font.underline is not None: r.font.underline = run_data.font.underline # Color try: if run_data.font.color and run_data.font.color.type is not None: rgb = run_data.font.color.rgb r.font.color.rgb = DocxRGB(rgb[0], rgb[1], rgb[2]) except: pass # Font name if run_data.font.name: r.font.name = run_data.font.name has_content = True doc.save(output_path) print(f"Saved to: {output_path}") print(f"Slides processed: {slide_count}") EOF
python3 -c " from docx import Document doc = Document('/tmp/workspace/pptx-to-docx/PRINCIPLES AND OBJECTIVES OF SKIN.docx') count = 0 for p in doc.paragraphs: if p.text.strip(): style = p.style.name print(f'[{style}] {p.text[:80]}') count += 1 if count > 40: print('...(more paragraphs follow)') break print(f'\nTotal paragraphs with text: {count}+') import os size = os.path.getsize('/tmp/workspace/pptx-to-docx/PRINCIPLES AND OBJECTIVES OF SKIN.docx') print(f'File size: {size:,} bytes ({size/1024:.1f} KB)') "
Where is the word file
Not opening
ls -lh "/tmp/workspace/pptx-to-docx/" && file "/tmp/workspace/pptx-to-docx/PRINCIPLES AND OBJECTIVES OF SKIN.docx"
.docx before opening it in WordSend me file not a link
.docx file automaticallymake it portrait format
python3 << 'EOF' from pptx import Presentation from pptx.util import Pt from docx import Document from docx.shared import Pt as DocxPt, Inches as DocxInches, RGBColor as DocxRGB from docx.enum.text import WD_ALIGN_PARAGRAPH from docx.oxml.ns import qn from docx.oxml import OxmlElement import io pptx_path = "/tmp/workspace/attachments/75aeb8ce-0f29-4738-82a0-169e235d288f/PRINCIPLES AND OBJECTIVES OF SKIN.pptx" output_path = "/tmp/workspace/pptx-to-docx/PRINCIPLES AND OBJECTIVES OF SKIN.docx" prs = Presentation(pptx_path) doc = Document() # Portrait A4 section = doc.sections[0] section.page_width = DocxInches(8.27) section.page_height = DocxInches(11.69) section.left_margin = DocxInches(1) section.right_margin = DocxInches(1) section.top_margin = DocxInches(0.75) section.bottom_margin = DocxInches(0.75) def map_alignment(align_str): if align_str is None: return None if "CENTER" in align_str: return WD_ALIGN_PARAGRAPH.CENTER if "RIGHT" in align_str: return WD_ALIGN_PARAGRAPH.RIGHT if "JUSTIFY" in align_str: return WD_ALIGN_PARAGRAPH.JUSTIFY return WD_ALIGN_PARAGRAPH.LEFT def add_horizontal_rule(doc): p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(2) p.paragraph_format.space_after = DocxPt(2) pPr = p._p.get_or_add_pPr() pBdr = OxmlElement('w:pBdr') bottom = OxmlElement('w:bottom') bottom.set(qn('w:val'), 'single') bottom.set(qn('w:sz'), '6') bottom.set(qn('w:space'), '1') bottom.set(qn('w:color'), 'AAAAAA') pBdr.append(bottom) pPr.append(pBdr) slide_count = 0 for slide_num, slide in enumerate(prs.slides, 1): has_text = any(shape.has_text_frame and shape.text_frame.text.strip() for shape in slide.shapes) has_images = any(shape.shape_type == 13 for shape in slide.shapes) if not has_text and not has_images: continue if slide_count > 0: add_horizontal_rule(doc) slide_count += 1 # Slide number marker slide_marker = doc.add_paragraph() slide_marker.paragraph_format.space_before = DocxPt(4) slide_marker.paragraph_format.space_after = DocxPt(0) run = slide_marker.add_run(f"Slide {slide_num}") run.font.size = DocxPt(8) run.font.color.rgb = DocxRGB(0x99, 0x99, 0x99) run.font.italic = True for shape in slide.shapes: # Images if shape.shape_type == 13: try: img_stream = io.BytesIO(shape.image.blob) img_para = doc.add_paragraph() img_para.alignment = WD_ALIGN_PARAGRAPH.CENTER img_para.paragraph_format.space_before = DocxPt(4) img_para.paragraph_format.space_after = DocxPt(4) r = img_para.add_run() r.add_picture(img_stream, width=DocxInches(5.5)) except: pass # Text if shape.has_text_frame: tf = shape.text_frame if not tf.text.strip(): continue is_title = "Title" in shape.name for para in tf.paragraphs: if not para.text.strip(): sp = doc.add_paragraph() sp.paragraph_format.space_before = DocxPt(1) sp.paragraph_format.space_after = DocxPt(1) continue p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(3) p.paragraph_format.space_after = DocxPt(3) if para.alignment: p.alignment = map_alignment(str(para.alignment)) for run_data in para.runs: if not run_data.text: continue texts = run_data.text.split('\x0b') for idx, text_part in enumerate(texts): if idx > 0: p = doc.add_paragraph() p.paragraph_format.space_before = DocxPt(3) p.paragraph_format.space_after = DocxPt(3) if not text_part: continue r = p.add_run(text_part) # Font size if run_data.font.size: sz = run_data.font.size.pt if hasattr(run_data.font.size, 'pt') else run_data.font.size r.font.size = DocxPt(sz) elif is_title: r.font.size = DocxPt(16) else: r.font.size = DocxPt(11) if run_data.font.bold is not None: r.font.bold = run_data.font.bold elif is_title: r.font.bold = True if run_data.font.italic is not None: r.font.italic = run_data.font.italic if run_data.font.underline is not None: r.font.underline = run_data.font.underline try: if run_data.font.color and run_data.font.color.type is not None: rgb = run_data.font.color.rgb r.font.color.rgb = DocxRGB(rgb[0], rgb[1], rgb[2]) except: pass if run_data.font.name: r.font.name = run_data.font.name doc.save(output_path) import os size = os.path.getsize(output_path) print(f"Done! Slides processed: {slide_count}") print(f"File size: {size:,} bytes ({size/1024/1024:.2f} MB)") print(f"Saved: {output_path}") EOF