fix(pdf): make footer and all content stay compact and strictly within half-sheet area
This commit is contained in:
@@ -74,9 +74,12 @@ class InsuranceAuthPdfService {
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Mitad superior de la hoja (máximo 5.5 pulgadas / 396 pt)
|
||||
pw.Container(
|
||||
height: 5.5 * PdfPageFormat.inch - 36,
|
||||
pw.ConstrainedBox(
|
||||
constraints: const pw.BoxConstraints(
|
||||
maxHeight: 5.5 * PdfPageFormat.inch - 36,
|
||||
),
|
||||
child: pw.Column(
|
||||
mainAxisSize: pw.MainAxisSize.min,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 1. Cabecera con Nombre del Doctor y Badge Sutil de Hidalyx Med
|
||||
@@ -207,10 +210,10 @@ class InsuranceAuthPdfService {
|
||||
pw.SizedBox(height: 8),
|
||||
|
||||
// 3. Contenido Formal idéntico a AlfaMedical
|
||||
pw.Expanded(
|
||||
child: pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
pw.Column(
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
mainAxisSize: pw.MainAxisSize.min,
|
||||
children: [
|
||||
// Señores ARS
|
||||
pw.RichText(
|
||||
text: pw.TextSpan(
|
||||
@@ -311,8 +314,14 @@ class InsuranceAuthPdfService {
|
||||
],
|
||||
],
|
||||
),
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
// Línea divisoria decorativa previa al pie
|
||||
pw.Container(
|
||||
height: 0.5,
|
||||
color: PdfColor.fromHex('CBD5E1'),
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.SizedBox(height: 5),
|
||||
|
||||
// 4. Pie de página con Contacto del Consultorio
|
||||
if (generalContact.isNotEmpty) ...[
|
||||
|
||||
@@ -71,9 +71,12 @@ class PrescriptionPdfService {
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Mitad superior de la hoja (máximo 5.5 pulgadas / 396 pt)
|
||||
pw.Container(
|
||||
height: 5.5 * PdfPageFormat.inch - 36,
|
||||
pw.ConstrainedBox(
|
||||
constraints: const pw.BoxConstraints(
|
||||
maxHeight: 5.5 * PdfPageFormat.inch - 36,
|
||||
),
|
||||
child: pw.Column(
|
||||
mainAxisSize: pw.MainAxisSize.min,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 1. Cabecera con Nombre del Doctor y Badge Superior de Hidalyx Med
|
||||
@@ -219,28 +222,33 @@ class PrescriptionPdfService {
|
||||
pw.SizedBox(height: 8),
|
||||
|
||||
// 3. Contenido de la Receta / Prescripción Médica
|
||||
pw.Expanded(
|
||||
child: pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 4),
|
||||
child: pw.Text(
|
||||
prescriptionText.trim().isNotEmpty
|
||||
? prescriptionText.trim()
|
||||
: 'Sin prescripciones anotadas.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10,
|
||||
lineSpacing: 3,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 6),
|
||||
child: pw.Text(
|
||||
prescriptionText.trim().isNotEmpty
|
||||
? prescriptionText.trim()
|
||||
: 'Sin prescripciones anotadas.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10,
|
||||
lineSpacing: 3,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
// Línea sutil previa al pie de página
|
||||
pw.Container(
|
||||
height: 0.5,
|
||||
color: PdfColor.fromHex('CBD5E1'),
|
||||
),
|
||||
pw.SizedBox(height: 5),
|
||||
|
||||
// 4. Pie de página con Contacto del Consultorio
|
||||
if (generalContact.isNotEmpty) ...[
|
||||
pw.Container(
|
||||
padding: const pw.EdgeInsets.only(top: 4),
|
||||
padding: const pw.EdgeInsets.only(top: 2),
|
||||
child: pw.Text(
|
||||
generalContact.toUpperCase(),
|
||||
textAlign: pw.TextAlign.center,
|
||||
@@ -252,10 +260,9 @@ class PrescriptionPdfService {
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(height: 3),
|
||||
],
|
||||
|
||||
pw.SizedBox(height: 3),
|
||||
|
||||
// Confirmación institucional
|
||||
pw.Center(
|
||||
child: pw.Text(
|
||||
|
||||
@@ -69,9 +69,12 @@ class DepartmentReferralPdfService {
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Mitad superior de la hoja (máximo 5.5 pulgadas / 396 pt)
|
||||
pw.Container(
|
||||
height: 5.5 * PdfPageFormat.inch - 36,
|
||||
pw.ConstrainedBox(
|
||||
constraints: const pw.BoxConstraints(
|
||||
maxHeight: 5.5 * PdfPageFormat.inch - 36,
|
||||
),
|
||||
child: pw.Column(
|
||||
mainAxisSize: pw.MainAxisSize.min,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 1. Cabecera con Nombre del Doctor y Badge Sutil de Hidalyx Med
|
||||
@@ -168,23 +171,28 @@ class DepartmentReferralPdfService {
|
||||
pw.SizedBox(height: 8),
|
||||
|
||||
// 2. Contenido del Referimiento (Idéntico a AlfaMedical)
|
||||
pw.Expanded(
|
||||
child: pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 4),
|
||||
child: pw.Text(
|
||||
referralText.trim().isNotEmpty
|
||||
? referralText.trim()
|
||||
: 'Sin detalles de referimiento.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10.5,
|
||||
lineSpacing: 3.5,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 6),
|
||||
child: pw.Text(
|
||||
referralText.trim().isNotEmpty
|
||||
? referralText.trim()
|
||||
: 'Sin detalles de referimiento.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10.5,
|
||||
lineSpacing: 3.5,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
// Línea divisoria decorativa previa al pie
|
||||
pw.Container(
|
||||
height: 0.5,
|
||||
color: PdfColor.fromHex('CBD5E1'),
|
||||
),
|
||||
pw.SizedBox(height: 5),
|
||||
|
||||
// 3. Pie de página con Contacto del Consultorio
|
||||
if (generalContact.isNotEmpty) ...[
|
||||
|
||||
@@ -69,9 +69,12 @@ class DoctorReferralPdfService {
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// Mitad superior de la hoja (máximo 5.5 pulgadas / 396 pt)
|
||||
pw.Container(
|
||||
height: 5.5 * PdfPageFormat.inch - 36,
|
||||
pw.ConstrainedBox(
|
||||
constraints: const pw.BoxConstraints(
|
||||
maxHeight: 5.5 * PdfPageFormat.inch - 36,
|
||||
),
|
||||
child: pw.Column(
|
||||
mainAxisSize: pw.MainAxisSize.min,
|
||||
crossAxisAlignment: pw.CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
// 1. Cabecera con Nombre del Doctor y Badge Sutil de Hidalyx Med
|
||||
@@ -168,23 +171,28 @@ class DoctorReferralPdfService {
|
||||
pw.SizedBox(height: 8),
|
||||
|
||||
// 2. Contenido del Referimiento (Idéntico a AlfaMedical con fontSize 13-14)
|
||||
pw.Expanded(
|
||||
child: pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 4),
|
||||
child: pw.Text(
|
||||
referralText.trim().isNotEmpty
|
||||
? referralText.trim()
|
||||
: 'Sin detalles de referimiento.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10.5,
|
||||
lineSpacing: 3.5,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
pw.Container(
|
||||
padding: const pw.EdgeInsets.symmetric(vertical: 6),
|
||||
child: pw.Text(
|
||||
referralText.trim().isNotEmpty
|
||||
? referralText.trim()
|
||||
: 'Sin detalles de referimiento.',
|
||||
style: pw.TextStyle(
|
||||
font: regular,
|
||||
fontSize: 10.5,
|
||||
lineSpacing: 3.5,
|
||||
color: PdfColor.fromHex('1E293B'),
|
||||
),
|
||||
),
|
||||
),
|
||||
pw.SizedBox(height: 6),
|
||||
pw.SizedBox(height: 10),
|
||||
|
||||
// Línea divisoria decorativa previa al pie
|
||||
pw.Container(
|
||||
height: 0.5,
|
||||
color: PdfColor.fromHex('CBD5E1'),
|
||||
),
|
||||
pw.SizedBox(height: 5),
|
||||
|
||||
// 3. Pie de página con Contacto del Consultorio
|
||||
if (generalContact.isNotEmpty) ...[
|
||||
|
||||
@@ -104,7 +104,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('PrescriptionPdfService Tests', () {
|
||||
test('builds prescription pdf bytes with correct page format', () async {
|
||||
test('builds prescription pdf bytes with correct page format and layout', () async {
|
||||
final bytes = await PrescriptionPdfService.buildPrescriptionPdf(
|
||||
doctorName: 'Dr. Luis A. Castro Sosa',
|
||||
specialty: 'Cirujano Urólogo',
|
||||
@@ -115,7 +115,6 @@ void main() {
|
||||
);
|
||||
|
||||
expect(bytes, isNotEmpty);
|
||||
// Valid PDF magic header %PDF
|
||||
expect(bytes.sublist(0, 4), equals([0x25, 0x50, 0x44, 0x46]));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user