[iText-questions] Strange Java problem
Hello, I have a project for which I choose to use itext for generating pdfs, on a web page, which is pdf you select some data, press the generate button, and the php calls a java application with some parameters which generates the pdf, so since the pdf makes a system call the two parts are not explicitly linked, I made the java project, and in my IDE netbeans it works fine, however when I run it in the console it crashes in a strange way... here is the output.. root# java -classpath .:jars/commons-httpclient-3.1.jar:jars/geoIP.jar:jars/iText.jar:jars/jCharts-0.6.0.jar:jars/jFreeChart.jar:jars/nanoxml-lite-2.2.3.jar:jars/servlet.jar:jars/taskapi.jar com.secpoint.pdf.Main 3990.log 3991.log [ModelConverter] Could not handle line: SecPoint(R) Penetrator Audit Engine: 7.1.3.1 [ModelConverter] Could not handle line: Checks: [StreamConverter] Opening PDF file Exception in thread main java.lang.NoSuchMethodError: com.lowagie.text.List.init(ZF)V at com.xxx.pdf.reportpages.Vulnerabilities.addList(Vulnerabilities.java:174) at com.xxx.pdf.reportpages.Vulnerabilities.addVulnerabilities(Vulnerabilities.java:165) at com.xxx.pdf.reportpages.Vulnerabilities.addVulnerabilities(Vulnerabilities.java:149) at com.xxx.pdf.reportpages.Vulnerabilities.init(Vulnerabilities.java:49) at com.xxx.pdf.ReportDocument.writePages(ReportDocument.java:149) at com.xxx.pdf.ReportDocument.write(ReportDocument.java:105) at com.xxx.pdf.Main.main(Main.java:52) root# any thoughts Tancho -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
[iText-questions] deleting a pdf after creating
In my code, I've created a pdf file using itextsharp. Somewhere in my code, I'm opening something and not closing it properly. I'm trying to delete the pdf after creating, but I keep getting an error that it's in use by a process. Any help appreciated. Dim FormFile As String = form.pdf Dim outFile As String = Out.pdf Dim reader As New PdfReader(FormFile) Dim Fstream As FileStream = New FileStream(outFile, FileMode.Create) Dim stamper As New PdfStamper(reader, Fstream)Dim pdfFormFields As AcroFields = stamper.AcroFields pdfFormFields.SetField(contractno, contractno.Text) blah blah blah Try Dim SendFrom As MailAddress = New MailAddress(someaddress@) Dim sendTo As MailAddress = New MailAddress(Someaddress@) Dim MyMessage As MailMessage = New MailMessage(SendFrom, sendTo) MyMessage.Subject = Attached PDF Dim attachFile As New Attachment(Out.pdf) MyMessage.Attachments.Add(attachFile) Dim mailClient As SmtpClient = New SmtpClient MyMessage.IsBodyHtml = False mailClient.Host = mail.com mailClient.Port = 25 mailClient.Credentials = New Net.NetworkCredential(fromaddress, Password) mailClient.Send(MyMessage) Dim fileinfo As FileInfo = New FileInfo(Out.pdf) If fileinfo.Exists Then File.Delete(E:\0\1\61\159\1713648\user\1849424\htdocs\RRSolutions\Out1.pdf) End If Always results in System.IO.IOException: The process cannot access the file 'Out.pdf' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.Delete(String path) at RRSolutions_HighLimitsTest.Button1_Click(Object sender, EventArgs e) in Test.aspx.vb:line 102 Thanks in advance. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] deleting a pdf after creating
PdfStamper.Close() closes the file, check if you can delete the file right after it. Paulo - Original Message - From: Kevin Blackwell akblack...@gmail.com To: itext-questions@lists.sourceforge.net Sent: Sunday, October 18, 2009 5:33 PM Subject: [iText-questions] deleting a pdf after creating In my code, I've created a pdf file using itextsharp. Somewhere in my code, I'm opening something and not closing it properly. I'm trying to delete the pdf after creating, but I keep getting an error that it's in use by a process. Any help appreciated. Dim FormFile As String = form.pdf Dim outFile As String = Out.pdf Dim reader As New PdfReader(FormFile) Dim Fstream As FileStream = New FileStream(outFile, FileMode.Create) Dim stamper As New PdfStamper(reader, Fstream)Dim pdfFormFields As AcroFields = stamper.AcroFields pdfFormFields.SetField(contractno, contractno.Text) blah blah blah Try Dim SendFrom As MailAddress = New MailAddress(someaddress@) Dim sendTo As MailAddress = New MailAddress(Someaddress@) Dim MyMessage As MailMessage = New MailMessage(SendFrom, sendTo) MyMessage.Subject = Attached PDF Dim attachFile As New Attachment(Out.pdf) MyMessage.Attachments.Add(attachFile) Dim mailClient As SmtpClient = New SmtpClient MyMessage.IsBodyHtml = False mailClient.Host = mail.com mailClient.Port = 25 mailClient.Credentials = New Net.NetworkCredential(fromaddress, Password) mailClient.Send(MyMessage) Dim fileinfo As FileInfo = New FileInfo(Out.pdf) If fileinfo.Exists Then File.Delete(E:\0\1\61\159\1713648\user\1849424\htdocs\RRSolutions\Out1.pdf) End If Always results in System.IO.IOException: The process cannot access the file 'Out.pdf' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.Delete(String path) at RRSolutions_HighLimitsTest.Button1_Click(Object sender, EventArgs e) in Test.aspx.vb:line 102 Thanks in advance. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] deleting a pdf after creating
Paulo, Thanks for the comments, But still wont let me delete. I missed a line when posting, but I added stamper.Close() But I still get Dim FormFile As String = form.pdf Dim outFile As String = Out.pdf Dim reader As New PdfReader(FormFile) Dim Fstream As FileStream = New FileStream(outFile, FileMode.Create) Dim stamper As New PdfStamper(reader, Fstream)Dim pdfFormFields As AcroFields = stamper.AcroFields pdfFormFields.SetField(contractno, contractno.Text) reader.Close() stamper.Close() blah blah blah Try Dim SendFrom As MailAddress = New MailAddress(someaddress@) Dim sendTo As MailAddress = New MailAddress(Someaddress@) Dim MyMessage As MailMessage = New MailMessage(SendFrom, sendTo) MyMessage.Subject = Attached PDF Dim attachFile As New Attachment(Out.pdf) MyMessage.Attachments.Add(attachFile) Dim mailClient As SmtpClient = New SmtpClient MyMessage.IsBodyHtml = False mailClient.Host = mail.com mailClient.Port = 25 mailClient.Credentials = New Net.NetworkCredential(fromaddress, Password) mailClient.Send(MyMessage) Dim fileinfo As FileInfo = New FileInfo(Out.pdf) Fstream.Close() If Not Fstream Is Nothing Then Fstream.Dispose() Fstream = Nothing End If If fileinfo.Exists Then File.Delete(Out.pdf) End If Catch ex As Exception Response.Write(ex.ToString) End Try System.IO.IOException: The process cannot access the file 'Out.pdf' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.Delete(String path) at Test.Button1_Click(Object sender, EventArgs e) -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] deleting a pdf after creating
My question is if you can delete right after stamper.Close(). Paulo - Original Message - From: Kevin Blackwell akblack...@gmail.com To: Post all your questions about iText here itext-questions@lists.sourceforge.net Sent: Sunday, October 18, 2009 6:09 PM Subject: Re: [iText-questions] deleting a pdf after creating Paulo, Thanks for the comments, But still wont let me delete. I missed a line when posting, but I added stamper.Close() But I still get Dim FormFile As String = form.pdf Dim outFile As String = Out.pdf Dim reader As New PdfReader(FormFile) Dim Fstream As FileStream = New FileStream(outFile, FileMode.Create) Dim stamper As New PdfStamper(reader, Fstream)Dim pdfFormFields As AcroFields = stamper.AcroFields pdfFormFields.SetField(contractno, contractno.Text) reader.Close() stamper.Close() blah blah blah Try Dim SendFrom As MailAddress = New MailAddress(someaddress@) Dim sendTo As MailAddress = New MailAddress(Someaddress@) Dim MyMessage As MailMessage = New MailMessage(SendFrom, sendTo) MyMessage.Subject = Attached PDF Dim attachFile As New Attachment(Out.pdf) MyMessage.Attachments.Add(attachFile) Dim mailClient As SmtpClient = New SmtpClient MyMessage.IsBodyHtml = False mailClient.Host = mail.com mailClient.Port = 25 mailClient.Credentials = New Net.NetworkCredential(fromaddress, Password) mailClient.Send(MyMessage) Dim fileinfo As FileInfo = New FileInfo(Out.pdf) Fstream.Close() If Not Fstream Is Nothing Then Fstream.Dispose() Fstream = Nothing End If If fileinfo.Exists Then File.Delete(Out.pdf) End If Catch ex As Exception Response.Write(ex.ToString) End Try System.IO.IOException: The process cannot access the file 'Out.pdf' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.File.Delete(String path) at Test.Button1_Click(Object sender, EventArgs e) -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
[iText-questions] acrobat error
Hi all I'm having a problem creating a pdf file with iText in java that can be read properly by abode acrobat. I seem to have tracked the problem down to PdfContentByte I've created a short test program (below). This views ok with foxit reader but comes as a blank page in acrobat9 Any ideas? ** package mine; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfWriter; public class simple { /** * @param args * @throws DocumentException * @throws IOException */ public static void main(String[] args) throws DocumentException, IOException { runMe(); System.out.println(FINISHED); } private static void runMe() throws DocumentException, IOException{ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(c:\\temp\\benchmarkTest.pdf)); document.open(); document.compress = false; BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI, BaseFont.EMBEDDED); PdfContentByte cb = writer.getDirectContent(); cb.setFontAndSize(bf, 7); cb.showTextAligned(PdfContentByte.ALIGN_LEFT,TESTING,200 , 200, 0); cb.closePath(); document.close(); } } *** Stephen Gallaghan ( mailto:sgallag...@energyts.com sgallag...@energyts.com) IT Support Energy Technical Services Ph: 04 3846121, Fax: 04 8016210 PO Box 6004, Marion Square Waterside House Level 6, 220 Willis Street Wellington 6141 Visit our websites: http://www.e-bench.com www.e-bench.com, http://www.energyts.com www.energyts.com or http://www.nzenergysolutionz.com www.nzenergysolutionz.com -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] acrobat error
Post an Actual PDF From: S Gallaghan [mailto:sgallag...@energyts.com] Sent: Sunday, October 18, 2009 6:33 PM To: itext-questions@lists.sourceforge.net Subject: [iText-questions] acrobat error Hi all I'm having a problem creating a pdf file with iText in java that can be read properly by abode acrobat. I seem to have tracked the problem down to PdfContentByte I've created a short test program (below). This views ok with foxit reader but comes as a blank page in acrobat9 Any ideas? ** package mine; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfWriter; public class simple { /** * @param args * @throws DocumentException * @throws IOException */ public static void main(String[] args) throws DocumentException, IOException { runMe(); System.out.println(FINISHED); } private static void runMe() throws DocumentException, IOException{ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(c:\\temp\\benchmarkTest.pdf)); document.open(); document.compress = false; BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI, BaseFont.EMBEDDED); PdfContentByte cb = writer.getDirectContent(); cb.setFontAndSize(bf, 7); cb.showTextAligned(PdfContentByte.ALIGN_LEFT,TESTING,200 , 200, 0); cb.closePath(); document.close(); } } *** Stephen Gallaghan (sgallag...@energyts.commailto:sgallag...@energyts.com) IT Support Energy Technical Services Ph: 04 3846121, Fax: 04 8016210 PO Box 6004, Marion Square Waterside House Level 6, 220 Willis Street Wellington 6141 Visit our websites: www.e-bench.comhttp://www.e-bench.com, www.energyts.comhttp://www.energyts.com or www.nzenergysolutionz.comhttp://www.nzenergysolutionz.com -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] acrobat error
Sorry found the problem. Wasn't using beginText(); And endText(); 8-) From: Leonard Rosenthol [mailto:lrose...@adobe.com] Sent: Monday, 19 October 2009 3:29 p.m. To: Post all your questions about iText here Subject: Re: [iText-questions] acrobat error Post an Actual PDF.. From: S Gallaghan [mailto:sgallag...@energyts.com] Sent: Sunday, October 18, 2009 6:33 PM To: itext-questions@lists.sourceforge.net Subject: [iText-questions] acrobat error Hi all I'm having a problem creating a pdf file with iText in java that can be read properly by abode acrobat. I seem to have tracked the problem down to PdfContentByte I've created a short test program (below). This views ok with foxit reader but comes as a blank page in acrobat9 Any ideas? ** package mine; import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.Document; import com.lowagie.text.DocumentException; import com.lowagie.text.pdf.BaseFont; import com.lowagie.text.pdf.PdfContentByte; import com.lowagie.text.pdf.PdfWriter; public class simple { /** * @param args * @throws DocumentException * @throws IOException */ public static void main(String[] args) throws DocumentException, IOException { runMe(); System.out.println(FINISHED); } private static void runMe() throws DocumentException, IOException{ Document document = new Document(); PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(c:\\temp\\benchmarkTest.pdf)); document.open(); document.compress = false; BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,BaseFont.WINANSI, BaseFont.EMBEDDED); PdfContentByte cb = writer.getDirectContent(); cb.setFontAndSize(bf, 7); cb.showTextAligned(PdfContentByte.ALIGN_LEFT,TESTING,200 , 200, 0); cb.closePath(); document.close(); } } *** Stephen Gallaghan (sgallag...@energyts.com) IT Support Energy Technical Services Ph: 04 3846121, Fax: 04 8016210 PO Box 6004, Marion Square Waterside House Level 6, 220 Willis Street Wellington 6141 Visit our websites: www.e-bench.com, www.energyts.com or www.nzenergysolutionz.com -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/
Re: [iText-questions] Strange Java problem
It's a classpath error that seems to emanate from your com.xxx.pdf... app in its call to iText. Looking at your classpath, I see that you're linking to itext.jar, which is not a standard name for an iText jar. Check your classpath. Netbeans can generate an Ant file to run your app. Look at its classpath and compare it with yours. Technically speaking, this is a Java question, not an iText question, and you probably won't get much more help on it from this mailing list. Good luck, ---mr. bean re Tanco wrote: Hello, I have a project for which I choose to use itext for generating pdfs, on a web page, which is pdf you select some data, press the generate button, and the php calls a java application with some parameters which generates the pdf, so since the pdf makes a system call the two parts are not explicitly linked, I made the java project, and in my IDE netbeans it works fine, however when I run it in the console it crashes in a strange way... here is the output.. root# java -classpath .:jars/commons-httpclient-3.1.jar:jars/geoIP.jar:jars/iText.jar:jars/jCharts-0.6.0.jar:jars/jFreeChart.jar:jars/nanoxml-lite-2.2.3.jar:jars/servlet.jar:jars/taskapi.jar com.secpoint.pdf.Main 3990.log 3991.log [ModelConverter] Could not handle line: SecPoint(R) Penetrator Audit Engine: 7.1.3.1 [ModelConverter] Could not handle line: Checks: [StreamConverter] Opening PDF file Exception in thread main java.lang.NoSuchMethodError: com.lowagie.text.List.init(ZF)V at com.xxx.pdf.reportpages.Vulnerabilities.addList(Vulnerabilities.java:174) at com.xxx.pdf.reportpages.Vulnerabilities.addVulnerabilities(Vulnerabilities.java:165) at com.xxx.pdf.reportpages.Vulnerabilities.addVulnerabilities(Vulnerabilities.java:149) at com.xxx.pdf.reportpages.Vulnerabilities.init(Vulnerabilities.java:49) at com.xxx.pdf.ReportDocument.writePages(ReportDocument.java:149) at com.xxx.pdf.ReportDocument.write(ReportDocument.java:105) at com.xxx.pdf.Main.main(Main.java:52) root# any thoughts Tancho -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/ -- View this message in context: http://www.nabble.com/Strange-Java-problem-tp25945918p25953116.html Sent from the iText - General mailing list archive at Nabble.com. -- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference ___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://www.1t3xt.com/docs/book.php Check the site with examples before you ask questions: http://www.1t3xt.info/examples/ You can also search the keywords list: http://1t3xt.info/tutorials/keywords/