Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Nov 27, 2018 3:57 pm

Hello!

I'm attempting to use Spire.PDF with Unity.. I've installed the free evaluation version spire.pdf-fe_4.3 and copied sprire.pdf.dll and spire.licence.dll from the NET 3.5 directory to my assets directory.

I'm using the following code for testing...

Code: Select all
using Spire.License; // Not sure if this is needed but makes no difference to my error
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

public class SavePDF : MonoBehaviour
{
   public void savePDF()
   {
      pdfTest();
   }
   
   void pdfTest()
   {
      PdfDocument doc = new PdfDocument();
      PdfSection section = doc.Sections.Add();
      PdfPageBase page = doc.Pages.Add();
   
      //Load a tiff image from system
      PdfImage image = PdfImage.FromFile("c:/users/Alex/Desktop/Logo.png");
      //Set image display location and size in PDF
      float widthFitRate = image.PhysicalDimension.Width / page.Canvas.ClientSize.Width;
      float heightFitRate = image.PhysicalDimension.Height / page.Canvas.ClientSize.Height;
      float fitRate = Mathf.Max(widthFitRate, heightFitRate);
      float fitWidth = image.PhysicalDimension.Width / fitRate;
      float fitHeight = image.PhysicalDimension.Height / fitRate;
      page.Canvas.DrawImage(image, 30, 30, fitWidth, fitHeight);      
      
      doc.SaveToFile("c:/users/Alex/Desktop/Test.pdf");
      doc.Close();
   }
}


but as soon as pdfTest() is triggered I get the following error...

Code: Select all
InvalidProgramException: Invalid IL code in Spire.License.LicenseProvider:.cctor (): IL_0014: pop       

Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Spire.License.LicenseProvider
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:513)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:519)
System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:528)
System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:77)
System.Activator.CreateInstance (System.Type type, Boolean nonPublic) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Activator.cs:372)
System.Activator.CreateInstance (System.Type type) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Activator.cs:254)
System.ComponentModel.LicenseManager.privateGetLicense (System.Type type, System.Object instance, Boolean allowExceptions, System.ComponentModel.License& license)
System.ComponentModel.LicenseManager.IsValid (System.Type type, System.Object instance, System.ComponentModel.License& license)
Spire.Pdf.PdfDocumentBase.ᜀ ()
Spire.Pdf.Pdf


Any idea what might be causing this issue? Do I need to manually set a licence file location?

Many thanks!

SpaceWarpStudio
 
Posts: 1
Joined: Tue Nov 27, 2018 1:24 pm

Wed Nov 28, 2018 9:14 am

Hi,

Thanks for your inquiry.
Sorry our products do not support Unity at present. If there is any update in the future, we will let you know.
Sincerely,
Mike
E-iceblue support team
User avatar

Mike.Zhang
 
Posts: 93
Joined: Thu Sep 27, 2018 7:11 am

Return to Spire.PDF

cron