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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error en Stream.readout y stram.writeout

Thread ID:





141571 Dec 18,2018 04:02 PM UTC Jan 24,2019 06:44 AM UTC Xamarin.Forms 9
Tags: PDF
Jonathan Estrada Gonzalez
Asked On December 18, 2018 04:02 PM UTC

Hola lo que pasa es que sigo la documentacion de syncfusion y no tenia probleas hasta ahora al tratar de hacer un archivo pdf con su documentacion me sale el erros de stream que el read y write estan null y no puedo avanzar no se por que no se puede si copi los archivos correctamente de la documentacion de pdf xamarin
//Load the file as stream
Stream docStream = typeof(App).GetTypeInfo().Assembly.GetManifestResourceStream("Sample.Assets.Sample.pdf");
PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);
//Create booklet with two sides
PdfDocument document = PdfBookletCreator.CreateBooklet(loadedDocument, new SizeF(1000, 700), true);
MemoryStream memoryStream = new MemoryStream();
//Save the document into memory stream
//close the documents
//Save the stream into pdf file
Xamarin.Forms.DependencyService.Get().Save("sample.pdf", "application/pdf", memoryStream);
public interface ISave
Task Save(string filename, string contentType, MemoryStream stream);
class SaveWindowsPhone: ISave
public async Task Save(string filename, string contentType, MemoryStream stream)
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
StorageFile outFile = await local.CreateFileAsync(filename, CreationCollisionOption.ReplaceExisting);
using (Stream outStream = await outFile.OpenStreamForWriteAsync())
outStream.Write(stream.ToArray(), 0, (int)stream.Length);
await Windows.System.Launcher.LaunchFileAsync(outFile);

Karthikeyan Chandrasekar [Syncfusion]
Replied On December 19, 2018 08:59 AM UTC

Hi Jonathan, 
Greetings from Syncfusion. 
We have tried with the code snippet which you provided from our UG documentation, but it is working fine as expected. We have attached the sample and UG link for your reference. 
Could you please modify the sample to reproduce your issue, so that we could further analyze in it and provide you the exact fix. 

Jonathan Estrada Gonzalez
Replied On December 19, 2018 07:27 PM UTC

Pues ya copie el codigo tal y como esta y me sale un error no se por que sea este es mi codigo de erros 

  Mensaje = Value cannot be null.
  Origen = Syncfusion.Pdf.Portable
  Seguimiento de la pila:
   en Syncfusion.Pdf.Parsing.PdfLoadedDocument..ctor(Stream file)
   en Control.Pages.Catalogos.Archivos.BtnExport_Clicked(Object sender, EventArgs e) en C:\Users\LICONSA\source\repos\Control\Control\Control\Pages\Catalogos\Archivos.xaml.cs: línea 99
   en Xamarin.Forms.MenuItem.OnClicked()
   en Xamarin.Forms.MenuItem.Activate()
   en Xamarin.Forms.Platform.UWP.MenuItemCommand.Execute(Object parameter)
   en System.Runtime.InteropServices.WindowsRuntime.ICommandToWinRTAdapter.Execute(Object parameter)

Karthikeyan Chandrasekar [Syncfusion]
Replied On December 20, 2018 11:34 AM UTC

Hi Jonathan, 
Thank you for your update. 
The stack trace of the exception seems to be steam is null. Could you please confirm that the stream is valid. When we are retrieving the stream from the PDF document , the PDF document build action should be embedded.  
Please refer the screenshot below for your reference. 


Kindly check the sample, which we are provided in the last update. If the issue occurs specific to the document, kindly share the document or  sample which you are checking. It will be helpful for us to provide the solution earlier. 


Jonathan Estrada Gonzalez
Replied On January 21, 2019 06:01 PM UTC

La Aplicacion me Corre perfectamente en UWP pero en android me sale este error al parecer es al abrir el archivo guardado en el telefono 

Karthikeyan Chandrasekar [Syncfusion]
Replied On January 22, 2019 11:48 AM UTC

Hi Jonathan, 

Starting from Android version (8.0, Marshmallow)  every android app need to request runtime permission when the application is deployed for the first time. This might be the cause of the exception  you get while saving the PDF document to the device. 

More detail on how to request runtime permission in Xamarin forms Android can be found in the link below: 

Also the sample for the same has been updated in Xamarin developer website which can be found in below link: 

Please note for saving the PDF in the mobile device “READ_EXTERNAL_STORAGE”  and “WRITE_EXTERNAL_STORAGE” permission needs to be enabled. 

Let us know if you need any further information in this. 


Jonathan Estrada Gonzalez
Replied On January 22, 2019 04:21 PM UTC

De echo los permisos se los di desde que implemente el código de guardar el pdf pero me sigue saliendo lo mismo por eso preguntaba por que los permisos ya fueron asignado aquí les dejo una foto de los permisos y de mi código de android

Y pues estuve investigando y me dice que el android.net.uri ya no es compatible con el api despues de 23 y que tengo que usar un provider en vez de un file
no se que tan cierto sea esto

Karthikeyan Chandrasekar [Syncfusion]
Replied On January 23, 2019 09:55 AM UTC

Hi Jonathan, 
To resolve the permission exception when deploying application in Android Marshmallow and above target, it is need to grant permission for the application to access storage. We have done the changes in MainActivity.cs to grant permission when opening the application. 


Sample can be found in the link below: 

Let us know if you need any further information. 

Jonathan Estrada Gonzalez
Replied On January 23, 2019 03:15 PM UTC

Hola Muchisimas Gracias por estar checando Mi Problema Ya lo solucione el dia de ayer poniendo un Provider con un content en mi codigo pero probare este codigo y vere igual la solucion muchisimas gracias 

Karthikeyan Chandrasekar [Syncfusion]
Replied On January 24, 2019 06:44 AM UTC

Hi Jonathan, 
Happy to know that your issue is resolved. Get back to us if you need any assistance in the future. 



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon