Hi make clinical guide for all cases gastroenterologist sees in opd ipd and emergency with exact prescriptions step by step for each case
Create a printable gastroenterology quick-reference PDF
Make it an adult clinician emergency quick-reference
gastrointestinal hemorrhage AND guideline
acute pancreatitis AND guideline
2025 ACG clinical guideline upper gastrointestinal and ulcer bleeding acute pancreatitis cholangitis emergency recommendations
variceal hemorrhage AND guideline
acute cholangitis AND guideline
hepatic encephalopathy AND guideline
ulcerative colitis AND guideline
site:aasld.org practice guidance acute variceal bleeding ascites hepatic encephalopathy spontaneous bacterial peritonitis pdf
PMID: 38857482
PMID: 40886248
Clostridioides difficile infection AND guideline
lower gastrointestinal bleeding AND guideline
https://www.the-hospitalist.org/hospitalist/article/41218/cr…
/tmp/workspace
mkdir -p "/tmp/workspace/gastro-emergency-quickref/src" "/tmp/workspace/gastro-emergency-quickref/output" && python - <<'PY' from pathlib import Path p=Path('/tmp/workspace/gastro-emergency-quickref/src/build_pdf.py') p.write_text(r'''from reportlab.lib import colors from reportlab.lib.colors import HexColor from reportlab.lib.enums import TA_CENTER, TA_LEFT from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.units import cm from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, PageBreak, KeepTogether from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics from reportlab.lib import utils from reportlab.pdfbase.pdfmetrics import stringWidth from reportlab.pdfgen import canvas from datetime import date OUT='/tmp/workspace/gastro-emergency-quickref/output/Adult_Gastroenterology_Emergency_Quick_Reference.pdf' NAVY=HexColor('#123047'); BLUE=HexColor('#1F5C7A'); TEAL=HexColor('#157A6E'); RED=HexColor('#A52A2A'); PALE=HexColor('#EAF1F4'); AMBER=HexColor('#FFF3D6'); GREY=HexColor('#F5F7F8'); DARK=HexColor('#1D252C') styles=getSampleStyleSheet() styles.add(ParagraphStyle(name='TitleX', parent=styles['Title'], fontName='Helvetica-Bold', fontSize=22, leading=26, alignment=TA_CENTER, textColor=NAVY, spaceAfter=10)) styles.add(ParagraphStyle(name='Sub', parent=styles['Normal'], fontName='Helvetica', fontSize=9.2, leading=12, alignment=TA_CENTER, textColor=DARK, spaceAfter=8)) styles.add(ParagraphStyle(name='H1x', parent=styles['Heading1'], fontName='Helvetica-Bold', fontSize=15, leading=18, textColor=colors.white, backColor=NAVY, borderPadding=6, spaceBefore=8, spaceAfter=7)) styles.add(ParagraphStyle(name='H2x', parent=styles['Heading2'], fontName='Helvetica-Bold', fontSize=11.3, leading=14, textColor=NAVY, spaceBefore=8, spaceAfter=4)) styles.add(ParagraphStyle(name='BodyX', parent=styles['BodyText'], fontName='Helvetica', fontSize=8.35, leading=10.6, textColor=DARK, spaceAfter=3)) styles.add(ParagraphStyle(name='Small', parent=styles['BodyText'], fontName='Helvetica', fontSize=7.2, leading=8.8, textColor=DARK, spaceAfter=2)) styles.add(ParagraphStyle(name='Callout', parent=styles['BodyText'], fontName='Helvetica-Bold', fontSize=8.3, leading=10.4, textColor=RED, spaceAfter=3)) styles.add(ParagraphStyle(name='Footer', parent=styles['Normal'], fontName='Helvetica', fontSize=7, leading=8, textColor=HexColor('#56636D'), alignment=TA_CENTER)) def P(t, s='BodyX'): return Paragraph(t, styles[s]) def bullet(items, style='BodyX'): return [P('• '+x, style) for x in items] def section(title): return [Spacer(1,3),P(title,'H1x')] def h(t): return P(t,'H2x') def box(title, rows, widths=(4.2*cm,13.9*cm)): data=[[P(title,'Small'), P('','Small')]] + [[P(a,'Small'),P(b,'Small')] for a,b in rows] tbl=Table(data, colWidths=widths, repeatRows=1, hAlign='LEFT') tbl.setStyle(TableStyle([ ('BACKGROUND',(0,0),(-1,0),PALE),('TEXTCOLOR',(0,0),(-1,0),NAVY),('FONTNAME',(0,0),(-1,0),'Helvetica-Bold'), ('GRID',(0,0),(-1,-1),0.25,HexColor('#B6C7CF')),('VALIGN',(0,0),(-1,-1),'TOP'), ('LEFTPADDING',(0,0),(-1,-1),5),('RIGHTPADDING',(0,0),(-1,-1),5),('TOPPADDING',(0,0),(-1,-1),4),('BOTTOMPADDING',(0,0),(-1,-1),4), ('BACKGROUND',(0,1),(0,-1),GREY) ])) return tbl def footer(canv, doc): canv.saveState(); w,h=A4 canv.setStrokeColor(HexColor('#B6C7CF')); canv.line(1.4*cm,1.25*cm,w-1.4*cm,1.25*cm) canv.setFont('Helvetica',7); canv.setFillColor(HexColor('#56636D')) canv.drawString(1.4*cm,0.82*cm,'Adult Gastroenterology Emergency Quick-Reference | Version 1.0 | 29 Aug 2026') canv.drawRightString(w-1.4*cm,0.82*cm,f'Page {doc.page}') canv.restoreState() story=[] story += [Spacer(1,1.3*cm),P('ADULT GASTROENTEROLOGY<br/>EMERGENCY QUICK-REFERENCE','TitleX'),P('ED, acute admissions, ICU handover and first 24-hour management','Sub')] story += [Spacer(1,7), box('Use and limits', [ ('Audience','Licensed adult clinicians. This is a bedside aide, not a replacement for senior review, local pathways, drug monographs, antimicrobial policy, transfusion policy, or specialist procedural advice.'), ('Before every order','Confirm weight where relevant, allergy, pregnancy potential, renal function, hepatic failure, QT risk, anticoagulants/antiplatelets, drug interactions, and route/access. Use local concentrations and infusion pumps.'), ('Call now','ICU/anaesthesia for airway risk, shock, escalating vasopressors, encephalopathy, severe acidosis, active major bleed. Early GI/endoscopy, surgery, interventional radiology, hepatology/transplant as indicated.'), ('Scope','Adult, non-pregnant default guidance. Do not apply doses to children. The guide does not cover every diagnosis or replace source control/endoscopy/surgery.')])] story += [Spacer(1,7), h('Universal first 10 minutes'), *bullet([ '<b>ABCDE:</b> monitor, two large-bore IVs, NPO if procedure/aspiration risk, glucose, ECG where indicated, analgesia and antiemetic while preserving serial examination.', '<b>Bloods:</b> CBC, U&E/creatinine, LFTs, bilirubin, albumin, PT/INR, group and screen/crossmatch, VBG/ABG plus lactate if ill. Add lipase, cultures, acetaminophen level, pregnancy test, troponin as syndrome dictates.', '<b>Resuscitation:</b> balanced crystalloid in small reassessed boluses for hypovolemia. Avoid fluid overload in cirrhosis, heart failure and renal failure. Activate massive hemorrhage protocol when needed.', '<b>Anticoagulants:</b> document agent, last dose, indication and thrombotic risk. In life-threatening bleeding, reverse under local protocol with haematology/pharmacy input. Do not use INR alone to estimate bleeding risk in cirrhosis.', '<b>Disposition:</b> haemodynamic instability, ongoing bleed, severe sepsis, organ failure, peritonitis, severe colitis, acute liver failure or encephalopathy require monitored/critical-care-level assessment.' ])] story += [Spacer(1,6), P('<b>Core red flags:</b> hematemesis/melena with shock; hematochezia with instability; peritonism/free air; fever-jaundice-hypotension/confusion; new ascites with pain/fever/AKI; altered mentation in liver disease; severe abdominal pain with lactate/acidosis; colonic dilation/systemic toxicity.','Callout')] story.append(PageBreak()) story += section('1. Overt gastrointestinal bleeding') story += [h('Upper GI bleed: initial pathway'), box('Immediate orders',[ ('Resuscitate','Large-bore access, crossmatch, serial vitals and Hb. Restrictive RBC strategy is typical: transfuse at Hb <7 g/dL (70 g/L) in most stable adults, but individualize for massive bleeding, active ischaemia, severe cardiopulmonary disease or local protocol.'), ('PPI when non-variceal likely/possible','Pantoprazole 80 mg IV bolus, then 8 mg/hour IV infusion for 72 h <i>after endoscopic haemostasis</i>, or local intermittent high-dose equivalent. Give pre-endoscopy per local pathway; it should not delay endoscopy.'), ('Endoscopy','Urgent GI. Endoscopy within 24 h after resuscitation for most UGIB; sooner for ongoing instability. Protect airway before endoscopy if massive hematemesis, impaired consciousness or inability to protect airway.'), ('Tests/risk','Glasgow-Blatchford Score can support risk assessment, not replace judgement. Check medication triggers, liver disease, NSAIDs, anticoagulants and cardiopulmonary disease.')]), h('Suspected variceal hemorrhage: treat before confirmation'), box('Time-critical orders',[ ('Vasoactive drug','<b>Octreotide 50 micrograms IV bolus, then 50 micrograms/hour continuous infusion</b>, usually 2-5 days according to local protocol/endoscopic result. Alternative vasoactive agent only under local protocol.'), ('Antibiotic prophylaxis','<b>Ceftriaxone 1 g IV every 24 h</b>, maximum 7 days in cirrhosis with UGIB, unless local policy, allergy or prior microbiology requires another regimen.'), ('Definitive control','Urgent therapeutic endoscopy, generally within 12 h after resuscitation. Band ligation for oesophageal varices. Escalate refractory/uncontrolled bleeding early to ICU, interventional radiology/hepatology for rescue or pre-emptive TIPS assessment.'), ('Avoid','Over-transfusion and routine correction of INR solely because of cirrhosis. Avoid routine PPI continuation once a purely variceal source is established unless another indication exists.')]), h('Lower GI bleed'), box('Initial pathway',[ ('Unstable / ongoing significant bleeding','Resuscitate, correct reversible coagulopathy under protocol, exclude brisk upper source, and discuss <b>CT angiography</b> urgently with radiology/IR. Positive extravasation generally directs catheter angiography/embolization where available.'), ('Stable','Risk stratify, inspect anorectal source, review drugs. Colonoscopy timing and bowel preparation are individualized after stabilization; involve GI. Consider CTA if recurrent/hemodynamically meaningful bleeding.'), ('Do not miss','Aortic pathology, mesenteric ischaemia, brisk UGIB, postoperative bleeding, and anticoagulant-associated hemorrhage.')])] story.append(PageBreak()) story += section('2. Acute biliary and pancreatic emergencies') story += [h('Acute cholangitis: sepsis plus biliary obstruction'), box('First-hour approach',[ ('Recognize','Fever/inflammatory response plus cholestasis and imaging evidence supports diagnosis. Hypotension, confusion, organ dysfunction or non-response to initial treatment imply severe disease.'), ('Cultures + antimicrobials','Take blood cultures without delaying antibiotics. Start local biliary-sepsis regimen. A common community-acquired option: <b>ceftriaxone 2 g IV every 24 h plus metronidazole 500 mg IV every 8 h</b>. Use local broader antipseudomonal/enterococcal coverage for healthcare-associated infection, shock, biliary stent, prior resistant organisms or immunosuppression. Renally adjust as required.'), ('Source control','Early GI/ERCP and anaesthesia discussion. Urgent drainage is indicated in septic shock/severe cholangitis and early drainage for moderate disease or failure to improve. ERCP is preferred when feasible; percutaneous or surgical drainage if not.'), ('Support','Sepsis bundle, lactate, urine output, vasopressors after adequate reassessed fluid resuscitation. Do not delay drainage for correction of non-actionable laboratory abnormalities.')]), h('Acute pancreatitis'), box('Initial management',[ ('Diagnose','Need 2 of 3: typical pain, lipase/amylase >3 times ULN, or characteristic imaging. Ultrasound for biliary cause. CT is not routine on arrival if diagnosis is clear; use if diagnosis uncertain, deterioration, or concern for complication.'), ('Fluid','Use <b>lactated Ringer solution</b> with moderately aggressive, goal-directed hydration. Reassess at frequent intervals using BP, HR, urine output, BUN/haematocrit trend, oxygenation and fluid overload signs. Consider initial 10-20 mL/kg bolus only if hypovolemic, then commonly 1.5 mL/kg/hour, adjusted to response and comorbidity.'), ('Analgesia / feeding','Titrate opioid analgesia and antiemetic. Start oral low-fat diet once pain/nausea permit in mild disease. In severe disease use enteral feeding rather than parenteral when possible.'), ('Antibiotics','<b>Do not give prophylactic antibiotics</b> for uncomplicated AP or sterile necrosis. Treat proven/suspected cholangitis, bacteremia, pneumonia, UTI, or infected necrosis using cultures and source control.'), ('ERCP','ERCP within 24 h for AP complicated by cholangitis. Do not perform routine early ERCP for biliary AP without cholangitis/ongoing obstruction; use MRCP/EUS if a CBD stone is suspected.'), ('Escalate','ICU for organ failure, persistent SIRS, severe hypoxaemia, shock, AKI or rising lactate. Consult surgery for infected necrosis/complications; avoid early intervention for stable necrosis when possible.')])] story.append(PageBreak()) story += section('3. Decompensated cirrhosis and acute liver failure') story += [h('Any hospitalized patient with cirrhosis and ascites'), box('Non-negotiable actions',[ ('Diagnostic paracentesis','Perform promptly on admission and with fever, pain, encephalopathy, AKI, GI bleed, shock or deterioration. Send cell count with differential, culture inoculated at bedside into blood-culture bottles, albumin and total protein.'), ('SBP threshold','Ascitic PMN <b>≥250 cells/mm³</b> = treat SBP, regardless of culture result. Do not delay antibiotics for culture.'), ('SBP treatment','Common regimen: <b>cefotaxime 2 g IV every 8 h</b> or <b>ceftriaxone 2 g IV every 24 h</b>, adjusted to local resistance, allergy, prior prophylaxis and nosocomial status. Typical duration 5-7 days, guided by response/culture/local policy.'), ('Albumin in SBP','<b>Albumin 1.5 g/kg IV day 1 and 1.0 g/kg IV day 3</b> (use institutional preparation/volume policy), particularly where renal dysfunction, bilirubin elevation or high risk is present. Monitor for pulmonary edema.'), ('AKI','Stop nephrotoxins/NSAIDs, assess volume and bleeding/infection, hold diuretics in AKI/hypotension, obtain urine studies as needed. Early hepatology/ICU for suspected HRS-AKI.')]), h('Overt hepatic encephalopathy'), box('Treat precipitants and lower ammonia',[ ('First','Check airway, glucose, sepsis, GI bleed, constipation, AKI, electrolyte disorder, sedatives/opioids, alcohol withdrawal and intracranial event when presentation is atypical. Avoid benzodiazepines unless clear indication.'), ('Lactulose','If able to take orally/NG: <b>25 mL (16-20 g) every 1-2 h</b> until 2 soft stools, then titrate to <b>2-3 soft stools/day</b>. If unable to take enterally, rectal route under local protocol. Avoid dehydration, hypernatremia and aspiration.'), ('Rifaximin','For recurrence or inadequate response after lactulose: <b>550 mg PO/NG twice daily</b>. Not a substitute for precipitant treatment.'), ('Escalate','Grade III-IV, loss of airway reflexes, aspiration or severe agitation: ICU/anaesthesia. Intubate for airway protection when necessary.')]), h('Suspected HRS-AKI'), box('Specialist-led therapy',[ ('Definition context','Cirrhosis with ascites and AKI after assessment, removal of nephrotoxins/diuretics, volume evaluation and exclusion of shock/structural renal disease. Infection must be sought and treated.'), ('First-line where available','<b>Terlipressin plus albumin</b> under hepatology/ICU protocol. Monitor closely for respiratory failure, hypoxaemia, ischaemia and volume overload; avoid/use extreme caution in hypoxaemia or significant ischaemic disease. Arrange transplant evaluation early.'), ('If unavailable','ICU-based norepinephrine plus albumin may be used per local specialist pathway. Midodrine/octreotide is less effective and should only be a specialist-directed alternative.')]), h('Acute liver failure'), box('Immediate referral syndrome',[ ('Recognize','INR ≥1.5 plus any encephalopathy in a patient without known cirrhosis, with illness <26 weeks. Transfer early to a liver transplant center and ICU.'), ('Orders','Frequent glucose, INR/fibrinogen, ammonia, lactate, ABG, phosphate, renal function, cultures; acetaminophen level regardless of history. Neuro checks, head elevation, avoid hypotonic fluid and unnecessary sedation.'), ('N-acetylcysteine','If acetaminophen toxicity is suspected: start immediately using local IV protocol. Standard 21-h IV protocol: <b>150 mg/kg over 1 h, then 50 mg/kg over 4 h, then 100 mg/kg over 16 h</b>. Extend based on acetaminophen level, AST/ALT, INR and specialist advice. Consider NAC in early non-acetaminophen ALF with transplant-center input.')])] story.append(PageBreak()) story += section('4. Colitis, diarrhoea and abdominal catastrophe') story += [h('Acute severe ulcerative colitis [ASUC]'), box('Same-day actions',[ ('Assess','Admit. Stool testing for C. difficile and enteric infection, CBC/CRP/U&E/LFT/albumin, abdominal radiograph or CT if distension/tenderness/systemic toxicity. Obtain early colorectal surgery and GI input.'), ('IV steroid','<b>Methylprednisolone 40-60 mg IV once daily</b> (or hydrocortisone <b>100 mg IV every 6 h</b>) after infection assessment. Do not delay lifesaving treatment in a critically ill known IBD patient while tests are pending, but reassess diagnosis.'), ('Support','VTE prophylaxis unless contraindicated by uncontrolled bleeding, fluid/electrolyte replacement, nutrition assessment, avoid NSAIDs, opioids, anticholinergics and antidiarrheals.'), ('Day 3 assessment','Assess stool frequency, bleeding, CRP and clinical status. If inadequate response, GI-led rescue with infliximab or ciclosporin after infection screening and surgical discussion. Do not serially delay colectomy in deterioration.')]), h('Toxic megacolon / suspected perforation'), box('Emergency response',[ ('Recognize','Systemic toxicity plus colonic dilation, worsening pain/tenderness, peritonitis, rising lactate or free air. Obtain urgent imaging and call colorectal surgery immediately.'), ('Orders','NPO, IV fluids/electrolytes, broad-spectrum IV antibiotics per intra-abdominal sepsis protocol, VTE prophylaxis when safe, serial abdominal examinations and radiographs. Avoid colonoscopy, barium enema, antidiarrheals, anticholinergics and opioids where possible.'), ('Definitive','Perforation, uncontrolled bleeding, clinical deterioration or refractory toxic megacolon requires urgent operative management.')]), h('Clostridioides difficile infection'), box('Initial treatment',[ ('Infection control','Contact/enteric precautions, soap-and-water hand hygiene, stop unnecessary antibiotics and acid suppression where possible. Test only unformed stool unless ileus/fulminant disease suspected.'), ('Initial non-fulminant episode','Preferred where available: <b>fidaxomicin 200 mg PO twice daily for 10 days</b>. Acceptable alternative: <b>vancomycin 125 mg PO four times daily for 10 days</b>. Follow local formulary and guideline.'), ('Fulminant CDI','Hypotension/shock, ileus or megacolon: <b>vancomycin 500 mg PO/NG every 6 h PLUS metronidazole 500 mg IV every 8 h</b>. If ileus, add rectal vancomycin under GI/ID protocol. ICU, GI, ID and surgery urgently.')]), h('Acute abdomen: obstruction, perforation, mesenteric ischaemia'), box('Do not defer source control',[ ('Actions','NPO, resuscitate, crossmatch, lactate/VBG, broad-spectrum IV antibiotics for perforation/strangulation/sepsis per local protocol, analgesia, urgent contrast CT if stable and it will not delay surgery.'), ('Consult','Immediate surgery for peritonitis, free air, strangulation/closed-loop obstruction, suspected bowel ischaemia, uncontrolled sepsis or deteriorating physiology. Early vascular/IR for mesenteric ischaemia pathway.'), ('NG tube','Use for significant vomiting, distension, aspiration risk or obstruction on surgical advice; do not let NG placement delay theatre/CT.')])] story.append(PageBreak()) story += section('5. Procedures, escalation and reference orders') story += [h('Ingestion / foreign body [adult]'), box('First actions',[ ('Airway','Drooling, stridor, respiratory distress, complete obstruction, button battery, sharp object, caustic ingestion or altered mental state: urgent anaesthesia/ENT/GI involvement. Do not induce emesis or neutralize caustic agents.'), ('Endoscopy','Emergent endoscopy for complete oesophageal obstruction, battery in oesophagus, sharp object in oesophagus. Urgent endoscopy for food impaction without complete obstruction. Imaging as appropriate; avoid contrast studies that delay/obscure endoscopy in unstable patients.'), ('Caustic ingestion','NPO, airway assessment, early poison-center/toxicology and GI/surgical advice. CT/endoscopy timing is specialist-led. Do not give blind NG tube or charcoal.')]), h('Medication safety checklist'), box('At every transfer / before procedure',[ ('Renal impairment','Renally adjust beta-lactams, metronidazole where indicated by local monograph, opioids and contrast-risk plan. Track urine output and creatinine trend.'), ('Liver impairment','Avoid excessive sedatives, hepatotoxic drugs, NSAIDs in decompensated cirrhosis, and unnecessary volume. Use lower opioid doses and longer intervals when appropriate.'), ('QT / interactions','Check ECG and electrolytes before repeated antiemetics, macrolides, fluoroquinolones, azoles or antipsychotics. Reconcile anticoagulants and P2Y12 inhibitors before endoscopy.'), ('Antibiotics','Obtain cultures when feasible, give promptly in sepsis, and narrow/stop when source and microbiology allow. Local antibiogram supersedes this document.')]), h('Recommended handover script'), *bullet([ '<b>Syndrome and severity:</b> "Suspected variceal bleed / cholangitis / ASUC, with current BP, lactate, mental state, organ failures and response to resuscitation."', '<b>Actions completed:</b> access, fluids/blood, cultures, antibiotic and exact time, vasoactive agent, PPI, lactulose, paracentesis result, imaging and current infusions.', '<b>Decision needed:</b> timing of endoscopy/ERCP/CTA-IR/surgery/TIPS/ICU and any anticoagulant reversal or airway plan.' ]), h('Evidence and update notes'), P('This reference synthesizes major emergency and gastroenterology guidance and textbook standards. Local protocols may intentionally differ, especially for antimicrobial selection, blood products, anticoagulant reversal, infusion formulations and access to ERCP/TIPS/IR. Main sources reviewed: ACG Acute Pancreatitis Guideline (2024, PMID 38857482); APASL Acute Variceal Bleeding Guideline (2025, PMID 40886248); AASLD Practice Guidance for ascites, SBP and HRS (2021); ACG CDI Guideline (2021) with 2025 regional update (PMID 40035163); AGA/ACG IBD guidance; Tokyo Guidelines 2018 for acute cholangitis; ACG Upper GI and Ulcer Bleeding Guideline (2021); ACG Lower GI Bleeding Guideline (2023). Textbook cross-checks: <i>Sleisenger and Fordtran’s Gastrointestinal and Liver Disease</i>, <i>Yamada’s Textbook of Gastroenterology</i>, and <i>ROSEN’s Emergency Medicine</i>.','Small'), P('<b>Recent evidence note:</b> The 2024 ACG pancreatitis guideline supports lactated Ringer-based moderately aggressive, reassessed hydration; early enteral feeding; no prophylactic antibiotics; and ERCP within 24 h when cholangitis complicates pancreatitis. (PMID 38857482.) Newer guidance should be checked before local adoption.','Small')] doc=SimpleDocTemplate(OUT,pagesize=A4, rightMargin=1.35*cm,leftMargin=1.35*cm,topMargin=1.2*cm,bottomMargin=1.55*cm,title='Adult Gastroenterology Emergency Quick-Reference',author='Orris') doc.build(story,onFirstPage=footer,onLaterPages=footer) print(OUT) ''') PY python "/tmp/workspace/gastro-emergency-quickref/src/build_pdf.py" && python - <<'PY' from pypdf import PdfReader p='/tmp/workspace/gastro-emergency-quickref/output/Adult_Gastroenterology_Emergency_Quick_Reference.pdf' r=PdfReader(p) print('pages',len(r.pages),'bytes',__import__('os').path.getsize(p)) for i,page in enumerate(r.pages): t=page.extract_text() or '' print(i+1,len(t),t[:70].replace('\n',' | ')) PY
python - <<'PY' import fitz p='/tmp/workspace/gastro-emergency-quickref/output/Adult_Gastroenterology_Emergency_Quick_Reference.pdf' doc=fitz.open(p) for n in (0,3,5): pix=doc[n].get_pixmap(matrix=fitz.Matrix(1.2,1.2),alpha=False) pix.save(f'/tmp/workspace/gastro-emergency-quickref/output/page_{n+1}_preview.png') print('rendered',len(doc)) PY ls -lh "/tmp/workspace/gastro-emergency-quickref/output"