Hi!
I'm trying to use COM API to print file to PDF. I tried c# sample that is going with PDFCreator installation (PDFCreator\COM Scripts\C#.Net\COM_TestForm) but I'm getting the following error:
Could you help me please ? Thank you in advance ![:slight_smile: :slight_smile:]()
System.ArgumentException: 'The interaction pdfforge.PDFCreator.UI.Interactions.MainWindowInteraction was not registered with a view!'
Obsidian.dll!pdfforge.Obsidian.Interaction.WindowRegistry.ResolveWindowForInteraction(System.Type interactionType) Unknown
Obsidian.dll!pdfforge.Obsidian.InteractionInvoker.Invoke<pdfforge.PDFCreator.UI.Interactions.MainWindowInteraction>(pdfforge.PDFCreator.UI.Interactions.MainWindowInteraction interaction) Unknown
PDFCreator.ViewModels.dll!pdfforge.PDFCreator.UI.ViewModels.MainWindowThreadLauncher.MainWindowLaunchThreadMethod() Unknown
PDFCreator.Utilities.dll!pdfforge.PDFCreator.Utilities.Threading.SynchronizedThread.RunThread() Unknown
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx) Unknown
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() Unknown
The C# code is this (it fails at "if (!jobQueue.WaitForJob(10))")
//dynamic jobQueue = Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("66A9CAB1-404A-4918-8DE2-29C26B9B271E")));
Queue jobQueue = new Queue();
var assemblyDir = Assembly.GetExecutingAssembly().Location;
var resultsDir = assemblyDir.Replace("\\bin\\Debug\\COM_TestForm.exe", "\\Results");
var convertedFilePath = Path.Combine(resultsDir, "TestPage_2PDF.pdf");
try
{
jobQueue.Initialize();
PrintWindowsTestPage();
if (!jobQueue.WaitForJob(10))
{
MessageBox.Show("The job didn't arrive within 10 seconds");
}
else
{
var printJob = jobQueue.NextJob;
printJob.SetProfileByGuid("DefaultGuid");
printJob.ConvertTo(convertedFilePath);
if (!printJob.IsFinished || !printJob.IsSuccessful)
{
MessageBox.Show("Could not convert: ");
}
else
{
MessageBox.Show("The conversion was succesful!");
}
}
}
catch (Exception err)
{
MessageBox.Show("An error occured: " + err.Message);
}
finally
{
jobQueue.ReleaseCom();
}