Anyone used .net's iTextSharp in Jade?

For questions and postings not covered by the other forums
timmeh
Posts: 18
Joined: Fri Apr 13, 2012 3:12 pm

Anyone used .net's iTextSharp in Jade?

Postby timmeh » Wed Jun 27, 2012 6:16 pm

Trying to utilise this library http://sourceforge.net/projects/itextsharp/ to make working with PDF a little easier for a web project.

After importing the .Net library i've followed this guide:
http://www.mikesdotnetting.com/Article/ ... iTextSharp
and written the following:

Code: Select all

vars doc : Document; stream : FileStream; writer : PdfWriter; begin create doc transient; create stream transient; create writer transient; doc.createDotNetObject(); stream.createDotNetObject_4_82('test.pdf'.StringUtf8,stream.FileMode_OpenOrCreate); writer.getInstance(doc,stream); end;
Although I keep getting this error, and have spent a few hours trying to figure it out:

Code: Select all

Failed to create .NET object System.MissingMethodException: Constructor on type 'iTextSharp.text.pdf.PdfWriter' not found. at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at JadeDotNet.CDotNetObject.CreateObject(String AsmName, String TypName, DskParam* pParams)
I've never written .net before so it's all a bit new to me, what i'm doing wrong is probably really obvious.
'Document' comes from the iTextSharp library, its at 'writer.getInstance(doc,stream);' where I get the above error which I'm struggling with.

Any thoughts would be much appreciated!

User avatar
Dr Danyo
Posts: 56
Joined: Fri Aug 21, 2009 8:59 am

Re: Anyone used .net's iTextSharp in Jade?

Postby Dr Danyo » Wed Jun 27, 2012 8:59 pm

Hi Timmeh,

If I understand you correctly, you are trying to invoke a static factory method (GetInstance) off the non static class PDFWriter ?

public class PdfWriter : iTextSharp.text.DocWriter
Member of iTextSharp.text.pdf

If you have a support license you might want to check with JADE Support, but I didn't think it was possible to invoke static classes or methods from JADE.

In your case because the class is not declared as static, and because you do not explicitly call createDotNetObject (but you do create a transient instance of the JADE proxy class), I think JADE is attempting to create an instance for you on the first use of the local variable.
My understanding is that JADE requires a default constructor (constructor with no parameters) to be defined in order to do this, however both constructors on the class are marked as protected and are inaccessible to JADE, hence the exception.

protected PdfWriter()
Member of iTextSharp.text.pdf.PdfWriter

protected PdfWriter(iTextSharp.text.pdf.PdfDocument document, System.IO.Stream os)
Member of iTextSharp.text.pdf.PdfWriter

If this is the case then I think you may need to consider creating a wrapper assembly to encapsulate the functionality of the ITestSharp library.

Hope this helps - Dr Danyo.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 8 guests