Posts: 133
Threads: 15
Joined: Jun 2014
Hi Gintaras,
I saw this product "ABCpdf" from this website
http://www.websupergoo.com/abcpdf-1.htm
Could you show me how to declare it and use its simplest function like to create a document file?
You can download it here:
http://www.websupergoo.com/download.htm#pd
Posts: 12,061
Threads: 140
Joined: Dec 2002
Macro
ABCpdf .NET
;create variable that manages compiled C# code
CsScript x
x.SetOptions("references=ABCpdf")
;compile code after #ret
x.AddCode("")
;call static function
int R=x.Call("Class1.TestFunction" _s.expandpath("$desktop$\QM ABCpdf.pdf"))
out R
#ret
//C# code
using System;
using WebSupergoo.ABCpdf9;
public class Class1
{
static public int TestFunction(string saveToThisFile)
{
Doc theDoc = new Doc();
theDoc.FontSize = 96;
theDoc.AddText("Quick Macros");
theDoc.Save(saveToThisFile);
theDoc.Clear();
return 1;
}
//add more functions here if need
}
Posts: 133
Threads: 15
Joined: Jun 2014
Thank you very much. It works just great!
One quick question though, could we use typelib to declare it and use
it through COM? Or do we have to use it through C# only?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Macro
ABCpdf COM
IDispatch theDoc._create("ABCpdf9.Doc")
theDoc.FontSize = 96
theDoc.AddText("Quick Macros")
theDoc.Save(_s.expandpath("$desktop$\QM ABCpdf COM.pdf"))
;or
typelib ABCpdf {9F74D25B-CA59-48F9-B374-26CE7A34EF1B} 9.1
ABCpdf.Doc theDoc2._create
theDoc2.FontSize = 96
theDoc2.AddText("Quick Macros")
theDoc2.Save(_s.expandpath("$desktop$\QM ABCpdf COM 2.pdf"))
Posts: 133
Threads: 15
Joined: Jun 2014
Thank you very much, I'm impressed!
The "IDispatch" method works fine.
But the "typelib" method gives me error on the first line at "ABCpdf"
saying that "This name already exist" you have any idea?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Maybe a function named ABCpdf exists, or a variable etc. You can use any name, eg typelib ABCpdf2 ....
Posts: 133
Threads: 15
Joined: Jun 2014
You're absolutely right! After changing its name to ABCpdf2 it works just fine.
Thank you very much for all your help on this topic. I'm really interested in this app
since it supports several languages and COM too! And most importantly QM could use most of them!
Cheers!
Posts: 133
Threads: 15
Joined: Jun 2014
Could you give me an example of this in Visual Basic?
Posts: 12,061
Threads: 140
Joined: Dec 2002
Macro
ABCpdf .NET VB
CsScript x.SetOptions("language=VB[]references=ABCpdf")
x.AddCode("")
int R=x.Call("Class1.TestFunction" _s.expandpath("$desktop$\QM ABCpdf VB.pdf"))
out R
#ret
'VB.NET code
Imports System
Imports WebSupergoo.ABCpdf9
Public Class Class1
Public Shared Function TestFunction(saveToThisFile As String) As Integer
Dim theDoc As New Doc
theDoc.FontSize = 96
theDoc.AddText("Quick Macros")
theDoc.Save(saveToThisFile)
theDoc.Clear()
Return 1
End Function
End Class
Posts: 133
Threads: 15
Joined: Jun 2014
Works like a charm!
Thank you very much!