Merge branch 'master' of http://192.168.10.111:8383/SIG
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports iTextSharp.text.pdf
|
||||
Imports iText.Kernel.Geom
|
||||
Imports iText.Kernel.Pdf
|
||||
Imports iText.Kernel.Pdf.Canvas
|
||||
Imports iText.Layout
|
||||
Imports iText.IO.Image
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
Partial Class Contabilidad_FiltraPolizas
|
||||
@@ -330,20 +334,13 @@ Partial Class Contabilidad_FiltraPolizas
|
||||
Dim formato As String = System.IO.Path.GetExtension(Path)
|
||||
If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then
|
||||
Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick)
|
||||
Using crea_archivo = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 18, 18, 18, 18)
|
||||
PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create))
|
||||
crea_archivo.Open()
|
||||
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path)
|
||||
If image.Height > image.Width Then
|
||||
Dim percentage As Double = 0.0F
|
||||
percentage = 700 / image.Height
|
||||
image.ScalePercent(percentage * 100)
|
||||
Else
|
||||
Dim percentage As Double = 0.0F
|
||||
percentage = 540 / image.Width
|
||||
image.ScalePercent(percentage * 100)
|
||||
End If
|
||||
crea_archivo.Add(image)
|
||||
Using documento = New Document(New PdfDocument(New PdfWriter(New FileStream(ComprobantePDF, FileMode.Create))), PageSize.A4)
|
||||
documento.SetMargins(18, 18, 18, 18)
|
||||
Dim image = New Element.Image(ImageDataFactory.Create(Path))
|
||||
'image.ScaleToFit(documento.GetPageEffectiveArea(PageSize.A4).GetWidth(), documento.GetPageEffectiveArea(PageSize.A4).GetHeight())
|
||||
image.ScaleToFit(540, 700)
|
||||
documento.Add(image)
|
||||
documento.Close()
|
||||
End Using
|
||||
Pathpdf.Add(ComprobantePDF)
|
||||
Else
|
||||
@@ -475,60 +472,51 @@ Partial Class Contabilidad_FiltraPolizas
|
||||
ObjConta.Dispose()
|
||||
|
||||
End Function
|
||||
Private Sub MergePdfFiles(ByVal pdfFiles() As String)
|
||||
Dim result As Boolean = False
|
||||
Dim pdfCount As Integer = 0
|
||||
Private Sub MergePdfFiles(pdfFilesList() As String)
|
||||
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
|
||||
|
||||
Dim pdfCount As Integer = pdfFilesList.Length
|
||||
|
||||
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}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, "poliza"), FileMode.Create))
|
||||
Dim currentFile = pdfFilesList(f)
|
||||
Dim reader As New PdfReader(currentFile)
|
||||
Dim srcDoc As New PdfDocument(reader)
|
||||
Dim pageCount = srcDoc.GetNumberOfPages()
|
||||
|
||||
Dim writer As New PdfWriter(New FileStream(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, "poliza"), FileMode.Create))
|
||||
Dim mergedDoc As New PdfDocument(writer)
|
||||
Dim document As New Document(mergedDoc, srcDoc.GetFirstPage.GetPageSizeWithRotation())
|
||||
document.SetMargins(18, 18, 18, 18)
|
||||
|
||||
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)
|
||||
Dim p As Integer = 0
|
||||
While p < pageCount
|
||||
p += 1
|
||||
Dim srcPage = srcDoc.GetPage(p)
|
||||
Dim srcPageSize = srcPage.GetPageSizeWithRotation()
|
||||
mergedDoc.SetDefaultPageSize(srcPageSize)
|
||||
Dim canvas As New PdfCanvas(mergedDoc.AddNewPage())
|
||||
Dim srcPageXObj = srcPage.CopyAsFormXObject(mergedDoc)
|
||||
Dim rotation = srcPage.GetRotation()
|
||||
If rotation = 90 Then
|
||||
cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 0, -1.0F, 1.0F, 0, 0, srcPageSize.GetHeight())
|
||||
ElseIf rotation = 270 Then
|
||||
cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 0, 1.0F, -1.0F, 0, srcPageSize.GetWidth() + 60, -30)
|
||||
Else
|
||||
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 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
|
||||
currentFile = pdfFilesList(f)
|
||||
reader = New PdfReader(currentFile)
|
||||
srcDoc = New PdfDocument(reader)
|
||||
pageCount = srcDoc.GetNumberOfPages()
|
||||
End If
|
||||
End While
|
||||
|
||||
|
||||
pdfDoc.Close()
|
||||
srcDoc.Close()
|
||||
document.Close()
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, "Poliza"))
|
||||
|
||||
@@ -541,16 +529,14 @@ Partial Class Contabilidad_FiltraPolizas
|
||||
Response.Flush() ' send it to the client to download
|
||||
HttpContext.Current.Response.SuppressContent = True
|
||||
HttpContext.Current.ApplicationInstance.CompleteRequest()
|
||||
|
||||
Response.End()
|
||||
|
||||
End If
|
||||
result = True
|
||||
Dim result As Boolean = True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Private Function VerificarComprobante(ByVal PrepolizaDetalle As DataTable) As String
|
||||
|
||||
@@ -4,9 +4,14 @@ Imports System.Data
|
||||
Imports System.IO
|
||||
Imports Extensiones
|
||||
Imports GemBox.Spreadsheet
|
||||
Imports iTextSharp.text.pdf
|
||||
Imports iText.Kernel.Geom
|
||||
Imports iText.Kernel.Pdf
|
||||
Imports iText.Kernel.Pdf.Canvas
|
||||
Imports iText.Layout
|
||||
Imports iText.IO.Image
|
||||
Imports Microsoft.Reporting.WebForms
|
||||
|
||||
|
||||
Partial Class ContabilidadC_RegPrePoliza
|
||||
Inherits ClsPaginas
|
||||
|
||||
@@ -1865,20 +1870,13 @@ Partial Class ContabilidadC_RegPrePoliza
|
||||
Dim formato As String = System.IO.Path.GetExtension(Path)
|
||||
If formato.ToLower.Contiene(".jpg", ".png", ".jpeg") Then
|
||||
Dim ComprobantePDF As String = String.Format("{0}\{1}\comprobante.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick)
|
||||
Using crea_archivo = New iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 18, 18, 18, 18)
|
||||
PdfWriter.GetInstance(crea_archivo, New FileStream(ComprobantePDF, FileMode.Create))
|
||||
crea_archivo.Open()
|
||||
Dim image As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Path)
|
||||
If image.Height > image.Width Then
|
||||
Dim percentage As Double = 0.0F
|
||||
percentage = 700 / image.Height
|
||||
image.ScalePercent(percentage * 100)
|
||||
Else
|
||||
Dim percentage As Double = 0.0F
|
||||
percentage = 540 / image.Width
|
||||
image.ScalePercent(percentage * 100)
|
||||
End If
|
||||
crea_archivo.Add(image)
|
||||
Using documento = New Document(New PdfDocument(New PdfWriter(New FileStream(ComprobantePDF, FileMode.Create))), PageSize.A4)
|
||||
documento.SetMargins(18, 18, 18, 18)
|
||||
Dim image = New Element.Image(ImageDataFactory.Create(Path))
|
||||
'image.ScaleToFit(documento.GetPageEffectiveArea(PageSize.A4).GetWidth(), documento.GetPageEffectiveArea(PageSize.A4).GetHeight())
|
||||
image.ScaleToFit(540, 700)
|
||||
documento.Add(image)
|
||||
documento.Close()
|
||||
End Using
|
||||
Pathpdf.Add(ComprobantePDF)
|
||||
Else
|
||||
@@ -1986,60 +1984,51 @@ Partial Class ContabilidadC_RegPrePoliza
|
||||
ObjConta.Dispose()
|
||||
|
||||
End Function
|
||||
Private Sub MergePdfFiles(ByVal pdfFiles() As String)
|
||||
Dim result As Boolean = False
|
||||
Dim pdfCount As Integer = 0
|
||||
Private Sub MergePdfFiles(ByVal pdfFilesList() As String)
|
||||
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
|
||||
|
||||
Dim pdfCount As Integer = pdfFilesList.Length
|
||||
|
||||
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))
|
||||
Dim currentFile = pdfFilesList(f)
|
||||
Dim reader As New PdfReader(currentFile)
|
||||
Dim srcDoc As New PdfDocument(reader)
|
||||
Dim pageCount = srcDoc.GetNumberOfPages()
|
||||
|
||||
Dim writer As New PdfWriter(New FileStream(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio), FileMode.Create))
|
||||
Dim mergedDoc As New PdfDocument(writer)
|
||||
Dim document As New Document(mergedDoc, srcDoc.GetFirstPage.GetPageSizeWithRotation())
|
||||
document.SetMargins(18, 18, 18, 18)
|
||||
|
||||
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)
|
||||
Dim p As Integer = 0
|
||||
While p < pageCount
|
||||
p += 1
|
||||
Dim srcPage = srcDoc.GetPage(p)
|
||||
Dim srcPageSize = srcPage.GetPageSizeWithRotation()
|
||||
mergedDoc.SetDefaultPageSize(srcPageSize)
|
||||
Dim canvas As New PdfCanvas(mergedDoc.AddNewPage())
|
||||
Dim srcPageXObj = srcPage.CopyAsFormXObject(mergedDoc)
|
||||
Dim rotation = srcPage.GetRotation()
|
||||
If rotation = 90 Then
|
||||
cb.AddTemplate(page, 0, -1.0F, 1.0F, 0, 0, reader.GetPageSizeWithRotation(i).Height)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 0, -1.0F, 1.0F, 0, 0, srcPageSize.GetHeight())
|
||||
ElseIf rotation = 270 Then
|
||||
cb.AddTemplate(page, 0, 1.0F, -1.0F, 0, reader.GetPageSizeWithRotation(i).Width + 60, -30)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 0, 1.0F, -1.0F, 0, srcPageSize.GetWidth() + 60, -30)
|
||||
Else
|
||||
cb.AddTemplate(page, 1.0F, 0, 0, 1.0F, 0, 0)
|
||||
canvas.AddXObjectWithTransformationMatrix(srcPageXObj, 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
|
||||
currentFile = pdfFilesList(f)
|
||||
reader = New PdfReader(currentFile)
|
||||
srcDoc = New PdfDocument(reader)
|
||||
pageCount = srcDoc.GetNumberOfPages()
|
||||
End If
|
||||
End While
|
||||
|
||||
|
||||
pdfDoc.Close()
|
||||
srcDoc.Close()
|
||||
document.Close()
|
||||
|
||||
Dim Archivo As New System.IO.FileInfo(String.Format("{0}\{1}\{2}-{3}.pdf", AppDomain.CurrentDomain.BaseDirectory, Tick, TipoPoliza, Folio))
|
||||
|
||||
@@ -2056,13 +2045,11 @@ Partial Class ContabilidadC_RegPrePoliza
|
||||
Response.End()
|
||||
|
||||
End If
|
||||
result = True
|
||||
Dim result As Boolean = True
|
||||
End If
|
||||
Catch ex As Exception
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
||||
Reference in New Issue
Block a user