I want cleaner version of the pdf with no changes
python3 -c " from pypdf import PdfReader import pdfplumber pdf_path = '/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf' reader = PdfReader(pdf_path) print(f'Pages: {len(reader.pages)}') print(f'Metadata: {reader.metadata}') # Check page sizes for i, page in enumerate(reader.pages): print(f'Page {i+1}: mediabox={page.mediabox}') # Check if images are embedded with pdfplumber.open(pdf_path) as pdf: for i, page in enumerate(pdf.pages): imgs = page.images print(f'Page {i+1}: {len(imgs)} image(s), size={page.width}x{page.height}') text = page.extract_text() print(f' Text extracted: {len(text) if text else 0} chars') if text: print(f' Sample: {text[:200]}') "
mkdir -p /tmp/workspace/pdf-cleaner/output && python3 << 'EOF' import pdfplumber import io from PIL import Image, ImageFilter, ImageEnhance, ImageOps from pypdf import PdfReader, PdfWriter from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter import os pdf_path = '/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf' # Extract raw image bytes from each page reader = PdfReader(pdf_path) images_info = [] for i, page in enumerate(reader.pages): for img_key in page.images: img_data = img_key.data images_info.append({ 'page': i, 'data': img_data, 'mediabox': page.mediabox }) print(f"Found {len(images_info)} images") # Check what format they are for j, info in enumerate(images_info): data = info['data'] print(f"Image {j}: first bytes = {data[:4].hex()}, size = {len(data)} bytes") EOF
python3 << 'EOF' import io, os from PIL import Image, ImageFilter, ImageEnhance, ImageOps, ImageChops import numpy as np from pypdf import PdfReader, PdfWriter from reportlab.pdfgen import canvas as rl_canvas from reportlab.lib.units import point pdf_path = '/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf' out_dir = '/tmp/workspace/pdf-cleaner/output' os.makedirs(out_dir, exist_ok=True) reader = PdfReader(pdf_path) page_images = [] for i, page in enumerate(reader.pages): for img_key in page.images: img_bytes = img_key.data img = Image.open(io.BytesIO(img_bytes)) if img.mode != 'RGB': img = img.convert('RGB') orig_w, orig_h = img.size print(f"Page {i+1}: {orig_w}x{orig_h} mode={img.mode}") # --- Cleaning pipeline --- # 1. Convert to grayscale for processing gray = img.convert('L') # 2. Auto-level: stretch histogram to remove yellowing/fading gray_arr = np.array(gray) p2, p98 = np.percentile(gray_arr, 2), np.percentile(gray_arr, 98) gray_arr = np.clip((gray_arr.astype(np.float32) - p2) / (p98 - p2) * 255, 0, 255).astype(np.uint8) gray = Image.fromarray(gray_arr) # 3. Increase contrast to make text pop enhancer = ImageEnhance.Contrast(gray) gray = enhancer.enhance(1.8) # 4. Mild sharpening gray = gray.filter(ImageFilter.UnsharpMask(radius=1, percent=120, threshold=3)) # 5. Lighten background (everything above threshold becomes white-ish) # Using a gentle approach - not hard threshold, just brighten whites arr = np.array(gray).astype(np.float32) # Gamma correction: lighten bright areas, keep dark text dark arr = (arr / 255.0) ** 0.75 * 255 arr = np.clip(arr, 0, 255).astype(np.uint8) cleaned = Image.fromarray(arr) # Save cleaned page image page_img_path = os.path.join(out_dir, f'page_{i+1}.jpg') cleaned.save(page_img_path, 'JPEG', quality=92, optimize=True) # Store with original PDF page dimensions for accurate sizing mb = reader.pages[i].mediabox pdf_w = float(mb.width) pdf_h = float(mb.height) page_images.append({'path': page_img_path, 'pdf_w': pdf_w, 'pdf_h': pdf_h}) print("\nCleaned pages saved. Now rebuilding PDF...") # Rebuild PDF using reportlab - one image per page preserving original dimensions from reportlab.pdfgen import canvas as rlc out_pdf = os.path.join(out_dir, 'Scanned_cleaned.pdf') c = rlc.Canvas(out_pdf) for info in page_images: c.setPageSize((info['pdf_w'], info['pdf_h'])) c.drawImage(info['path'], 0, 0, width=info['pdf_w'], height=info['pdf_h']) c.showPage() c.save() print(f"Done! Output: {out_pdf}") print(f"File size: {os.path.getsize(out_pdf):,} bytes") EOF
python3 << 'EOF' import io, os from PIL import Image, ImageFilter, ImageEnhance, ImageOps import numpy as np from pypdf import PdfReader, PdfWriter from reportlab.pdfgen import canvas as rlc pdf_path = '/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf' out_dir = '/tmp/workspace/pdf-cleaner/output' os.makedirs(out_dir, exist_ok=True) reader = PdfReader(pdf_path) page_images = [] for i, page in enumerate(reader.pages): for img_key in page.images: img_bytes = img_key.data img = Image.open(io.BytesIO(img_bytes)) if img.mode not in ('RGB', 'L'): img = img.convert('RGB') orig_w, orig_h = img.size print(f"Page {i+1}: {orig_w}x{orig_h}") # Convert to grayscale gray = img.convert('L') # Auto-level: stretch histogram to remove yellowing/fading gray_arr = np.array(gray, dtype=np.float32) p2 = float(np.percentile(gray_arr, 2)) p98 = float(np.percentile(gray_arr, 98)) if p98 > p2: gray_arr = np.clip((gray_arr - p2) / (p98 - p2) * 255, 0, 255) gray_arr = gray_arr.astype(np.uint8) gray = Image.fromarray(gray_arr) # Boost contrast gray = ImageEnhance.Contrast(gray).enhance(1.8) # Mild sharpening gray = gray.filter(ImageFilter.UnsharpMask(radius=1, percent=120, threshold=3)) # Gamma correction: lighten background, keep text dark arr = np.array(gray).astype(np.float32) arr = (arr / 255.0) ** 0.75 * 255 arr = np.clip(arr, 0, 255).astype(np.uint8) cleaned = Image.fromarray(arr) page_img_path = os.path.join(out_dir, f'page_{i+1}.jpg') cleaned.save(page_img_path, 'JPEG', quality=92) mb = reader.pages[i].mediabox page_images.append({ 'path': page_img_path, 'pdf_w': float(mb.width), 'pdf_h': float(mb.height) }) print("Cleaned pages saved. Rebuilding PDF...") out_pdf = os.path.join(out_dir, 'Scanned_cleaned.pdf') c = rlc.Canvas(out_pdf) for info in page_images: c.setPageSize((info['pdf_w'], info['pdf_h'])) c.drawImage(info['path'], 0, 0, width=info['pdf_w'], height=info['pdf_h']) c.showPage() c.save() print(f"Done! Output: {out_pdf}") print(f"File size: {os.path.getsize(out_pdf):,} bytes") EOF
Scanned cleaned
PDF Document · PDF
Can I get more enhanced and visibly clear
python3 << 'EOF' import io, os from PIL import Image, ImageFilter, ImageEnhance, ImageOps import numpy as np from pypdf import PdfReader from reportlab.pdfgen import canvas as rlc pdf_path = '/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf' out_dir = '/tmp/workspace/pdf-cleaner/output' os.makedirs(out_dir, exist_ok=True) reader = PdfReader(pdf_path) page_images = [] for i, page in enumerate(reader.pages): for img_key in page.images: img_bytes = img_key.data img = Image.open(io.BytesIO(img_bytes)) img = img.convert('RGB') orig_w, orig_h = img.size print(f"Page {i+1}: {orig_w}x{orig_h}") # Step 1: Convert to grayscale gray = img.convert('L') arr = np.array(gray, dtype=np.float32) # Step 2: Aggressive auto-level (stretch 5th–95th percentile to 0–255) p5 = float(np.percentile(arr, 5)) p95 = float(np.percentile(arr, 95)) if p95 > p5: arr = np.clip((arr - p5) / (p95 - p5) * 255, 0, 255) # Step 3: Adaptive background whitening # Estimate local background using a large blur, then subtract it from PIL import ImageFilter as IF tmp = Image.fromarray(arr.astype(np.uint8)) bg = tmp.filter(ImageFilter.GaussianBlur(radius=40)) bg_arr = np.array(bg, dtype=np.float32) # Normalize: divide by background to equalize illumination arr = np.clip(arr / (bg_arr + 1e-6) * 220, 0, 255) # Step 4: Strong contrast boost tmp = Image.fromarray(arr.astype(np.uint8)) tmp = ImageEnhance.Contrast(tmp).enhance(2.5) arr = np.array(tmp, dtype=np.float32) # Step 5: Levels: push whites to pure white, darken dark tones # Everything above 200 → 255 (white); below 80 → 0 (black) arr = np.where(arr > 200, 255, arr) arr = np.where(arr < 80, 0, arr) # Step 6: Sharpen twice for crisp text tmp = Image.fromarray(arr.astype(np.uint8)) tmp = tmp.filter(ImageFilter.UnsharpMask(radius=1.5, percent=200, threshold=2)) tmp = tmp.filter(ImageFilter.UnsharpMask(radius=0.8, percent=120, threshold=1)) # Step 7: Final brightness nudge — lift midtones slightly tmp = ImageEnhance.Brightness(tmp).enhance(1.1) page_img_path = os.path.join(out_dir, f'page_v2_{i+1}.jpg') tmp.save(page_img_path, 'JPEG', quality=95) mb = reader.pages[i].mediabox page_images.append({ 'path': page_img_path, 'pdf_w': float(mb.width), 'pdf_h': float(mb.height) }) print("\nRebuilding PDF...") out_pdf = os.path.join(out_dir, 'Scanned_enhanced_v2.pdf') c = rlc.Canvas(out_pdf) for info in page_images: c.setPageSize((info['pdf_w'], info['pdf_h'])) c.drawImage(info['path'], 0, 0, width=info['pdf_w'], height=info['pdf_h']) c.showPage() c.save() print(f"Done! {out_pdf}") print(f"Size: {os.path.getsize(out_pdf):,} bytes") EOF
Scanned enhanced v2
PDF Document · PDF
Extract and convert text to searchable PDF (OCR)
tesseract --version 2>&1; python3 -c "import pytesseract; print('pytesseract ok')" 2>&1; python3 -c "import easyocr; print('easyocr ok')" 2>&1; python3 -c "import ocrmypdf; print('ocrmypdf ok')" 2>&1; which tesseract 2>&1
python3 -c " import base64, os pages = [f'/tmp/workspace/pdf-cleaner/output/page_v2_{i}.jpg' for i in range(1,5)] for p in pages: exists = os.path.exists(p) size = os.path.getsize(p) if exists else 0 print(f'{p}: exists={exists}, size={size:,}') "
python3 -c " import base64 # Convert page images to data URLs for analyse_media for i in range(1, 5): path = f'/tmp/workspace/pdf-cleaner/output/page_v2_{i}.jpg' with open(path, 'rb') as f: b64 = base64.b64encode(f.read()).decode() data_url = f'data:image/jpeg;base64,{b64[:50]}...' print(f'Page {i}: data URL length = {len(b64)} chars') "
pip install --user pytesseract 2>&1 | tail -5; pip install --user tesseract 2>&1 | tail -3; python3 -c "import PIL; print(PIL.__version__)"
which tesseract 2>&1 || find /usr /opt /home -name "tesseract" -type f 2>/dev/null | head -5; python3 -c "import pytesseract; pytesseract.get_tesseract_version()" 2>&1
python3 -c "import paddle; print('paddle ok')" 2>&1; python3 -c "import paddleocr; print('paddleocr ok')" 2>&1; python3 -c "import doctr; print('doctr ok')" 2>&1; python3 -c "import transformers; print(transformers.__version__)" 2>&1
# Start a background HTTP server to serve the images, get the port python3 -c " import http.server, threading, socket # find a free port s = socket.socket() s.bind(('', 0)) port = s.getsockname()[1] s.close() print(port) "
# Start HTTP server in background and test it cd /tmp/workspace/pdf-cleaner/output && python3 -m http.server 58001 & sleep 2 curl -s -o /dev/null -w "%{http_code}" http://localhost:58001/page_v2_1.jpg
You need to OCR 4 scanned document page images and return the extracted text for each page. There is a local HTTP server already running at http://localhost:58001 serving these images: - http://localhost:58001/page_v2_1.jpg (page 1) - http://localhost:58001/page_v2_2.jpg (page 2) - http://localhost:58001/page_v2_3.jpg (page 3) - http://localhost:58001/page_v2_4.jpg (page 4) Use the `analyse_media` tool on ALL 4 pages (you can call them in parallel in one message). For each page use this focus parameter: "Extract ALL text exactly as it appears on the page, preserving line breaks, paragraphs, headings, numbers, punctuation and layout. Output only the raw text content, nothing else." Return a JSON object with keys "page1", "page2", "page3", "page4" each containing the full extracted text string for that page. Nothing else in your response - just the JSON.
curl -s -o /tmp/page_v2_1.jpg http://localhost:58001/page_v2_1.jpg && curl -s -o /tmp/page_v2_2.jpg http://localhost:58001/page_v2_2.jpg && curl -s -o /tmp/page_v2_3.jpg http://localhost:58001/page_v2_3.jpg && curl -s -o /tmp/page_v2_4.jpg http://localhost:58001/page_v2_4.jpg && echo "Done" && ls -lh /tmp/page_v2_*.jpg
curl -v http://localhost:58001/page_v2_1.jpg 2>&1 | head -30
ss -tlnp | grep 58001; netstat -tlnp 2>/dev/null | grep 58001; ps aux | grep -i server | grep -v grep
ps aux | grep -v grep | grep -E "python|http|server|node|ruby"; ls /tmp/*.jpg 2>/dev/null; ls /tmp/*.png 2>/dev/null; ls /var/www 2>/dev/null; find /tmp -name "*.jpg" -o -name "*.png" 2>/dev/null | head -20
cd /tmp/workspace/pdf-cleaner/output && python3 -m http.server 58001 &>/tmp/server.log & sleep 2 && echo "Server started" && curl -s -I http://localhost:58001/page_v2_1.jpg | head -5
ls -lh /tmp/workspace/pdf-cleaner/output/page_v2_*.jpg
python3 -c " from PIL import Image import os for i in range(1, 5): src = f'/tmp/workspace/pdf-cleaner/output/page_v2_{i}.jpg' dst = f'/tmp/page_v2_{i}_small.jpg' img = Image.open(src) # Resize to max width/height of 2000 while keeping aspect ratio img.thumbnail((2000, 2000), Image.LANCZOS) img.save(dst, 'JPEG', quality=70) print(f'page {i}: {img.size}, {os.path.getsize(dst)/1024:.0f} KB') "
python3 -c " from PIL import Image import os for i in range(1, 5): src = f'/tmp/workspace/pdf-cleaner/output/page_v2_{i}.jpg' dst = f'/tmp/page_v2_{i}_tiny.jpg' img = Image.open(src) img.thumbnail((1000, 1400), Image.LANCZOS) img.save(dst, 'JPEG', quality=60) print(f'page {i}: {img.size}, {os.path.getsize(dst)/1024:.0f} KB') "
python3 -c " from PIL import Image import os for i in range(1, 5): src = f'/tmp/workspace/pdf-cleaner/output/page_v2_{i}.jpg' dst = f'/tmp/page_v2_{i}_med.jpg' img = Image.open(src) img.thumbnail((1400, 1960), Image.LANCZOS) img.save(dst, 'JPEG', quality=75) print(f'page {i}: {img.size}, {os.path.getsize(dst)/1024:.0f} KB') "
python3 << 'PYEOF' import os from reportlab.pdfgen import canvas as rlc from reportlab.lib.colors import Color from pypdf import PdfReader out_dir = '/tmp/workspace/pdf-cleaner/output' # OCR text for each page page_texts = { 1: """Topic 4. Stanya Vijnana (Breast Milk) POINT: Explain method and practices of Swarnaprashana. Swarnaprashana (also spelled Suvarnaprashan) is an ancient Ayurvedic practice mentioned in classical texts like Kashyapa Samhita, used to enhance the health, immunity, intelligence, and overall development of children. It involves administering a specially prepared formulation of gold (Swarna or Suvarna) along with other medicinal substances to children, typically in their early years of life. Meaning and Origin Suvarnaprashana (Ka.S.Su.Lehadiyay) Gold should be rubbed on a washed stone with a little quantity of water then churned with honey and Ghrita, and given to the child for Lehana. Swarnaprashana is a Sanskrit term: Swarna = Gold Prashana = Administration or ingestion It is described by Acharya Kashyapa, a classical pediatrician of Ayurveda, under the chapter "Lehana Vidhi" (supplementary feeding). Ingredients Used The preparation of Swarnaprashana involves the following ingredients: 1. Swarnabhasma - Purified and incinerated gold in a fine powder form. 2. Ghee (Ghrita) - Usually cow ghee, used as a carrier and enhancer of bioavailability. 3. Honey (Madhu) - Acts as a vehicle and preservative. 4. Medhya herbs - Herbs that enhance intellect and memory, such as: Brahmi (Bacopa monnieri) Shankhpushpi (Convolvulus pluricaulis) Vacha (Acorus calamus) Mandukaparni (Centella asiatica) Method of Administration When is it given? Daily: Some practitioners administer it daily for a specific duration (e.g., 30 days or 6 months). Pushya Nakshatra: A more traditional and popular method where Swarnaprashana is given monthly on the day of Pushya Nakshatra, considered highly auspicious in Vedic astrology. How is it given? Oral administration in small drops or spoonfuls, depending on the age of the child. Usually administered on an empty stomach in the morning. Dosage is decided based on: Age of the child, Constitution (Prakriti), Physician's assessment. Precautions and Contraindications Should be administered under the supervision of a qualified Ayurvedic practitioner. Not recommended if the child is having acute infections, allergic to any components, or medically compromised without physician's clearance. Quality of Swarnabhasma must be authentic and tested for safety and purity. Modern Perspective Some Ayurvedic researchers and practitioners suggest Swarnaprashana can enhance: Immunity (supports respiratory and general immune function), Cognitive development, Gut health. However, modern clinical evidence is limited, and more scientific trials are needed to confirm its long-term effects. Benefits (As per Ayurveda) According to Kashyapa Samhita: "Suvarnaprashanam medhagnibalavardhanam | Ayushyam mangalam punyam vrushyam varnyam grahapaham ||" This translates to: Enhances intelligence and memory (Medha Vardhanam) Improves digestion and metabolism (Agni Vardhanam) Builds physical strength (Bala Vardhanam) Promotes longevity (Ayushya) Brings auspiciousness and spiritual well-being (Mangalam, Punyam) Improves skin complexion (Varnya) Acts as an immunomodulator (Grahapaham - protects from evil influences and infections) Summary of Practices Age Group: 0-16 years (often started early, around 0-5 years) Frequency: Daily or monthly (on Pushya Nakshatra) Method: Oral administration of gold-based mixture Benefits Claimed: Boosts immunity, brain function, digestion, and longevity Safety Note: Only with authentic ingredients and practitioner guidance""", 2: """Topic 4. Stanya Vijnana (Breast Milk) POINT: Analyse the scientific benefits of Swarnaprashana. The scientific analysis of Swarnaprashana is a developing area, as this practice originates from classical Ayurvedic literature and has limited but emerging modern research support. Here is a breakdown of the scientific perspective on its components, effects, and claims: 1. Analysis of Key Components Swarnabhasma (Gold Ash) Form: Nanoparticle-sized purified gold used traditionally in Ayurveda. Scientific Insight: Studies suggest gold nanoparticles can have anti-inflammatory, antioxidant, and immunomodulatory properties. Gold compounds are being explored in modern medicine for autoimmune disorders (e.g., rheumatoid arthritis). Safety Concern: The particle size and purity of Swarnabhasma are critical for safety. Improperly prepared bhasma can be toxic; hence it must be manufactured under strict quality controls. Honey and Ghee Honey: Has antibacterial and antioxidant properties. Acts as a natural preservative and sweetener. Ghee: Rich in butyrate, a compound beneficial for gut health. Improves the bioavailability of herbal compounds (lipophilic absorption). Medhya Rasayanas (Memory-enhancing herbs) Herbs like Brahmi, Shankhpushpi, Vacha, and Mandukaparni have shown promising results in: Enhancing memory and cognitive performance Neuroprotective effects in some animal and clinical studies Reducing anxiety and stress 2. Scientific Evidence for Claimed Benefits Improved memory and intelligence: Some studies on Brahmi and Shankhpushpi support cognitive enhancement. Limited data on Swarnabhasma's direct role. Boosted immunity: Gold nanoparticles and Ayurvedic herbs show immune-modulating effects in lab and animal studies. Better digestion and metabolism: Ghee aids digestion; herbs like Vacha have carminative properties. Longer life / rejuvenation: No clinical studies directly validate this; possible support through antioxidant actions. Protection from infections: Honey and herbal components have antimicrobial activity; gold has potential immunoprotective roles. Improved skin tone / complexion: No scientific studies specifically support this. Some ingredients have general detoxifying and nourishing effects. Scientific Studies and Trials 1. Gold Nanoparticles in Medicine: Studies indicate they may modulate immune responses and reduce oxidative stress. Potential application in neurodegenerative and autoimmune disorders. 2. Swarnabhasma Studies: Some small-scale animal and in vitro studies suggest non-toxicity and biocompatibility of properly prepared Swarnabhasma. Human trials are limited and vary in quality. 3. Brahmi and Shankhpushpi: Several randomized controlled trials (RCTs) in children and adults show improvements in learning, memory, and attention span. 4. Suvarnaprashan Clinical Trials (India): A few pilot studies in Ayurvedic institutions report: Better weight gain, growth markers Increased immunity (fewer infections) Improvement in cognitive tasks However, most studies lack placebo controls, large sample sizes, or peer-reviewed publication. Limitations and Scientific Gaps Lack of large-scale, double-blind RCTs to definitively confirm claims. Variability in formulation and dosage among practitioners. Limited standardization of Swarnabhasma production and testing. Need for long-term safety and efficacy studies in children.""", 3: """Topic 4. Stanya Vijnana (Breast Milk) POINT: Prepare and Administer Swarnaprashana The words 'praasana' and 'lehana' are used synonymously in Kaumarabhrithya. Nowadays, the effect of this karma is being widely discussed. Therefore, a systematic and detailed study of praasana is mandatory. Definition The amount of food which can be grasped by the tip of middle finger of the care taker is termed as praasa. The concept of praasa can be viewed in the following manner as per classical reference of Brihattrayees. [A] Praasa before Vamana Drugs: Aindri, Brahmi, Vacha, Sankhapushpi Aims: Attainment of intellect, longevity and strength are the aims of praasa [B] Praasa after Vamana (before establishment of lactation) Praasa given after vamana, before the establishment of lactation, aims at speeding up the passage of meconium and also act as a compensatory food to colostrum to meet the nutritional requirements of the baby for the first three days or up to the effective establishment of lactation. After delivery, the siraas, located in relation to the heart (seat of rasadhaatu - stanya is an upadhaatu of rasa) get dilated. So the production of breast milk starts only on the third or fourth day. Hence on the first day, the baby should be made to lick the mixture of honey and ghee mixed with ananta (Gold) fortified with sacred mantras, three times a day. On the second and third days, the baby should be given ghee prepared with lakshmana. After wards, the baby, which was hitherto prevented from sucking the breast, should be made to lick one panitala of navanita followed by drinking of breast-milk, two times of the day. [C] Praasa after establishment of lactation Mainly three types of praasana are explained, of which the foremost is suvamapraasa. The very first chapter of sutrasthaana of available Kasyapasamhita explains suvamapraasa with due importance. Suvamapraasa is the procedure by which swarna along with some herbal drugs is administered to a neonate for gaining positive qualities of life. Swarnaprashanavidhi: Keeping face towards east, gold should be rubbed on a clean stone with a little quantity of water, churned with honey and ghrita and given to the child. Four groups of drugs mentioned by each quarter verse; consumed with honey and ghee, for a period of one year bestows good body growth, intelligence, strength, colour and goodness. 1. Hema, swetavacha and kushta 2. Arkapushpi and kaanchana 3. Hema, matsyaakshaka and sankha. 4. Kaidarya, kanaka and vacha. Feeding of gold increases intellect, digestive and metabolic power, strength and gives long life. It is considered as auspicious, virtuous, aphrodisiac, increases complexion and eliminates grahas. By feeding the gold for one month, the child becomes extremely intelligent and is protected from diseases. By using it for 6 months, the child is able to retain for a long time whatever he hears. Why suvarna? Suvarna is nirmala and best among the 4 sudha lohas. It is said to prevent grahabaadha, protects against visha and increases budhi, medha and smriti. By suvarnapraasa, Acharya might have intended the attainment of good intellect, immune power and longevity.""", 4: """Topic 4. Stanya Vijnana POINT: Prepare and Administer Swarnaprashana Introduction The use of elemental gold and different compounds like swarnabhasma, sidha makara dhwajam etc in Ayurvedic classics and in some ethnopractices. The vrishya, rasaayana and medhya property of gold. We do not have sufficient convincing research data to prove this property of gold in front of the scientific community. Modern science believes that elemental gold as well as majority of its compounds are not absorbed from the GI tract. It is the need of the hour to have a long term perspective multi centered research to test whether the claims of Ayurveda charyas were true or not. If proven, the mode of action should be traced out. Administration of gold compounds in the form of injections are being used in different diseases in allopathic practice. DMARD (Disease Modifying Anti-rheumatic Drugs) is one such example. Chrysotherapy is the term used for the treatment of diseases with the gold. Mostly used and absorbable forms of gold are Aurothioglucose and gold sodium thiomalate. Hypothesis The presence of gold and its compounds in the GI tract of humans along with the biological materials like herbal drugs may influence the different biochemical activities occurring in the body of baby. Drug used Both single drugs and compound formulations have been prescribed by Acharya Kashyapa. Brahmi, Mandookaparni, Triphala, Chitraka, Vacha, Sataavari, Danti, Naagabala, Trivrit. Benefits of lehana Kasyapasamhita emphasizes the importance of lehana by stating that happiness and sorrow of children are dependent on lehanas. Lehana is a simple remedy for common diseases in curative aspect. The preparation also imparts sufficient potency for the prevention of different diseases. Moreover, the drugs used are easily accessible as well as administrable. 1. Ingredients Required Swarnabhasma: 1-2 mg (lab-tested, purified gold ash) Cow Ghee (Ghrita): 2-3 drops (pure, preferably A2 cow ghee) Honey (Madhu): 2-3 drops (raw, unprocessed) Medhya herbs (optional): Powder or extract of Brahmi, Shankhpushpi, Vacha, or Mandukaparni - small quantity as per need and age Ensure all ingredients are from certified Ayurvedic pharmacies (GMP-certified), and Swarnabhasma is lab-tested for heavy metals. 2. Preparation Method 1. Clean Hands and Utensils: Sterilize or wash the small spoon or bowl used. 2. Mixing the Formulation - In a clean spoon or bowl: Add 1-2 mg of Swarnabhasma Add 2-3 drops each of honey and ghee Optionally, add a pinch of Medhya herb powder Mix well to form a paste or smooth liquid 3. Quantity: Infants (0-1 year): 1-2 drops Toddlers (1-3 years): 3-5 drops Older children (3-16 years): 5-10 drops (adjusted based on age and practitioner advice) 3. Time and Frequency of Administration Daily administration: Early morning on empty stomach (preferably same time daily) Monthly (Pushya Nakshatra): Given once a month on Pushya Nakshatra (considered most auspicious and energetically receptive) Seasonal (Ritucharya): Administered 2-3 times a year for immunity boosting Optional Enhancements (as per age) 0-3 years: Brahmi, Vacha - Brain development, speech stimulation 4-10 years: Shankhpushpi, Mandukaparni - Focus, memory, learning enhancement 11-16 years: Ashwagandha, Yashtimadhu - Stress relief, immune support 4. How to Administer Place the prepared paste or liquid directly on the tongue using a dropper, spoon, or clean finger. Ensure child is calm and cooperative; avoid giving during illness, fever, or indigestion. Avoid food for at least 15-30 minutes post-administration.""" } # Build searchable PDF: cleaned image as background, invisible text on top reader = PdfReader('/tmp/workspace/attachments/f49d9a24-058c-4e0c-9213-1dcbdc659af0/Scanned_20260724_174954.pdf') out_pdf = os.path.join(out_dir, 'Scanned_searchable_OCR.pdf') c = rlc.Canvas(out_pdf) for i in range(1, 5): img_path = os.path.join(out_dir, f'page_v2_{i}.jpg') mb = reader.pages[i-1].mediabox pw = float(mb.width) ph = float(mb.height) c.setPageSize((pw, ph)) # Draw the cleaned image as background c.drawImage(img_path, 0, 0, width=pw, height=ph) # Overlay invisible (white, 0 opacity) text for searchability # We use a tiny font, render text in white with alpha=0 (invisible) c.saveState() # Set fill color to white, fully transparent rendering trick: # Use a rendering mode that makes text invisible but selectable (mode 3 = invisible) c.setFillColorRGB(1, 1, 1, alpha=0) # fully transparent white text = page_texts[i] lines = text.split('\n') # Place text across the full page # Distribute lines evenly from top to bottom font_size = 9 c.setFont("Helvetica", font_size) # Calculate starting y and step margin_top = ph - 40 margin_bottom = 40 usable_height = margin_top - margin_bottom line_count = len(lines) step = usable_height / max(line_count, 1) step = min(step, font_size * 1.4) # don't spread too thin y = margin_top for line in lines: if line.strip(): c.drawString(30, y, line.strip()) y -= step if y < margin_bottom: break c.restoreState() c.showPage() c.save() print(f"Searchable PDF created: {out_pdf}") print(f"Size: {os.path.getsize(out_pdf):,} bytes") PYEOF
Scanned searchable OCR
PDF Document · PDF