Error using COM Interface


#1

Hi, i’m using pdfcreator as virtual printer with success. And now i’m looking for COM Interface to integrate in a windows form application (vb.net framework .net 4).
As described in documentation i found example in COM Scripts folder but i cannot run any sample project.
In COM_TestForm project if i start debug and press the TestPage2PF button the program stop at line:

PrintJob.ConvertTo(fullPath)

with error “System.Runtime.InteropServices.COMException (0x80004005): Object reference not set to an instance of an object.”

Same error if i run C# COM_TestForm sample.

Any suggestions
Thank you


#2

I got the same problem. None of the examples work.

I tried adding file to the queue (see code), but still get the same error:

var pdfObj = new PdfCreatorObj();
pdfObj.AddFileToQueue(@"C:\testDocument.pdf");

Stack trace:

   at pdfforge.PDFCreator.Core.ComImplementation.PrintJobAdapter.DoConversion(Job job, String targetFilename)
   at pdfforge.PDFCreator.Core.ComImplementation.PrintJobAdapter.ConvertTo(String fullFileName)
   at pdfforge.PDFCreator.UI.COM.PrintJob.ConvertTo(String fullFileName)
   at COM_TestForm.Form1.testPage_btn_Click(Object sender, EventArgs e) in C:\Program Files\PDFCreator\COM Scripts\C#.Net\COM_TestForm\COM_TestForm\Form1.cs:line 81
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at COM_TestForm.Program.Main() in C:\Program Files\PDFCreator\COM Scripts\C#.Net\COM_TestForm\COM_TestForm\Program.cs:line 18
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

How to fix this?


#3

I have the same Problem with function "ConvertTo(…)


#4

Still having this issue. Anyone have a solution??


#5

I have one same issue with me

Message = “Referência de objeto não definida para uma instância de um objeto.”
Source = “PDFCreator.ComImplementation”
StackTrace = " em pdfforge.PDFCreator.Core.ComImplementation.PrintJobAdapter.DoConversion(Job job, String targetFilename)\r\n em COM_TestForm.Form1.testPage_btn_Click(Object sender, EventArgs e) na C:\Program Files\PDFCreator\COM Scripts\C#.Net\COM_TestForm\CO…


#6

I have same problem here.
I am using PDFCreator 2.4.1, Win 8.1, COM using LotusScript (very similar to VBA).

At line with .ConvertTo(fullfilename) it raises error, but PDF file is created. But for production it is useless…


#7

It is still not fixed - same problem in version 2.5.1 and 2.5.2.
Have you found a solution or workaround?

Best regards,
Michael


#8

I got the same error with 2.5.2

The problem took over half year, any one fix it?


#9

Hi, I got the same issue.
Any solution?


#10

Hi,

the error should be fixed for all COM access except VBA, which seems to be violating the COM principle (The essence of COM is a language-neutral way of implementing objects). So far it is unclear why there is a problem with VBA access, if you’d like to use VBA, please downgrade to PDFCreator 2.4.x for the moment.

Best regards,

Robin


#11

I’m working in c# .NET 4.5, windows application.
It doesn’t work even with 2,4.x version.
I got the following error code: -2147467259, object not set to an instance of an object.
The error occurs invoking ConvertTo function.

var jobQueue = new Queue();
jobQueue.Initialize();
if (!jobQueue.WaitForJob(10))
{
}
else
{
var printJob = jobQueue.NextJob;
printJob.SetProfileByGuid(“DefaultGuid”);
printJob.ConvertTo(outputFile);
}


#12

Hi,

did you already come across http://docs.pdfforge.org/pdfcreator/latest/en/pdfcreator/com-interface/user-manual/how-to/use-com-from-dotnet/#use-com-from-net ?

Best regards,

Robin


#13

It works!
Thank you very much.