
We passed Hello123 and Owner123 as password values. First two parameters are the password values in bytes. Note that in setEncryption() method, we passes several arguments. Just added one line tEncryption() to set password to generated PDF. Thus we used the same steps to generate PDF file that we used in previous tutorial. PdfWriter.ALLOW_PRINTING, PdfWriter.ENCRYPTION_AES_128) ĭocument.add( new Paragraph( "Hello World, iText")) ĭocument.add( new Paragraph( new Date().toString())) tEncryption(USER_PASS.getBytes(), OWNER_PASS.getBytes(), PdfWriter writer = PdfWriter.getInstance(document, file) OutputStream file = new FileOutputStream( new File( "D:\\Test.pdf")) Private static String OWNER_PASS = "Owner123" 'allContext = (ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, static String USER_PASS = "Hello123" Response.Write(GetPDFContext(Server.MapPath("~/dummy.pdf"))) In addition, if you want to show the content you got from the pdf file, call a function which returns the content is not enough, you will also need code to show it, Response.Write it for example. Please check below demo which is built based on your code and changed the file path. He has also provided an example GetPDFContext(Server.MapPath("~/organizer.pdf")) since you mentioned the pdf file is "in the root of my site". GetPDFContext("C:\Users\SCOT\source\repos\WebApplication1\WebApplication1\instructions.pdf")īy "an path to the file.", means the relative path of the file. It is not a free tool unless you're going to share your source code. I put in the full path and it doesn't work. 'allContext = (ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, (allContext))) PageContextList.Add(PdfTextExtractor.GetTextFromPage(oReader, i, its))ĭim allContext As String = String.Join(" ", pageContextList) Private Function GetPDFContext(filePath As String) As Stringĭim pageContextList As New List(Of String)įor i As Integer = 1 To oReader.NumberOfPagesĭim its As New SimpleTextExtractionStrategy Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load It sitting right there where I told it in the root of my site. My application is in vb.net so I'm trying to use the code below to display a file.
