We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Import byte stream

Thread ID:

Created:

Updated:

Platform:

Replies:

125017 Jul 14,2016 12:46 PM Sep 21,2016 08:26 AM JavaScript 7
loading
Tags: ejPdfViewer
j.nord
Asked On July 14, 2016 12:46 PM

Hello,

It is possible to directly read a byte stream in the PDF viewer?

Regards

j.Nord

Sabari Anand Senthamarai Kannan [Syncfusion]
Replied On July 18, 2016 04:37 AM

Hi Jürgen, 
 
Thanks for your interest in Syncfusion products. 
 
Yes, byte streams can be loaded in to the PDF viewer control to display the PDF document. The code snippet for loading the PDF file as a byte stream in the PDF viewer is given below, 
 
Code snippet: 
PdfViewerHelper helper = new PdfViewerHelper(); 
MemoryStream stream = new MemoryStream(File.ReadAllBytes(Helper.GetFilePath("F# Succinctly.pdf"))); 
helper.Load(stream); 
 
A sample which illustrates loading PDF document using byte stream into PDF viewer is available in the following link. 
 
 
Regards, 
Sabari Anand

j.nord
Replied On July 18, 2016 08:46 AM

Hi Sabari,

the solution can't work. In javascript is not a command "memorystream". And the sample works with a file. We get a base64String or a byteStream from the server (c# Generic handler  .ashx) and would load it in the viewer. But it doesn't work. We have no file.

It is possible to load the base64String or a byteStream from a server (ajax request) into the pdf viewer?

Regards

j.nord

Sabari Anand Senthamarai Kannan [Syncfusion]
Replied On July 19, 2016 09:20 AM

Hi Jürgen, 
 
Sorry for the inconvenience caused. 
 
The code snippet provided in the previous update is to be implemented in PdfViewerController in WebApi(server side). 
 
Yes, it is possible to load base64 string to the PDF Viewer control in the client side. We have created a sample which illustrates the loading of PDF document as base64 string into the PDF Viewer. The sample is available in the following link, 
http://www.syncfusion.com/downloads/support/forum/125017/ze/Sample1345948333 
 
Working with the sample: 
·       When the sample is ran, a web page is displayed with a dropdown list containing document names from the Data folder.  
·       When a value in the dropdown list is selected, the ‘change’ event is triggered. At the change event handler, an AJAX request is fired to the “GetFileStream” action method of PdfViewerController. 
·       At the “GetFileStream” method, the file path is got from the value in the dropdown list. Then the FileStream is created using the file path. The stream is stored in a memory stream. Then it is converted to byte array. From the byte array, the base64 string is created and returned to the client side. 
·       After the success of the AJAX request, the control is initialized and the base64 string is applied to load API of the PdfViewer control.  
  
Please let us know if you have any concerns. 
 
Regards, 
Sabari Anand

j.nord
Replied On July 20, 2016 10:58 AM

Hi Sabari,

so it can't work. We get with the ajax command in the "sucess:" the data.

We then pass the data in the Load command and then we get "a split error". Whether binary or base64.

Why the service is called within the sucess again?
. $ ("# Container") ejPdfViewer ({ServiceUrl: '../api/PdfViewer'});

That's not logical.

Why can not store a Base64 or Binarischen value simply in obj.load(binaryFile or base64 string)?

Regards

j.nord

Sabari Anand Senthamarai Kannan [Syncfusion]
Replied On July 21, 2016 07:50 AM

Hi Jürgen, 
 
Thank you for your update. 
 
We have created a new incident under your account for your queries in your last update. We request you to follow the new incident for further updates. You can log in to our support system using the following link, 
 
 
Regards, 
Sabari Anand

Jainish
Replied On September 20, 2016 04:58 AM

This is very useful post. why this type of functionality you didn't add in your main document ?

Thanks

Sabari Anand Senthamarai Kannan [Syncfusion]
Replied On September 21, 2016 08:26 AM

Hi Jainish, 
 
Thank you for using Syncfusion products. 
 
The various methods to load a PDF document in the PDF Viewer control at the server is available in the following documentation link, 
 
 
Please let us know your requirements in viewing the PDF document using the PDF viewer control. So that it will be helpful for us to fulfill your requirements. 
 
Regards, 
Sabari Anand

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;