| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import os
- from markdown_pdf import MarkdownPdf, Section
- import fitz
- docs_dir = r"c:/Users/lanfr144/Documents/DOPRO1/Antigravity/Food/docs"
- md_file = os.path.join(docs_dir, "Installation_Guide.md")
- with open(md_file, "r", encoding="utf-8") as f:
- md_content = f.read()
- # Current CSS from generate_pdfs.py
- user_css = """
- * {
- color: #1a1a1a !important;
- }
- body {
- font-family: 'Helvetica', 'Arial', sans-serif !important;
- color: #1a1a1a !important;
- background-color: #ffffff !important;
- }
- h1, h2, h3, h4, h5, h6, h1 *, h2 *, h3 *, h4 *, h5 *, h6 * {
- color: #000000 !important;
- margin-top: 18px !important;
- margin-bottom: 8px !important;
- }
- pre {
- background-color: #f8f9fa !important;
- border: 1px solid #e9ecef !important;
- padding: 2px !important;
- margin-top: 8px !important;
- margin-bottom: 16px !important;
- border-radius: 3px !important;
- font-family: 'Courier New', 'Courier', monospace !important;
- font-size: 10pt !important;
- white-space: pre-wrap !important;
- word-break: break-all !important;
- }
- pre code, pre * {
- font-family: 'Courier New', 'Courier', monospace !important;
- font-size: 10pt !important;
- color: #212529 !important;
- background-color: #f8f9fa !important;
- white-space: pre-wrap !important;
- word-break: break-all !important;
- }
- code {
- font-family: 'Courier New', 'Courier', monospace !important;
- font-size: 10pt !important;
- color: #b02a37 !important;
- background-color: #f8f9fa !important;
- padding: 2px 4px !important;
- border-radius: 3px !important;
- white-space: pre-wrap !important;
- word-break: break-all !important;
- }
- a, a * {
- color: #0d6efd !important;
- }
- blockquote, blockquote * {
- color: #555555 !important;
- border-left: 4px solid #ccc !important;
- padding-left: 10px !important;
- }
- table, tr, td, th, table * {
- color: #1a1a1a !important;
- border-color: #cccccc !important;
- }
- th {
- background-color: #f2f2f2 !important;
- }
- ul, li {
- list-style-type: disc !important;
- }
- """
- pdf = MarkdownPdf()
- section = Section(md_content, paper_size="A4", root=docs_dir)
- pdf.add_section(section, user_css=user_css)
- pdf.save("scratch/debug_install.pdf")
- doc = fitz.open("scratch/debug_install.pdf")
- print("Text on Page 2:")
- print(doc[1].get_text())
- doc.close()
|