West Wind Internet and Client Tools
wwDotNetBridge PdfDocument from Spire.Pdf.dll
Gravatar is a globally recognized avatar based on your email address. wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Ulrich Hoppe
  All
  Jan 29, 2021 @ 12:17am

Hello Rick Strahl, Please help me by using wwDotNetBridge in foxpro

do wwDotNetBridge
Local loBridge as wwDotNetBridge

loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.GetDotnetVersion()

*** Load an assembly from disk
IF !loBridge.LoadAssembly("Spire.Pdf.dll")
  ? loBridge.cErrorMsg
endif
* I GOT this error
* Es wurde versucht, eine Assembly von einer Netzwerkadresse zu laden, 
* was in früheren Versionen von .NET Framework zum Ausführen der * Assembly als Sandkastenassembly geführt hätte. 
* In dieser Version von .NET Framework wird die CAS-Richtlinie standardmäßig nicht aktiviert, dieser Ladevorgang kann daher  gefährlich sein. 
* Wenn Sie nicht beabsichtigen, durch diesen Ladevorgang eine Sandkastenassembly zu erstellen, 
* aktivieren Sie den * loadFromRemoteSources-Schalter. 
* Weitere Informationen finden Sie unter "http://go.microsoft.com/fwlink/?LinkId=155569".

public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument")   && This does not work!!!!, how do I create an Object from the dll ?
loDoc  =loPdfDocument.LoadFromFile("Example.pdf")

DO you have any ideas. Thank you

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Rick Strahl
  Ulrich Hoppe
  Jan 29, 2021 @ 02:50pm

Take a look here:

Unable to load CLR Instance

Most likely you're loading an assembly from a network drive. Try bringing the DLL into the application folder, or if you can't do that set the configuration setting as described in the help topic.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Rick Strahl
  Ulrich Hoppe
  Feb 9, 2021 @ 02:13pm

Can't help you with more information.

At a guess I'd say the class you're trying to invoke doesn't have a parameterless contstructor and you have to pass parameters to it when you call CreateInstance().

And please look at what you're posting - your message is a garbled mess. Please read on how to format your code on the bottom in front of the Post button.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Ulrich Hoppe
  Rick Strahl
  Feb 10, 2021 @ 07:37am
public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument")   && This does not work!!!!, how do I create an Object from the dll ?
loDoc  =loPdfDocument.LoadFromFile("Example.pdf")

* How do I config loadFromRemoteSources  in VFP ? 
**************************************************
*<configuration>
*  <runtime>
*      <loadFromRemoteSources enabled="true"/>
*  </runtime>
*</configuration>

Here is the example in VBNet

Imports System.Collections.Generic
Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Text
Imports Spire.Pdf

Namespace Extraction
    Friend Class Program
        Shared Sub Main(ByVal args() As String)
            'Create a pdf document.
            Dim doc As New PdfDocument()
            doc.LoadFromFile("Sample2.pdf")

            Dim buffer As New StringBuilder()
            Dim images As IList(Of Image) = New List(Of Image)()

            For Each page As PdfPageBase In doc.Pages
                buffer.Append(page.ExtractText())
                For Each image As Image In page.ExtractImages()
                    images.Add(image)
                Next image
            Next page

            doc.Close()

            'save text
            Dim fileName As String = "TextInPdf.txt"
            File.WriteAllText(fileName, buffer.ToString())

            'save image
            Dim index As Integer = 0
            For Each image As Image In images
                Dim imageFileName As String = String.Format("Image-{0}.png", index)
                index += 1
                image.Save(imageFileName, ImageFormat.Png)
            Next image

            'Launching the Text file.
            Process.Start(fileName)
        End Sub

    End Class
End Namespace
Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Rick Strahl
  Ulrich Hoppe
  Feb 10, 2021 @ 12:00pm

You need to specify the .NET type with a namespace.

Please take a look at the documentation or the White Paper on how to use wwDotnetBridge.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Ulrich Hoppe
  Rick Strahl
  Feb 12, 2021 @ 05:34am

Sorry, but I don't know,whre is the mistake. Do you have any other ideas, why I got an error by using !loBridge.LoadAssembly()?


do wwDotNetBridge
Local loBridge as wwDotNetBridge

loBridge = CreateObject("wwDotNetBridge","V4")
? loBridge.GetDotnetVersion()

*** Load an assembly from disk
IF !loBridge.LoadAssembly("Spire.Pdf.dll")
  ? loBridge.cErrorMsg
endif

public loPdfDocument as PdfDocument
loPdfDocument= loBridge.CreateInstance("PdfDocument")   && This does not work!!!!, how do I create an Object from the dll ?
loDoc  =loPdfDocument.LoadFromFile("Example.pdf")
Gravatar is a globally recognized avatar based on your email address. re: wwDotNetBridge PdfDocument from Spire.Pdf.dll
  Rick Strahl
  Ulrich Hoppe
  Feb 12, 2021 @ 01:42pm

You've got to specify the full type name in CreateInstance() which is the .NET namespace.classname.

I suspect it's:

loInst = loBridge.CreateInstance("Spire.Pdf.PdfDocument")

+++ Rick ---

© 1996-2024