Torna al Thread

Private Sub CreaNuovoFile(ByVal sourcePdfPath As String, ByVal outputPdfPath As String, ByVal password As String, ByVal PasswordNew As String) Try Dim pageCount As Integer = 0 Dim currentPage As Integer = 0 Dim pdfDoc As iTextSharp.text.Document = Nothing Dim writer As iTextSharp.text.pdf.PdfCopy = Nothing Dim page As iTextSharp.text.pdf.PdfImportedPage = Nothing Dim currentPDF As Integer = 0 Dim pdfReader As New PdfReader(sourcePdfPath, New System.Text.ASCIIEncoding().GetBytes(password)) pdfDoc = New iTextSharp.text.Document(pdfReader.GetPageSizeWithRotation(1)) writer = New iTextSharp.text.pdf.PdfCopy(pdfDoc, _ New IO.FileStream(outputPdfPath, _ IO.FileMode.OpenOrCreate, _ IO.FileAccess.Write)) writer.SetEncryption(PdfWriter.STRENGTH128BITS, PasswordNew, PasswordNew, PdfWriter.AllowCopy) pageCount = pdfReader.NumberOfPages pdfDoc.Open() While currentPage < pageCount currentPage += 1 pdfDoc.SetPageSize(pdfReader.GetPageSizeWithRotation(currentPage)) pdfDoc.NewPage() page = writer.GetImportedPage(pdfReader, currentPage) writer.AddPage(page) End While pdfDoc.Close() Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5