I want the photo I have sent same in the clearer version of it without any changes in spelling and wordsin the pdf format
mkdir -p /tmp/workspace/stanya-pdf && ls /tmp/workspace/
~/stanya-pdf/create_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.lib import colors
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
# ── output path ──────────────────────────────────────────────────────────────
OUTPUT = "/tmp/workspace/stanya-pdf/Topic4_Stanya_Vijnana.pdf"
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=1.8*cm,
rightMargin=1.8*cm,
topMargin=1.5*cm,
bottomMargin=1.5*cm,
)
W, H = A4
COL_W = (W - 3.6*cm) / 2 # half the usable width
# ── colour palette ───────────────────────────────────────────────────────────
RED = colors.HexColor("#C0392B")
BLUE = colors.HexColor("#2471A3")
LBLUE = colors.HexColor("#D6EAF8")
LYELLOW = colors.HexColor("#FDFEFE")
ORANGE = colors.HexColor("#E67E22")
GREEN = colors.HexColor("#1E8449")
PURPLE = colors.HexColor("#7D3C98")
DGRAY = colors.HexColor("#2C3E50")
LGRAY = colors.HexColor("#F2F3F4")
WHITE = colors.white
BLACK = colors.black
styles = getSampleStyleSheet()
# ── custom paragraph styles ──────────────────────────────────────────────────
def S(name, **kw):
base = kw.pop("parent", "Normal")
return ParagraphStyle(name, parent=styles[base], **kw)
page_header = S("PageHeader", fontSize=8, textColor=DGRAY, alignment=TA_LEFT, spaceAfter=2)
title_style = S("TitleStyle", fontSize=13, textColor=PURPLE, alignment=TA_CENTER,
spaceAfter=6, fontName="Helvetica-Bold", borderPad=4)
point_style = S("PointStyle", fontSize=10, textColor=BLACK, alignment=TA_LEFT,
spaceAfter=4, fontName="Helvetica-Bold")
section_head = S("SectionHead", fontSize=11, textColor=WHITE, alignment=TA_LEFT,
fontName="Helvetica-Bold", spaceAfter=2)
sub_head = S("SubHead", fontSize=10, textColor=BLUE, fontName="Helvetica-Bold",
spaceAfter=2, spaceBefore=4)
body = S("Body", fontSize=9, alignment=TA_JUSTIFY, spaceAfter=3, leading=13)
body_small = S("BodySmall", fontSize=8.5, alignment=TA_JUSTIFY, spaceAfter=3, leading=12)
sanskrit = S("Sanskrit", fontSize=8.5, alignment=TA_CENTER, textColor=DGRAY,
spaceAfter=2, leading=12, fontName="Helvetica-Oblique")
ref_style = S("Ref", fontSize=8, textColor=DGRAY, alignment=TA_CENTER, spaceAfter=3)
bullet_body = S("BulletBody", fontSize=9, leftIndent=14, spaceAfter=2, leading=13,
bulletIndent=4)
# ── helper: coloured box heading ─────────────────────────────────────────────
def boxed_heading(text, bg=RED, fg=WHITE, font_size=10):
"""Return a Table that looks like a coloured label."""
p = Paragraph(f"<b>{text}</b>", ParagraphStyle(
"bh", fontSize=font_size, textColor=fg, fontName="Helvetica-Bold",
alignment=TA_CENTER, leading=font_size+2))
t = Table([[p]], colWidths=[COL_W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("ROUNDEDCORNERS", [4]),
]))
return t
def inline_label(text, bg=BLUE, fg=WHITE, font_size=9):
p = Paragraph(f"<b>{text}</b>", ParagraphStyle(
"il", fontSize=font_size, textColor=fg, fontName="Helvetica-Bold",
alignment=TA_LEFT, leading=font_size+2))
t = Table([[p]])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
]))
return t
# ── LEFT column content ──────────────────────────────────────────────────────
def left_col():
elems = []
# Red box heading
elems.append(boxed_heading("STANYAAPANAYANAM", bg=RED))
elems.append(Paragraph("(Weaning)", S("ctr", fontSize=9, alignment=TA_CENTER, spaceAfter=4)))
elems.append(Paragraph(
"The child should be taken off from the breast gradually to fed with "
"other solid and nutrient food when his tooth eruption starts.", body))
elems.append(Paragraph(
"अहैर्व आत्मरात्मं अत्नेयपात्मयेत् रतस्कम् ।", sanskrit))
elems.append(Paragraph("A.H.U. 1/38", ref_style))
elems.append(Paragraph("Ancient method to detach the child from breast are", body))
elems.append(Paragraph(
"कुष्ठग्रासाने स्नेहसंकल्पश्च स्मरणोपचरे।<br/>"
"बीघपातरोधकाविकोकृप्तिचान्तक्लेशे।।", sanskrit))
elems.append(Paragraph("A.S. U. 1/41", ref_style))
elems.append(Paragraph(u"\u2022 \u0938\u094d\u0928\u0947\u0939\u0938\u0902\u0915\u0932\u094d\u092a\u0923\u093e (Attraction of love to other things)", bullet_body))
elems.append(Paragraph(u"\u2022 \u092c\u0940\u0918\u092a\u093e\u0924\u0930\u094b\u0927\u092e\u094d (Horrible scenes)", bullet_body))
elems.append(Paragraph(u"\u2022 \u092f\u093e\u092a\u0915\u093e\u0938\u093e\u0930\u0938 (Applying laakshaaras)", bullet_body))
elems.append(Paragraph(u"\u2022 \u0915\u0943\u0924\u093f\u092e\u0935\u094d\u092f\u0924\u094d\u0928\u0928\u092e\u094d (Showing artificial injuries)", bullet_body))
elems.append(Paragraph(
"Such child should be fed with modakas of preenasa & jeevana in nature.", body))
elems.append(Paragraph(
"दियालनरामभुपकस्तुनाजलरतोपागे।<br/>"
"अपरतनना संयोग्या प्रीणनी मोदका निशो।।", sanskrit))
elems.append(Paragraph("A.H.U. 1/38", ref_style))
elems.append(Paragraph(
"After the 12<sup>th</sup> month, the child should be given different types of food "
"according to his desire.", body))
elems.append(Paragraph(
"शालिर्नां पच्तिक्रवा वा पुराणानि विनोधत।<br/>"
"लघुदोहित्स्तुभूपुटे: खजितो सामिथा इत।।<br/>"
"सन्देहलवणा लेह्या धालनां पथिचर्चया। K.S. Khi. 12/19-20", sanskrit))
elems.append(Paragraph(
"In this context, food is advised to be mixed with lavana. Lavana rasa is "
"known to enhance appetite and remove srotorodha ensuring maximum "
"bioavailability of nutrients. Lehya has been indicated so that the food is "
"given in the semi solid form for better deglutition.", body))
elems.append(Paragraph(
"For a baby with predominance of pitta in constitution mridweeks "
"with honey and ghrita should always be given. Similarly, in predominance "
"of vaata, an appreciable amount of maatulunga rasa and salt should be used.", body))
elems.append(Paragraph(
"At least 8-10% of energy should be obtained from proteins. Animal "
"proteins like milk, egg, meat should be given. Dark leafy vegetables are "
"given to add iron. Well-cooked gruel is another ideal food which can be "
"given during weaning. Mashed bananas cooked in milk alongwith "
"mashed pulses can also be given.", body))
elems.append(Paragraph(
"By 8-9 months, the child should be able to consume cooked food "
"similar to that of adults.", body))
# Frequency of feeding label
elems.append(inline_label("Frequency of feeding", bg=colors.HexColor("#F0B27A"), fg=BLACK))
elems.append(Spacer(1, 2))
elems.append(Paragraph(
"Regular intake of food is advised after 12 months. The factors influencing "
"the frequency of feeding are:", body))
elems.append(Paragraph("1 Desam-Regional practice", bullet_body))
elems.append(Paragraph("2 Agnibelam-Digestive capacity", bullet_body))
elems.append(Paragraph("3 Balam-Activity", bullet_body))
elems.append(Paragraph("4 Kaalam-Season", bullet_body))
elems.append(Paragraph(
"<i>In spite of all these parameters, the ultimate criteria to determine the "
"frequency of feeding should be the HUNGER of the child alone. "
"(demand schedule).</i>", body))
return elems
# ── RIGHT column content ─────────────────────────────────────────────────────
def right_col():
elems = []
# Blue "Weaning" label
elems.append(inline_label("Weaning", bg=BLUE, fg=WHITE))
elems.append(Spacer(1, 3))
elems.append(Paragraph(
"Since human milk or cow's milk is not sufficient to meet the energy and "
"proteins requirements for the growth of infants, it is necessary to provide "
"nutritional supplements by the age of 4 months.", body))
# Definition label
elems.append(inline_label("Definition", bg=BLUE, fg=WHITE))
elems.append(Spacer(1, 3))
elems.append(Paragraph(
"Wenian (English) means 'to accustom'. Weaning means accustoming "
"the infant to nourishment other than mother's milk.", body))
elems.append(Paragraph("Weaning foods should be", body))
for item in [
"Culturally acceptable",
"Adequate",
"Locally available & inexpensive",
"Easily prepared at home",
"Clean & hygienic",
"Physiologically stable, suitable, easily digestible and nourishing",
]:
elems.append(Paragraph(f"\u2022 {item}", bullet_body))
# Time label
elems.append(Spacer(1, 4))
elems.append(inline_label("Time", bg=BLUE, fg=WHITE))
elems.append(Spacer(1, 3))
elems.append(Paragraph(
"Weaning should be gradual. It should be begun at the age of 4 months "
"and completed by 9 months of age.", body))
# Method label
elems.append(inline_label("Method", bg=BLUE, fg=WHITE))
elems.append(Spacer(1, 3))
for item in [
"The amount of new foods given should be gradually increased "
"(paadaamsika krama can be adopted).",
"Before introducing a new type of food, any one type should be given "
"for several days.",
"Gradual process helps the infant to accept new food without upsetting the GIT.",
]:
elems.append(Paragraph(f"\u2022 {item}", bullet_body))
return elems
# ── Assemble the page ────────────────────────────────────────────────────────
story = []
# Page-level header bar text
story.append(Paragraph(
"Average requirement of breast milk: 100ml/kg/24hoursby3rd day 150ml/kg/24hoursby10th day",
page_header))
story.append(HRFlowable(width="100%", thickness=0.5, color=DGRAY, spaceAfter=6))
# Topic title (purple pill)
title_p = Paragraph(
"<b>Topic 4. Stanya Vijnana (Breast Milk)</b>",
ParagraphStyle("tp", fontSize=13, textColor=PURPLE, alignment=TA_CENTER,
fontName="Helvetica-Bold", leading=16))
title_tbl = Table([[title_p]], colWidths=[W - 3.6*cm])
title_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), colors.HexColor("#F4ECF7")),
("BOX", (0,0), (-1,-1), 1, PURPLE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
]))
story.append(title_tbl)
story.append(Spacer(1, 6))
# POINT line
story.append(Paragraph(
"<b>POINT:</b> Explain Stanyapanayana.",
ParagraphStyle("pt", fontSize=10, spaceAfter=8, leading=14)))
# Two-column table: left | right
left_cells = left_col()
right_cells = right_col()
# Build inner tables for each column
def build_inner(elems, w):
rows = [[e] for e in elems]
t = Table(rows, colWidths=[w])
t.setStyle(TableStyle([
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 0),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
return t
col_gap = 0.6*cm
actual_col_w = (W - 3.6*cm - col_gap) / 2
left_tbl = build_inner(left_cells, actual_col_w)
right_tbl = build_inner(right_cells, actual_col_w)
two_col = Table([[left_tbl, right_tbl]], colWidths=[actual_col_w, actual_col_w],
hAlign="LEFT")
two_col.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("LINEAFTER", (0,0), (0,-1), 0.5, colors.HexColor("#BFC9CA")),
("RIGHTPADDING", (0,0), (0,-1), col_gap/2),
("LEFTPADDING", (1,0), (1,-1), col_gap/2),
]))
story.append(two_col)
# Build PDF
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
cd /tmp/workspace/stanya-pdf && python create_pdf.py 2>&1
Topic4 Stanya Vijnana
PDF Document · PDF
Why am I not getting the ayurvedic terminologies and sholka I want that too be included in the document please
fc-list | grep -i "noto" | grep -i "devanagari" | head -10
fc-list | grep -i "devanagari" | head -20; echo "---"; fc-list | grep -i "noto" | head -20
python3 -c " from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics pdfmetrics.registerFont(TTFont('Devanagari', '/usr/share/fonts/google-droid-sans-fonts/DroidSansDevanagari-Regular.ttf')) print('Font registered OK') # quick test: can we encode Devanagari chars? import unicodedata sample = 'अहैर्व आत्मरात्मं' for ch in sample: print(repr(ch), unicodedata.name(ch, 'UNKNOWN')) "
python3 -c " # Test if ReportLab can actually render Devanagari with this font from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics from reportlab.platypus import SimpleDocTemplate, Paragraph from reportlab.lib.styles import ParagraphStyle from reportlab.lib.pagesizes import A4 pdfmetrics.registerFont(TTFont('Devanagari', '/usr/share/fonts/google-droid-sans-fonts/DroidSansDevanagari-Regular.ttf')) doc = SimpleDocTemplate('/tmp/workspace/stanya-pdf/test_deva.pdf', pagesize=A4) story = [Paragraph('अहैर्व आत्मरात्मं अत्नेयपात्मयेत् रतस्कम् ।', ParagraphStyle('t', fontName='Devanagari', fontSize=12))] doc.build(story) print('Success') "
~/stanya-pdf/create_pdf_v2.py
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
# ── Register Devanagari font ──────────────────────────────────────────────────
DEVA_FONT_PATH = "/usr/share/fonts/google-droid-sans-fonts/DroidSansDevanagari-Regular.ttf"
pdfmetrics.registerFont(TTFont("Devanagari", DEVA_FONT_PATH))
OUTPUT = "/tmp/workspace/stanya-pdf/Topic4_Stanya_Vijnana.pdf"
W, H = A4
MARGIN = 1.8 * cm
USABLE_W = W - 2 * MARGIN
GAP = 0.5 * cm
COL_W = (USABLE_W - GAP) / 2
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=MARGIN,
rightMargin=MARGIN,
topMargin=1.4 * cm,
bottomMargin=1.4 * cm,
)
# ── Colours ───────────────────────────────────────────────────────────────────
RED = colors.HexColor("#C0392B")
BLUE = colors.HexColor("#1A5276")
PURPLE = colors.HexColor("#7D3C98")
ORANGE = colors.HexColor("#D35400")
DGRAY = colors.HexColor("#2C3E50")
MGRAY = colors.HexColor("#BFC9CA")
WHITE = colors.white
BLACK = colors.black
LBLUE = colors.HexColor("#D6EAF8")
LPURP = colors.HexColor("#F4ECF7")
LORAN = colors.HexColor("#FDEBD0")
styles = getSampleStyleSheet()
def PS(name, **kw):
parent = kw.pop("parent", "Normal")
return ParagraphStyle(name, parent=styles[parent], **kw)
# ── Paragraph styles ──────────────────────────────────────────────────────────
page_hdr = PS("PageHdr", fontSize=7.5, textColor=DGRAY, alignment=TA_LEFT, spaceAfter=2)
body = PS("Body", fontSize=9, alignment=TA_JUSTIFY, spaceAfter=3, leading=13)
body_it = PS("BodyIt", fontSize=9, alignment=TA_JUSTIFY, spaceAfter=3, leading=13,
fontName="Helvetica-Oblique")
bullet = PS("Bullet", fontSize=9, leftIndent=12, bulletIndent=2, spaceAfter=2, leading=13)
ref = PS("Ref", fontSize=8, textColor=DGRAY, alignment=TA_CENTER, spaceAfter=3)
# Devanagari / Sanskrit style
deva = PS("Deva", fontSize=9, fontName="Devanagari", alignment=TA_CENTER,
leading=14, spaceAfter=1, textColor=DGRAY)
deva_ref = PS("DevaRef", fontSize=8, alignment=TA_CENTER, spaceAfter=4, textColor=DGRAY,
fontName="Helvetica-Oblique")
point_hdr = PS("PointHdr", fontSize=10, fontName="Helvetica-Bold", spaceAfter=6)
# ── Helpers ───────────────────────────────────────────────────────────────────
def colored_label(text, bg, fg=WHITE, font_size=9, width=None):
"""Small pill-shaped coloured label."""
p = Paragraph(f"<b>{text}</b>",
ParagraphStyle("cl", fontSize=font_size, textColor=fg,
fontName="Helvetica-Bold", alignment=TA_LEFT,
leading=font_size + 3))
cw = [width] if width else [len(text) * font_size * 0.62 + 14]
t = Table([[p]], colWidths=cw)
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
]))
return t
def red_box_header(text, width):
"""Full-width red box with white bold text (for STANYAAPANAYANAM)."""
p = Paragraph(f"<b>{text}</b>",
ParagraphStyle("rbh", fontSize=10, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, leading=13))
t = Table([[p]], colWidths=[width])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), RED),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
]))
return t
def shloka(*lines, ref_text=None):
"""Return a list of flowables: Devanagari lines + optional italic reference."""
elems = []
for line in lines:
elems.append(Paragraph(line, deva))
if ref_text:
elems.append(Paragraph(ref_text, deva_ref))
return elems
# ── LEFT COLUMN ───────────────────────────────────────────────────────────────
def left_col():
e = []
# Header box
e.append(red_box_header("STANYAAPANAYANAM", COL_W))
e.append(Paragraph("(Weaning)", PS("ctr", fontSize=9, alignment=TA_CENTER, spaceAfter=4)))
e.append(Paragraph(
"The child should be taken off from the breast gradually to fed with "
"other solid and nutrient food when his tooth eruption starts.", body))
# Shloka 1 (Devanagari)
e += shloka(
"अहैर्व आत्मरात्मं अत्नेयपात्मयेत् रतस्कम् ।",
ref_text="A.H.U. 1/38"
)
e.append(Paragraph("Ancient method to detach the child from breast are", body))
# Shloka 2 (Devanagari)
e += shloka(
"कुष्ठग्रासाने स्नेहसंकल्पश्च स्मरणोपचरे ।",
"बीघपातरोधकाविकोकृप्तिचान्तक्लेशे ।।",
ref_text="A.S. U. 1/41"
)
# 4 bullet methods
for item in [
"स्नेहसंकल्पणा (Attraction of love to other things)",
"बीघपातरोधम् (Horrible scenes)",
"यापकासारस (Applying laakshaaras)",
"कृतिमव्यत्ननम् (Showing artificial injuries)",
]:
e.append(Paragraph(f"\u2022 {item}", bullet))
e.append(Paragraph(
"Such child should be fed with modakas of preenasa & jeevana in nature.", body))
# Shloka 3 (Devanagari)
e += shloka(
"दियालनरामभुपकस्तुनाजलरतोपागे ।",
"अपरतनना संयोग्या प्रीणनी मोदका निशो ।।",
ref_text="A.H.U. 1/38"
)
e.append(Paragraph(
"After the 12<sup>th</sup> month, the child should be given different "
"types of food according to his desire.", body))
# Shloka 4 (multi-line Devanagari + ref)
e += shloka(
"शालिर्नां पच्तिक्रवा वा पुराणानि विनोधत ।",
"लघुदोहित्स्तुभूपुटे: खजितो सामिथा इत ।।",
"सन्देहलवणा लेह्या धालनां पथिचर्चया ।",
ref_text="K.S. Khi. 12/19-20"
)
e.append(Paragraph(
"In this context, food is advised to be mixed with lavana. Lavana rasa is "
"known to enhance appetite and remove srotorodha ensuring maximum "
"bioavailability of nutrients. Lehya has been indicated so that the food is "
"given in the semi solid form for better deglutition.", body))
e.append(Paragraph(
"For a baby with predominance of pitta in constitution mridweeks "
"with honey and ghrita should always be given. Similarly, in predominance "
"of vaata, an appreciable amount of maatulunga rasa and salt should be used.", body))
e.append(Paragraph(
"At least 8-10% of energy should be obtained from proteins. Animal "
"proteins like milk, egg, meat should be given. Dark leafy vegetables are "
"given to add iron. Well-cooked gruel is another ideal food which can be "
"given during weaning. Mashed bananas cooked in milk alongwith "
"mashed pulses can also be given.", body))
e.append(Paragraph(
"By 8-9 months, the child should be able to consume cooked food "
"similar to that of adults.", body))
# Frequency of feeding label
e.append(Spacer(1, 2))
e.append(colored_label("Frequency of feeding", bg=colors.HexColor("#E59866"), fg=BLACK, width=COL_W))
e.append(Spacer(1, 3))
e.append(Paragraph(
"Regular intake of food is advised after 12 months. The factors influencing "
"the frequency of feeding are:", body))
for n, item in enumerate([
"Desam-Regional practice",
"Agnibelam-Digestive capacity",
"Balam-Activity",
"Kaalam-Season",
], 1):
e.append(Paragraph(f"{n} {item}", bullet))
e.append(Paragraph(
"<i>In spite of all these parameters, the ultimate criteria to determine the "
"frequency of feeding should be the HUNGER of the child alone. "
"(demand schedule).</i>", body))
return e
# ── RIGHT COLUMN ──────────────────────────────────────────────────────────────
def right_col():
e = []
e.append(colored_label("Weaning", bg=BLUE, fg=WHITE))
e.append(Spacer(1, 4))
e.append(Paragraph(
"Since human milk or cow's milk is not sufficient to meet the energy and "
"proteins requirements for the growth of infants, it is necessary to provide "
"nutritional supplements by the age of 4 months.", body))
e.append(Spacer(1, 4))
e.append(colored_label("Definition", bg=BLUE, fg=WHITE))
e.append(Spacer(1, 4))
e.append(Paragraph(
"Wenian (English) means 'to accustom'. Weaning means accustoming "
"the infant to nourishment other than mother's milk.", body))
e.append(Paragraph("Weaning foods should be", body))
for item in [
"Culturally acceptable",
"Adequate",
"Locally available & inexpensive",
"Easily prepared at home",
"Clean & hygienic",
"Physiologically stable, suitable, easily digestible and nourishing",
]:
e.append(Paragraph(f"\u2022 {item}", bullet))
e.append(Spacer(1, 5))
e.append(colored_label("Time", bg=BLUE, fg=WHITE))
e.append(Spacer(1, 4))
e.append(Paragraph(
"Weaning should be gradual. It should be begun at the age of 4 months "
"and completed by 9 months of age.", body))
e.append(Spacer(1, 4))
e.append(colored_label("Method", bg=BLUE, fg=WHITE))
e.append(Spacer(1, 4))
for item in [
"The amount of new foods given should be gradually increased "
"(paadaamsika krama can be adopted).",
"Before introducing a new type of food, any one type should be given "
"for several days.",
"Gradual process helps the infant to accept new food without upsetting "
"the GIT.",
]:
e.append(Paragraph(f"\u2022 {item}", bullet))
return e
# ── ASSEMBLE PAGE ─────────────────────────────────────────────────────────────
story = []
# Top header line
story.append(Paragraph(
"Average requirement of breast milk: 100ml/kg/24hoursby3rd day "
"150ml/kg/24hoursby10th day",
page_hdr))
story.append(HRFlowable(width="100%", thickness=0.5, color=MGRAY, spaceAfter=6))
# Title box
title_p = Paragraph(
"<b>Topic 4. Stanya Vijnana (Breast Milk)</b>",
PS("tp", fontSize=13, textColor=PURPLE, alignment=TA_CENTER,
fontName="Helvetica-Bold", leading=16))
title_tbl = Table([[title_p]], colWidths=[USABLE_W])
title_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), LPURP),
("BOX", (0,0), (-1,-1), 1, PURPLE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
]))
story.append(title_tbl)
story.append(Spacer(1, 6))
# POINT line
story.append(Paragraph(
"<b>POINT:</b> Explain Stanyapanayana.",
point_hdr))
# Two-column layout
def build_col(elems, w):
rows = [[e] for e in elems]
t = Table(rows, colWidths=[w])
t.setStyle(TableStyle([
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 0),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
return t
left_tbl = build_col(left_col(), COL_W)
right_tbl = build_col(right_col(), COL_W)
two_col = Table(
[[left_tbl, Spacer(GAP, 1), right_tbl]],
colWidths=[COL_W, GAP, COL_W],
hAlign="LEFT"
)
two_col.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 0),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("LINEAFTER", (0,0), (0,-1), 0.5, MGRAY),
("LINEBEFORE", (2,0), (2,-1), 0, WHITE),
]))
story.append(two_col)
doc.build(story)
print(f"PDF saved: {OUTPUT}")
cd /tmp/workspace/stanya-pdf && python3 create_pdf_v2.py 2>&1
Topic4 Stanya Vijnana
PDF Document · PDF
Add shlokas
~/stanya-pdf/create_pdf_v2.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/stanya-pdf/create_pdf_v2.py'
cd /tmp/workspace/stanya-pdf && python3 create_pdf_v2.py 2>&1
Topic4 Stanya Vijnana
PDF Document · PDF
| # | Shloka | Reference |
|---|---|---|
| 1 | अथैनं जातदशनं क्रमेणापनयेत् स्तनम् । | A.H.U. 1/38 |
| 2 | कुष्ठं सर्जरसः स्नेहो रजःस्वलाङ्गलाकियाः । / बीभत्सदर्शनं चापि स्तनत्यागकराणि च ।। | A.S. U. 1/41 |
| 3 | प्रीणनीयैश्च जीवनीयैश्च मोदकैः । / अपरान्नसमायोगः... | A.H.U. 1/38 |
| 4 | शालीनां षष्टिकानां वा पुराणानां विशेषतः । (3 lines) | K.S. Khi. 12/19-20 |