imprmir en runtime
This commit is contained in:
@@ -436,6 +436,8 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
If dr("FolioPoliza").ToString.ToEntero > 0 Then
|
If dr("FolioPoliza").ToString.ToEntero > 0 Then
|
||||||
divContabilizada.Visible = True
|
divContabilizada.Visible = True
|
||||||
LblFolio.Text = dr("FolioPoliza").ToString
|
LblFolio.Text = dr("FolioPoliza").ToString
|
||||||
|
Folio = dr("FolioPoliza").ToString
|
||||||
|
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
If dr("IdPoliza").ToString.ToEntero > 0 Then
|
If dr("IdPoliza").ToString.ToEntero > 0 Then
|
||||||
@@ -2004,23 +2006,7 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
|
|
||||||
#Region "Paquete Egresos"
|
#Region "Paquete Egresos"
|
||||||
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
|
Protected Sub LnkImprimirPDF_Click(sender As Object, e As EventArgs)
|
||||||
Dim Pathpdf As New List(Of String)
|
ImprimirPolizaPDF(IdPoliza)
|
||||||
Dim Path As String
|
|
||||||
Try
|
|
||||||
|
|
||||||
Path = ImprimirPolizaPDF(IdPoliza)
|
|
||||||
If File.Exists(Path) Then
|
|
||||||
Pathpdf.Add(Path)
|
|
||||||
End If
|
|
||||||
|
|
||||||
MergePdfFiles(Pathpdf.ToArray)
|
|
||||||
If File.Exists(Path) Then
|
|
||||||
Directory.Delete(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick), True)
|
|
||||||
End If
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
Alert("Error al descargar la poliza", TipoMensaje.MsgError)
|
|
||||||
End Try
|
|
||||||
End Sub
|
End Sub
|
||||||
Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String
|
Private Function ImprimirPolizaPDF(IdPoliza As Integer) As String
|
||||||
Dim ObjConta As New ClsContabilidad
|
Dim ObjConta As New ClsContabilidad
|
||||||
@@ -2056,94 +2042,13 @@ Partial Class ContabilidadC_RegPrePolizaS
|
|||||||
Else
|
Else
|
||||||
ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
|
ruta = "Empresas/Grales/Formatos/Polizas.rdlc"
|
||||||
End If
|
End If
|
||||||
Bytes = StreamPDF(ruta, dtVC, params, "ppoliza")
|
ImprimirbytesPDF(StreamPDF(ruta, dtVC, params, "ppoliza"), String.Format("{0}-{1}", TipoPoliza, dr("FolioPoliza").ToString), "PDF", True)
|
||||||
If Not File.Exists(String.Format("{0}{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)) Then
|
|
||||||
DirectoryExistsCreate(String.Format("{0}{1}", AppDomain.CurrentDomain.BaseDirectory, Tick))
|
|
||||||
File.WriteAllBytes(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString), Bytes)
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
|
Return String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, IdPoliza.ToString)
|
||||||
ObjConta.Dispose()
|
ObjConta.Dispose()
|
||||||
|
|
||||||
End Function
|
End Function
|
||||||
Private Sub MergePdfFiles(ByVal pdfFiles() As String)
|
|
||||||
Dim result As Boolean = False
|
|
||||||
Dim pdfCount As Integer = 0
|
|
||||||
Dim f As Integer = 0
|
|
||||||
Dim fileName As String
|
|
||||||
Dim reader As iTextSharp.text.pdf.PdfReader = Nothing
|
|
||||||
Dim pageCount As Integer = 0
|
|
||||||
Dim pdfDoc As iTextSharp.text.Document = Nothing
|
|
||||||
Dim writer As PdfWriter = Nothing
|
|
||||||
Dim cb As PdfContentByte = Nothing
|
|
||||||
|
|
||||||
Dim page As PdfImportedPage = Nothing
|
|
||||||
Dim rotation As Integer = 0
|
|
||||||
|
|
||||||
|
|
||||||
Try
|
|
||||||
pdfCount = pdfFiles.Length
|
|
||||||
If pdfCount > 0 Then
|
|
||||||
fileName = pdfFiles(f)
|
|
||||||
reader = New iTextSharp.text.pdf.PdfReader(fileName)
|
|
||||||
pageCount = reader.NumberOfPages
|
|
||||||
pdfDoc = New iTextSharp.text.Document(reader.GetPageSizeWithRotation(1), 18, 18, 18, 18)
|
|
||||||
writer = PdfWriter.GetInstance(pdfDoc, New FileStream(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio), FileMode.Create))
|
|
||||||
|
|
||||||
With pdfDoc
|
|
||||||
.Open()
|
|
||||||
End With
|
|
||||||
cb = writer.DirectContent
|
|
||||||
While f < pdfCount
|
|
||||||
Dim i As Integer = 0
|
|
||||||
While i < pageCount
|
|
||||||
i += 1
|
|
||||||
pdfDoc.SetPageSize(reader.GetPageSizeWithRotation(i))
|
|
||||||
pdfDoc.NewPage()
|
|
||||||
page = writer.GetImportedPage(reader, i)
|
|
||||||
rotation = reader.GetPageRotation(i)
|
|
||||||
If rotation = 90 Then
|
|
||||||
cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height)
|
|
||||||
ElseIf rotation = 270 Then
|
|
||||||
cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30)
|
|
||||||
Else
|
|
||||||
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
|
|
||||||
End If
|
|
||||||
End While
|
|
||||||
f += 1
|
|
||||||
If f < pdfCount Then
|
|
||||||
fileName = pdfFiles(f)
|
|
||||||
reader = New iTextSharp.text.pdf.PdfReader(fileName)
|
|
||||||
pageCount = reader.NumberOfPages
|
|
||||||
End If
|
|
||||||
End While
|
|
||||||
|
|
||||||
|
|
||||||
pdfDoc.Close()
|
|
||||||
|
|
||||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio))
|
|
||||||
|
|
||||||
If Archivo.Exists Then
|
|
||||||
HttpContext.Current.Response.Clear()
|
|
||||||
HttpContext.Current.Response.ClearContent()
|
|
||||||
HttpContext.Current.Response.ContentType = "application/octet-stream"
|
|
||||||
HttpContext.Current.Response.AppendHeader("Content-disposition", String.Format("attachment; filename={0}", Archivo.Name))
|
|
||||||
HttpContext.Current.Response.AddHeader("Content-Length", Archivo.Length.ToString())
|
|
||||||
HttpContext.Current.Response.TransmitFile(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio))
|
|
||||||
Response.Flush() ' send it to the client to download
|
|
||||||
HttpContext.Current.Response.SuppressContent = True
|
|
||||||
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
|
||||||
Response.End()
|
|
||||||
|
|
||||||
End If
|
|
||||||
result = True
|
|
||||||
End If
|
|
||||||
Catch ex As Exception
|
|
||||||
End Try
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
|
|
||||||
#End Region
|
#End Region
|
||||||
|
|||||||
@@ -565,8 +565,8 @@ function CargaPickers() {
|
|||||||
TThis.datetimepicker({
|
TThis.datetimepicker({
|
||||||
dayOfWeekStart: 1,
|
dayOfWeekStart: 1,
|
||||||
lang: 'es',
|
lang: 'es',
|
||||||
format: 'd/m/Y H:i',
|
format: 'd/m/Y',
|
||||||
formatDate: 'd/m/Y H:i',
|
formatDate: 'd/m/Y',
|
||||||
step: 30
|
step: 30
|
||||||
});
|
});
|
||||||
if (datetimeButton && datetimeButton.length) {
|
if (datetimeButton && datetimeButton.length) {
|
||||||
|
|||||||
@@ -236,6 +236,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user