Loading a PDF with Windows Service

Discussions about PDF management.
Post Reply
prosigma
Posts: 8
Joined: Tue Nov 10, 2009 2:26 pm

Loading a PDF with Windows Service

Post by prosigma » Wed Jan 27, 2010 10:41 am

Hello,

I've sent you a mail with this content:
I encountered a problem with the use of PDFs in GdPicture.NET.

I have to load a PDF as byte[ ] with GdPicture to perform an "Automatic Document Recognition" on it.
Is there an option other than loading the byte[ ] with GdPicture.GdViewer.DisplayFromByteArray(byte[ ]) followed by GdPicture.GdViewer.PdfRenderPageToGdPictureImage(int,int)?

I can't use the GdViewer because the ADR is performed in a WindowsService, so there is no GUI available. I tried loading the PDF byte[ ] with GdPictureImaging.CreateGdPictureImageFromByteArray(byte [ ]) but this returns 0.
and received this answer:
No there is no other option to load PDF. The GdViewer control can be used in GUIless application. Just create a new GdViewer object like a GdPictureImaging one:

Dim oGdViewer as New GdViewer
I've already tried this, but this doesn't work for me.
I created a new c# project with following steps:
1) New Project -> Windows Service
2) Edit the static void Main() to:

Code: Select all

Service1 service = new Service1();
service.Start();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
3) Add Reference -> GdPicture.NET and System.Windows.Forms (otherwise it doesn't even compile)
4) Add method to Service1

Code: Select all

public void Start()
{
     GdViewer view = new GdPicture.GdViewer();
}
5) Set a breakpoint to this method.

At debugging i get this Exception:

Code: Select all

System.InvalidOperationException was unhandled
  Message="DragDrop registration did not succeed."
  Source="System.Windows.Forms"
  StackTrace:
       at System.Windows.Forms.Control.SetAcceptDrops(Boolean accept)
       at System.Windows.Forms.Control.OnHandleCreated(EventArgs e)
       at System.Windows.Forms.Control.WmCreate(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.UserControl.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.IntCreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
       at System.Windows.Forms.UnsafeNativeMethods.CreateWindowEx(Int32 dwExStyle, String lpszClassName, String lpszWindowName, Int32 style, Int32 x, Int32 y, Int32 width, Int32 height, HandleRef hWndParent, HandleRef hMenu, HandleRef hInst, Object pvParam)
       at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp)
       at System.Windows.Forms.Control.CreateHandle()
       at System.Windows.Forms.Control.get_Handle()
       at GdPicture.GdViewer..ctor()
       at GdPictureTestService.Service1.Start() in D:\Save\Projects\GdPictureTestService\GdPictureTestService\Service1.cs:Zeile 31.
       at GdPictureTestService.Program.Main() in D:\Save\Projects\GdPictureTestService\GdPictureTestService\Program.cs:Zeile 13.
       at System.AppDomain._nExecuteAssembly(Assembly 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.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
I've added the new project i created as attachment.

Thanks in advance!

Regards,
prosigma
Attachments
GdPictureTestService.zip
(15.27 KiB) Downloaded 264 times

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Loading a PDF with Windows Service

Post by Loïc » Wed Jan 27, 2010 10:47 am

Hi,

You are using an old edition of GdPciture.NET. The problem you are talking about have been resolved since few months.

Please, update to the latest release.

With best regards,

Loïc

prosigma
Posts: 8
Joined: Tue Nov 10, 2009 2:26 pm

Re: Loading a PDF with Windows Service

Post by prosigma » Wed Jan 27, 2010 3:37 pm

Thanks!

Regards,
prosigma

Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 1 guest