qutiado puppeter y probando otra cosa

This commit is contained in:
2025-09-26 11:31:35 +02:00
parent f740b95a1c
commit fe101a5554
272 changed files with 493 additions and 564 deletions

View File

@@ -0,0 +1,23 @@
using System.Reflection;
using System.Runtime.Loader;
namespace HerramientaCASA
{
public class AssemnlyLoadwkhtmltox : AssemblyLoadContext
{
public IntPtr LoadUnmanagedLibrary(string absolutePath)
{
return LoadUnmanagedDll(absolutePath);
}
protected override IntPtr LoadUnmanagedDll(string unmanagedDllPath)
{
return LoadUnmanagedDllFromPath(unmanagedDllPath);
}
protected override Assembly Load(AssemblyName assemblyName)
{
return null;
}
}
}

View File

@@ -13,7 +13,7 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
<link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
<link href="Content/Site.css?v=0.56" rel="stylesheet" />
<link href="Content/Site.css?v=0.62" rel="stylesheet" />
<link href="Content/all.min.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<script src="Scripts/jquery.min.js"></script>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -6,25 +6,43 @@
@msTextoEncabezado
</p>
<div class="d-flex flex-column mt-3">
<div class="mt-3">
<label>Simulación: <span class="NombreSimulacionImprimir">@objetoCASA.NombreSimulacion</span></label>
<br />
<label>Fecha de creación: <span class="NombreSimulacionImprimir">@DateTime.Now</span></label>
</div>
</div>
@* TABLA COSTE HORA DESPACHO PROFESIONAL *@
<table>
<tr style="border-color: red !important;
border-width: 1px !important;
BORDER-STYLE: SOLID !important;
background-color:blue !important;
color:white !important;
">
<td>
hola
</td>
<td>adios</td>
</tr>
</table>
<div class="col-8 mx-auto" style="align-items: flex-end; margin-bottom:30px;">
<div class="TituloTablaImprimir">
<b>Coste hora de los trabajos realizados por el despacho profesional</b>
</div>
<div class="table-responsive espacioTablas">
<table class="TablaImprimir mb-0" style="width:100%;">
<thead>
<tr>
<tr style="border-color: red;
border-width: 1px;
BORDER-STYLE: SOLID;
background-color:blue;
color:white;
">
<th>Tipo de costes</th>
<th>Coste/hora</th>
</tr>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -13,10 +13,25 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Compile Remove="wwwroot\chrome-win\**" />
<Content Remove="wwwroot\chrome-win\**" />
<EmbeddedResource Remove="wwwroot\chrome-win\**" />
<None Remove="wwwroot\chrome-win\**" />
</ItemGroup>
<ItemGroup>
<Content Include="DinkToPdf\libs\win-x64\libwkhtmltox.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Blazor.Bootstrap" Version="3.3.1" />
<PackageReference Include="ClosedXML" Version="0.105.0" />
<PackageReference Include="PuppeteerSharp" Version="20.2.2" />
<PackageReference Include="DinkToPdf" Version="1.0.8" />
</ItemGroup>
<ItemGroup>
@@ -28,4 +43,10 @@
<ProjectReference Include="..\bdHerramientaCACOA\bdHerramientaCACOA.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="wwwroot\Content\Site.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -1,11 +1,27 @@
using bdHerramientaCACOA.dbcontext;
using DinkToPdf;
using DinkToPdf.Contracts;
using HerramientaCASA;
using HerramientaCASA.Components;
using HerramientaCASA.Model;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
using System.Globalization;
using System.Runtime.InteropServices;
var builder = WebApplication.CreateBuilder(args);
var context = new AssemnlyLoadwkhtmltox();
// ruta a la dll nativa
context.LoadUnmanagedLibrary(
Path.Combine(Directory.GetCurrentDirectory(), "DinkToPdf", "libs", "win-x64", "libwkhtmltox.dll")
);
builder.Services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));
builder.Services.AddScoped<ServicioPDF>();
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();

View File

@@ -0,0 +1,122 @@
using DinkToPdf;
using DinkToPdf.Contracts;
using System.Text;
namespace HerramientaCASA
{
public class ServicioPDF
{
private readonly IConverter _converter;
public ServicioPDF(IConverter converter)
{
_converter = converter;
}
public byte[] GenerarPdf(string html)
{
var doc = new HtmlToPdfDocument()
{
GlobalSettings = {
PaperSize = PaperKind.A4,
Orientation = Orientation.Portrait,
},
Objects = {
new ObjectSettings() {
HtmlContent = html,
WebSettings = { DefaultEncoding = "utf-8", UserStyleSheet = Path.Combine(Environment.CurrentDirectory, "wwwroot", "Content", "Site.css") }
}
}
};
return _converter.Convert(doc);
}
// /// <summary>
// /// Convierte HTML a PDF (bytes) usando HtmlRenderer.PdfSharpCore, inyectando site.css.
// /// </summary>
// /// <param name="htmlBody">
// /// Contenido HTML del body (o el documento completo). Si pasas solo el body, se envolverá automáticamente.
// /// </param>
// /// <param name="siteCssPath">Ruta al archivo site.css en el servidor (p. ej. "wwwroot/css/site.css").</param>
// /// <param name="baseUri">
// /// (Opcional) Base para resolver rutas relativas.
// /// Se inserta como &lt;base href="..."&gt; en &lt;head&gt;.
// /// </param>
// /// <param name="pageSize">Tamaño de página (A4 por defecto).</param>
// /// <param name="margin">Margen en puntos (40 por defecto).</param>
// public byte[] HtmlToPdfWithSiteCss(
// string htmlBody,
// string siteCssPath,
// string? baseUri = null,
// PdfSharpCore.PageSize pageSize = PdfSharpCore.PageSize.A4,
// int margin = 40
// )
// {
// if (string.IsNullOrWhiteSpace(htmlBody))
// throw new ArgumentException("El HTML no puede estar vacío.", nameof(htmlBody));
// if (string.IsNullOrWhiteSpace(siteCssPath) || !File.Exists(siteCssPath))
// throw new FileNotFoundException("No se encontró el archivo CSS indicado.", siteCssPath);
// // Evitar problemas de codificación (tildes, ñ)
// Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
// // Lee el CSS local
// var css = File.ReadAllText(siteCssPath);
// // HTML mínimo
// bool isFullHtml = htmlBody.Contains("<html", StringComparison.OrdinalIgnoreCase);
// string headExtras = $"<meta charset='utf-8'><style>{css}</style>";
// if (!string.IsNullOrWhiteSpace(baseUri))
// headExtras = $"<base href=\"{baseUri}\">{headExtras}";
// string fullHtml = isFullHtml
// ? InjectIntoHead(htmlBody, headExtras)
// : $"<!doctype html><html><head>{headExtras}</head><body>{htmlBody}</body></html>";
// var cfg = new PdfGenerateConfig
// {
// PageSize = (PdfSharp.PageSize)pageSize,
// MarginLeft = margin,
// MarginRight = margin,
// MarginTop = margin,
// MarginBottom = margin
// };
// using var doc = PdfGenerator.GeneratePdf(fullHtml, cfg);
// using var ms = new MemoryStream();
// doc.Save(ms);
// return ms.ToArray();
// // Inserta contenido en <head> (si existe); si no, lo crea.
// static string InjectIntoHead(string html, string toInject)
// {
// int headOpen = html.IndexOf("<head", StringComparison.OrdinalIgnoreCase);
// if (headOpen >= 0)
// {
// int headClose = html.IndexOf('>', headOpen);
// if (headClose > headOpen)
// {
// return html.Insert(headClose + 1, toInject);
// }
// }
// // No hay <head>, lo creamos
// int htmlOpen = html.IndexOf("<html", StringComparison.OrdinalIgnoreCase);
// if (htmlOpen >= 0)
// {
// int htmlTagEnd = html.IndexOf('>', htmlOpen);
// if (htmlTagEnd > htmlOpen)
// {
// return html.Insert(htmlTagEnd + 1, $"<head>{toInject}</head>");
// }
// }
// // Documento raro: envolvemos completo
// return $"<!doctype html><html><head>{toInject}</head><body>{html}</body></html>";
// }
// }
//}
}
}

View File

@@ -821,7 +821,7 @@ div.content {
.TablaImprimir table {
border-collapse: collapse;
width: 100%;
font-size: 9pt;
font-size: 984pt;
}
.TablaImprimir thead tr th {

View File

@@ -1,8 +0,0 @@
<assembly
xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<assemblyIdentity
name='142.0.7435.0'
version='142.0.7435.0'
type='win32'/>
<file name='chrome_elf.dll'/>
</assembly>

View File

@@ -1 +0,0 @@
krome

View File

@@ -1,6 +0,0 @@
{
"manifest_version": 2,
"name": "Iwa Key Distribution",
"version": "2025.7.24.0",
"is_preloaded": true
}

View File

@@ -1,8 +0,0 @@
{
"name": "MEI Preload",
"icons": {},
"version": "1.0.7.1652906823",
"manifest_version": 2,
"update_url": "https://clients2.google.com/service/update2/crx",
"description": "Contains preloaded data for Media Engagement"
}

View File

@@ -1,6 +0,0 @@
{
"manifest_version": 2,
"name": "Privacy Sandbox Attestations",
"version": "2025.7.18.0",
"pre_installed": true
}

View File

@@ -1,262 +0,0 @@
https://2k.comhttps://33across.comhttps://360yield.comhttps://3lift.comhttps://ad-score.com
https://ad.gthttps://adentifi.comhttps://adform.nethttps://adingo.jphttps://admatrix.jphttps://admixer.nethttps://adnami.iohttps://adnxs.comhttps://adsafeprotected.comhttps://adsrvr.orghttps://adthrive.comhttps://advividnetwork.comNhttps://aggregation-service-site-dot-clz200258-datateam-italy.ew.r.appspot.comhttps://anonymised.iohttps://aphub.aihttps://appier.nethttps://avads.nethttps://ayads.iohttps://bidswitch.nethttps://bidtheatre.nethttps://bing.comhttps://blendee.comhttps://bounceexchange.comhttps://bypass.jphttps://casalemedia.comhttps://cdn-net.comhttps://clickonometrics.plhttps://connected-stories.comhttps://crcldu.comhttps://creativecdn.comhttps://criteo.comhttps://ctnsnet.comhttps://daum.nethttps://display.iohttps://dotdashmeredith.comhttps://dotomi.comhttps://doubleclick.nethttps://dynalyst.jphttps://edkt.iohttps://ezoic.comhttps://fanbyte.comhttps://flashtalking.comhttps://fout.jphttps://fwmrm.nethttps://gama.globohttps://ghtinc.comhttps://gmossp-sp.jphttps://google-analytics.comhttps://gsspat.jphttps://gumgum.comhttps://html-load.comhttps://im-apps.nethttps://impact-ad.jphttps://indexww.comhttps://inmobi.comhttps://innovid.comhttps://jivox.comhttps://kakao.comhttps://kidoz.nethttps://ladsp.comhttps://lucead.comhttps://mail.ruhttps://media.nethttps://mediaintelligence.dehttps://mediamath.comhttps://mediavine.comhttps://microad.jphttps://naver.comhttps://nhnace.comhttps://nodals.iohttps://onetag-sys.comhttps://openx.nethttps://optable.cohttps://outbrain.comhttps://pixfuture.com+https://privacy-sandbox-demos-ad-server.dev'https://privacy-sandbox-demos-dsp-a.dev'https://privacy-sandbox-demos-dsp-b.dev'https://privacy-sandbox-demos-dsp-x.dev'https://privacy-sandbox-demos-dsp-y.dev%https://privacy-sandbox-demos-dsp.dev*https://privacy-sandbox-demos-services.dev'https://privacy-sandbox-demos-ssp-a.dev'https://privacy-sandbox-demos-ssp-b.dev'https://privacy-sandbox-demos-ssp-x.dev'https://privacy-sandbox-demos-ssp-y.dev%https://privacy-sandbox-demos-ssp.dev https://privacy-sandbox-test.com0https://privacy-sandcastle-dev-ad-server.web.app-https://privacy-sandcastle-dev-dsp-a1.web.app-https://privacy-sandcastle-dev-dsp-b1.web.app,https://privacy-sandcastle-dev-dsp-x.web.app,https://privacy-sandcastle-dev-dsp-y.web.app*https://privacy-sandcastle-dev-dsp.web.app/https://privacy-sandcastle-dev-services.web.app,https://privacy-sandcastle-dev-ssp-a.web.app,https://privacy-sandcastle-dev-ssp-b.web.app,https://privacy-sandcastle-dev-ssp-x.web.app,https://privacy-sandcastle-dev-ssp-y.web.app*https://privacy-sandcastle-dev-ssp.web.apphttps://pub.networkhttps://pubmatic.comhttps://pubtm.comhttps://quantserve.comhttps://relevant-digital.comhttps://sascdn.comhttps://shinystat.comhttps://shop.byhttps://singular.nethttps://sportradarserving.comhttps://t13.iohttps://teads.tvhttps://thepopradar.comhttps://theryn.iohttps://tncid.apphttps://toponad.comhttps://tpmark.nethttps://tribalfusion.comhttps://triptease.iohttps://uinterbox.comhttps://uol.com.br
https://vg.nohttps://vpadn.comhttps://washingtonpost.comhttps://yahoo.co.jphttps://yahoo.comhttps://yandex.ruhttps://yelp.com
https://stackadapt.com

https://yieldlab.net
%
https://googlesyndication.com

https://worldhistory.org

https://sitescout.com

https://docomo.ne.jp

https://tamedia.com.tw

https://connatix.com

https://quora.com

https://presage.io

https://onet.pl
%
https://creative-serving.com

https://dreammail.jp

https://bluems.com

https://storygize.net
#
https://amazon-adsystem.com

https://undertone.com

https://finn.no

https://ad-stir.com
#
https://youronlinechoices.eu

https://disqus.com
&
https://adtrafficquality.google

https://tya-dev.com
&
https://googleadservices.com

https://akpytela.cz
!
https://ebayadservices.com

https://linkedin.com

https://postrelease.com

https://shinobi.jp

https://tiktok.com

https://torneos.gg

https://primecaster.net

https://payment.goog

https://ebis.ne.jp

https://iobeya.com

https://ingereck.net
"
https://kompaspublishing.nl

https://r2b2.io

https://dailymail.co.uk

https://pinterest.com

https://verve.com

https://fandom.com

https://trkkn.com

https://azubiyo.de

https://jkforum.net

https://lwadm.com
%
https://audienceproject.com

https://facebook.com

https://trip.com
"
https://rubiconproject.com

https://apex-football.com

https://adswizz.com
#
https://adsmeasurement.com

https://a-mo.net

https://tangooserver.com

https://retargetly.com

https://elle.com

https://yieldmo.com

https://momento.dev
"
https://appsflyersdk.com

https://gokwik.co

https://snapchat.com
7
/https://shared-storage-demo-publisher-b.web.app

https://tailtarget.com

https://alketech.eu

https://aniview.com

https://demand.supply

https://doubleverify.com
!
https://weborama-tech.ru
%
https://wepowerconnections.com

https://beaconmax.com

https://nexxen.tech

https://permutive.app

https://admission.net
1
(https://paa-reporting-advertising.amazon
(
https://smadexprivacysandbox.com

https://eloan.co.jp

https://cpx.to

https://atirun.com

https://adscale.de

https://semafor.com
6
/https://ptb-msmt-static-5jyy5ulagq-uc.a.run.app

https://i-mobile.co.jp

https://atomex.net

https://sephora.com
#
https://explorefledge.com

https://weborama.fr

https://aqfer.com

https://taboola.com

https://elnacional.cat

https://coupang.com
<
4https://shared-storage-demo-content-producer.web.app
!
https://dailymotion.com

https://gunosy.com

https://xsoda.net

https://getyourguide.com

https://get3rdspace.com

https://boost-web.com
"
https://rocksolidrustic.com

https://grxchange.gr
"
https://d-edgeconnect.media

https://samplicio.us
!
https://audience360.com.au

https://getcapi.co

https://logly.co.jp

https://kargo.com

https://appconsent.io

https://open-bid.com

https://insyta.com

https://adroll.com

https://moshimo.com

https://convertunits.com

https://appsflyer.com

https://vidazoo.com

https://validate.audio

https://globo.com

https://seedtag.com
7
/https://shared-storage-demo-publisher-a.web.app

https://metro.co.uk

https://usemax.de

https://deepintent.com

https://cazamba.com

https://superfine.org
"
https://authorizedvault.com
"
https://media6degrees.com

https://socdm.com

https://euleriancdn.net

https://wp.pl

https://acxiom.com

Some files were not shown because too many files have changed in this diff Show More