02/06/2026 V 5.0.9 Se cambia sobrecarga de CombinaDocx a una nueva funcion CombinaDocxPdfPorBloques
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>tsWPF</id>
|
<id>tsWPF</id>
|
||||||
<version>5.0.8.0</version>
|
<version>5.0.9.0</version>
|
||||||
<authors>Tecnosis</authors>
|
<authors>Tecnosis</authors>
|
||||||
<owners>Tecnosis</owners>
|
<owners>Tecnosis</owners>
|
||||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||||
|
|||||||
@@ -55,10 +55,14 @@ Imports System.Windows
|
|||||||
' mediante el asterisco ('*'), como se muestra a continuación:
|
' mediante el asterisco ('*'), como se muestra a continuación:
|
||||||
' <Assembly: AssemblyVersion("1.0.*")>
|
' <Assembly: AssemblyVersion("1.0.*")>
|
||||||
|
|
||||||
<Assembly: AssemblyVersion("5.0.8.0")>
|
<Assembly: AssemblyVersion("5.0.9.0")>
|
||||||
<Assembly: AssemblyFileVersion("5.0.8.0")>
|
<Assembly: AssemblyFileVersion("5.0.9.0")>
|
||||||
|
|
||||||
|
|
||||||
|
' Cambios en la versión 5.0.9.0
|
||||||
|
|
||||||
|
' 02/06/2026 V 5.0.9 Se cambia sobrecarga de CombinaDocx a una nueva funcion CombinaDocxPdfPorBloques
|
||||||
|
|
||||||
' Cambios en la versión 5.0.8.0
|
' Cambios en la versión 5.0.8.0
|
||||||
|
|
||||||
' 02/06/2026 V 5.0.8 Se añade parametro opcional a docx.combinar
|
' 02/06/2026 V 5.0.8 Se añade parametro opcional a docx.combinar
|
||||||
|
|||||||
@@ -29,53 +29,38 @@ Namespace Utilidades
|
|||||||
Throw New Exception(ex.Message, ex)
|
Throw New Exception(ex.Message, ex)
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
Public Shared Function CombinaDocx(tabla As DataTable, Plantilla() As Byte, FormatoPDF As Boolean, Optional NumRegBloque As Integer = 1000, Optional manejadorCalculateVariable As CalculateDocumentVariableEventHandler = Nothing) As Byte()
|
Public Shared Function CombinaDocxPdfPorBloques(tabla As DataTable, Plantilla() As Byte, NumRegBloque As Integer, Optional manejadorCalculateVariable As CalculateDocumentVariableEventHandler = Nothing) As Byte()
|
||||||
Try
|
Try
|
||||||
|
Dim iNumBloques As Integer = (Int((tabla.Rows.Count - 1) / NumRegBloque)) - 1
|
||||||
If FormatoPDF Then
|
If tabla.Rows.Count Mod NumRegBloque > 1 Then iNumBloques += 1
|
||||||
' Throw New Exception("Exportación a pdf aún no soportada")
|
Dim sp(iNumBloques) As String
|
||||||
Dim iNumBloques As Integer = (Int((tabla.Rows.Count - 1) / NumRegBloque)) - 1
|
Dim sd(iNumBloques) As String
|
||||||
If tabla.Rows.Count Mod NumRegBloque > 1 Then iNumBloques += 1
|
Dim p As New IO.MemoryStream(Plantilla)
|
||||||
Dim sp(iNumBloques) As String
|
Dim iRegIni As Integer
|
||||||
Dim sd(iNumBloques) As String
|
Dim iRegFin As Integer
|
||||||
Dim p As New IO.MemoryStream(Plantilla)
|
For i = 0 To iNumBloques
|
||||||
Dim iRegIni As Integer
|
sd(i) = tsl5.Utilidades.ObtieneFicheroAleatorio("docx")
|
||||||
Dim iRegFin As Integer
|
sp(i) = tsl5.Utilidades.ObtieneFicheroAleatorio("pdf")
|
||||||
For i = 0 To iNumBloques
|
Dim fs As New IO.FileStream(sd(i), IO.FileMode.CreateNew, IO.FileAccess.Write)
|
||||||
sd(i) = tsl5.Utilidades.ObtieneFicheroAleatorio("docx")
|
iRegIni = i * NumRegBloque
|
||||||
sp(i) = tsl5.Utilidades.ObtieneFicheroAleatorio("pdf")
|
iRegFin = Math.Min((i * NumRegBloque) + NumRegBloque - 1, tabla.Rows.Count - 1)
|
||||||
Dim fs As New IO.FileStream(sd(i), IO.FileMode.CreateNew, IO.FileAccess.Write)
|
Debug.WriteLine(Now.ToString & " Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin)
|
||||||
iRegIni = i * NumRegBloque
|
p = New IO.MemoryStream(Plantilla)
|
||||||
iRegFin = Math.Min((i * NumRegBloque) + NumRegBloque - 1, tabla.Rows.Count - 1)
|
Utilidades.Docx.Combinar(p, tabla, fs, iRegIni, iRegFin, DevExpress.XtraRichEdit.DocumentFormat.OpenXml, manejadorCalculateVariable)
|
||||||
Debug.WriteLine(Now.ToString & " Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin)
|
|
||||||
p = New IO.MemoryStream(Plantilla)
|
|
||||||
Utilidades.Docx.Combinar(p, tabla, fs, iRegIni, iRegFin, DevExpress.XtraRichEdit.DocumentFormat.OpenXml, manejadorCalculateVariable)
|
|
||||||
fs.Close()
|
|
||||||
GC.Collect()
|
|
||||||
GC.WaitForPendingFinalizers()
|
|
||||||
Debug.WriteLine(Now.ToString & " Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin & " a pdf")
|
|
||||||
Utilidades.Docx.ExportarApdf(sd(i), sp(i))
|
|
||||||
Debug.WriteLine(Now.ToString & " Fin Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin & " a pdf")
|
|
||||||
GC.Collect()
|
|
||||||
GC.WaitForPendingFinalizers()
|
|
||||||
' fs.Close()
|
|
||||||
Next
|
|
||||||
Dim msPdfUnidos As New IO.MemoryStream
|
|
||||||
TSpdfUtils.pdf.UnePdfs(sp, msPdfUnidos)
|
|
||||||
msPdfUnidos.Seek(0, 0)
|
|
||||||
Return msPdfUnidos.ToArray
|
|
||||||
Else
|
|
||||||
Dim sdocx As String
|
|
||||||
Do
|
|
||||||
sdocx = tsl5.Utilidades.ObtieneFicheroAleatorio("docx")
|
|
||||||
Loop Until Not IO.File.Exists(sdocx)
|
|
||||||
|
|
||||||
Dim fs As New IO.FileStream(sdocx, IO.FileMode.CreateNew, IO.FileAccess.Write)
|
|
||||||
|
|
||||||
Utilidades.Docx.Combinar(New IO.MemoryStream(Plantilla), tabla, fs, 0, tabla.Rows.Count, DevExpress.XtraRichEdit.DocumentFormat.OpenXml, manejadorCalculateVariable)
|
|
||||||
fs.Close()
|
fs.Close()
|
||||||
Return IO.File.ReadAllBytes(sdocx) ' tsl5.Ficheros.FicheroAArrayBytes(sdocx)
|
GC.Collect()
|
||||||
End If
|
GC.WaitForPendingFinalizers()
|
||||||
|
Debug.WriteLine(Now.ToString & " Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin & " a pdf")
|
||||||
|
Utilidades.Docx.ExportarApdf(sd(i), sp(i))
|
||||||
|
Debug.WriteLine(Now.ToString & " Fin Bloque " & i.ToString & " " & iRegIni & "-" & iRegFin & " a pdf")
|
||||||
|
GC.Collect()
|
||||||
|
GC.WaitForPendingFinalizers()
|
||||||
|
' fs.Close()
|
||||||
|
Next
|
||||||
|
Dim msPdfUnidos As New IO.MemoryStream
|
||||||
|
TSpdfUtils.pdf.UnePdfs(sp, msPdfUnidos)
|
||||||
|
msPdfUnidos.Seek(0, 0)
|
||||||
|
Return msPdfUnidos.ToArray
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Throw New Exception(ex.Message, ex)
|
Throw New Exception(ex.Message, ex)
|
||||||
End Try
|
End Try
|
||||||
|
|||||||
Reference in New Issue
Block a user