Load File From Stream

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Viewer (v1)  /  Load File From Stream

DynamicPDF Viewer (v1) Forum

 Feb 23 2009 9:08 AM
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.
 Feb 23 2009 11:06 AM
Posted by a ceTe Software moderator
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.
 Feb 24 2009 3:28 PM
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.
 Feb 24 2009 6:17 PM
Posted by a ceTe Software moderator
Can you post the exact error message along with the full stack trace? 

Thanks,
ceTe Software Support Team
 Feb 25 2009 9:59 AM
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.
 Feb 25 2009 1:53 PM
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)
....
 Feb 25 2009 2:36 PM
Posted by a ceTe Software moderator
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
 Mar 01 2010 6:39 PM
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.
 Mar 02 2010 5:13 AM
Posted by a ceTe Software moderator
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.

All times are US Eastern Standard time. The time now is 8:51 PM.