@@ -2,6 +2,7 @@ import { HTMLComponent } from '../../model/html-component.class';
22import * as mime from 'mime-types' ;
33import { streamToBase64 , readFile } from '../../../../core/tm/controller/file-storage' ;
44import { getArchivoAdjunto } from '../../../../modules/rup/controllers/rup' ;
5+ import { streamToJpegDataUri } from '../../../../utils/pdf/puppeteer' ;
56
67
78export class AdjuntarDocumentoComponent extends HTMLComponent {
@@ -17,7 +18,7 @@ export class AdjuntarDocumentoComponent extends HTMLComponent {
1718 {{#each documentos}}
1819 <div class="subregistro">
1920 <p> {{ term }}: </p>
20- <img class="w-25 archivo-adjunto" src="data:image/png;base64, {{img}}">
21+ <img class="w-50 archivo-adjunto" src="{{img}}">
2122 </div>
2223 {{/each}}
2324 </div>
@@ -45,8 +46,21 @@ export class AdjuntarDocumentoComponent extends HTMLComponent {
4546 return new Promise ( async ( resolve , reject ) => {
4647 if ( documento . id ) {
4748 const stream = await getArchivoAdjunto ( documento . id ) ;
48- const base64 = await streamToBase64 ( stream ) ;
49- return resolve ( { img : base64 , term : documento ?. descripcion ?. term } ) ;
49+ const img = await streamToJpegDataUri ( stream , { maxWidth : 1600 , quality : 75 } ) ;
50+ return resolve ( { img, term : documento ?. descripcion ?. term } ) ;
51+
52+
53+ // const stream = await getArchivoAdjunto(documento.id);
54+ // const dataUri = await streamToOptimizedDataUri(stream, {
55+ // format: 'jpeg', // o 'webp' si necesitás alpha
56+ // quality: 75,
57+ // maxWidth: 1600,
58+ // });
59+ // return resolve({ img: dataUri, term: documento?.descripcion?.term });
60+
61+
62+ // const base64 = await streamToBase64(stream);
63+ // return resolve({ img: base64, term: documento?.descripcion?.term });
5064 }
5165 return ;
5266 } ) ;
0 commit comments