Load File From Stream

Load File From Stream

Forum member · Feb 23, 2009
We are evaluating the DynamicPDF Viewer to display PDF generated by Crystal Reports. I convert the Crystal Report to a stream and then use the OpenStream to load the PDF in the viewer but nothing shows. If i export the PDF to a file on disk, then load with OpenFile, the report appears fine.

Re: Load File From Stream

Support · Feb 23, 2009
Hello, In order to open a stream you can use the below sample code. stream.Seek(0, SeekOrigin.Begin); byte[] contents = new byte[stream.Length]; stream.Read(contents, 0, contents.Length); stream.Close(); GCHandle gch = GCHandle.Alloc(contents, GCHandleType.Pinned); IntPtr contentsIntPtr = gch.AddrOfPinnedObject(); dynamicPDFViewerControl1.OpenBuffer(contentsIntPtr, contents.Length, ""); Thanks, ceTe Software Support Team.

Re: Load File From Stream

Forum member · Feb 24, 2009
Hi, This works fine. However, if i try to do a compile version of our .NET application. Upon starting the application I get an InteropServices error saying UnsafeNativeMethods at CreateWithoutLicense.

Re: Load File From Stream

Support · Feb 24, 2009
Can you post the exact error message along with the full stack trace? Thanks, ceTe Software Support Team

Re: Load File From Stream

Forum member · Feb 25, 2009
Hi, I will post the stack once i get back to the office, but if I install the DynamicPDF viewer using the .msi on the target machine, then i do not get the error. In the compile, i did set the Copy local to true but it would appear the compile application is not finding the .dll. If they are installed prior to running our software, then i do not get the error.

Re: Load File From Stream

Forum member · Feb 25, 2009
Here is the actual message: Unhandled exception has occured in your application. Unknown error 0x80040200. System.Runtime.InteropServices.COMException(0x80040154): Unknown error 0x80040200 at System.Windows.Forms.UnsafeNativeMethods.CoCreateInstance() at System.Windows.Forms.AxHost.CreateWithoutLicense(Guid,clsid) at System.Windows.Forms.AxHost.CreateWithLicense(String license,Guid clsi) ....

Re: Load File From Stream

Support · Feb 25, 2009
Hello, We have never seen this error message in the past. It looks like you need to register the OCX file on the target machine in order to use the Viewer API. Running the MSI does register the OCX file and thats the reason the error does not occur. Thanks, ceTe Software Support Team

Re: Load File From Stream

Forum member · Mar 1, 2010
I'm not sure if the original poster was using v1.0 or v2.0 but I'm using v2.0 and getting the same results. Is the recommendation the same for v2.0.

Re: Load File From Stream

Support · Mar 2, 2010
Hello, Yes, the above recommendation is same for both v1.0 and v2.0. Please try registering our viewer and see if it solves your problem. Thanks, ceTe Software Support Team.