"Unable to read beyond the end of the stream" error C1PrintDocument export PDF

Posted by: andrea.davoli on 15 May 2026, 9:20 am EST

  • Posted 15 May 2026, 9:20 am EST

    Hello,

    Some users are recently reporting that they are having issues while saving reports generated through C1PrintDocument in PDF format.

    The error is “Unable to read beyond the end of the stream”, and at the moment it has been reported from users with Windows running with French or Hebrew settings, and this issue started to happen recently without any update of the code or dlls involved at our end.

    This issue is not happening from our tests in different systems and folders, however the problem is being reported from different users but we are not able to test it directly.

    The .dll version (C1Document, C1PrintPreview and other dlls) is currently 4.8.2024.1.672 and we never encountered this issue before.

    The code involved is:

    Dim exPdf As C1.C1Preview.Export.PdfExporter  = C1.C1Preview.Export.ExportProviders.PdfExportProvider.NewExporter
    exPdf.Document = PrintDocument
    exPdf.ShowOptions = False
    exPdf.Export(pathExportPDF)

    This procedure is called after the report is already generated and correctly visualized.

    We also tried to add this code in case of error to test within those users, but it does not work:

     Using ms As New MemoryStream()
         exPdf.Export(ms)
         ms.Position = 0
         Using fs As New FileStream(pathExportPDF, FileMode.Create, FileAccess.Write)
             ms.CopyTo(fs)
         End Using
     End Using

    We did check with this users their permissions as well as folder selected, but this seems not to be a problem because they are able to save other file in those foldrs and also to export the same report as xls without issues (using C1.C1Preview.Export.XlsExporter).

    Also, with one user we were able to click on “Print” button on the C1PrintPreview and to print as pdf without issues, however clicking on “Save” and trying to save as pdf always gave the same error.

    Can you provide assistance with this issue? Are there any suggestion or alternatives to save as pdf?

    Thanks!

  • Posted 18 May 2026, 2:39 am EST

    Hi Andrea,

    Unfortunately, we were unable to reproduce the mentioned behavior on our end. We tested the different approaches you described for exporting to PDF, and they all worked as expected on our end in both the French and Hebrew culture settings.

    Here are a few suggestions that you could try to debug the cause:

    1. Since this problem began without any changes to your code or DLLs, and is restricted to specific cultures, it is possible that a recent Windows update might have modified localized regional settings. Please check the exact Windows OS version from the affected machines to see if they share a common update.

    2. Font mapping differences in specific locales or using any specific fonts can cause unexpected stream reading issues during PDF export. You can try explicitly disabling font embedding before calling the export method:

    exPdf.EmbedTrueTypeFonts = False
    1. Try temporarily forcing the executing thread to use the invariant culture right before the PDF export process:
    Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture
    Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture
    1. Since you are currently using an older version (4.8.20241.672), we suggest to test this behavior in the latest version (4.8.20252.761) and see if this resolves the issue.

    While you try the debugging suggestions mentioned above, you can use the Print() API of C1PrintDocument as an alternative to generate the PDF via “Microsoft Print to PDF”. We have added the implementation for this approach within the attached sample project - PrinDocSamplePrj.zip

    Best Regards,

    Kartik

  • Posted 22 May 2026, 1:59 am EST

    Hi Andrea and Kartik,

    We too have had the issue reported by nearly 20 customers for our commercial app without any changes to our code. I have done a little digging and although this has NOT corrected the problem at every site, the removal of Windows Update KB5089549 that was released mid May has solved the problem for some.

    Kind Regards

    Pete Lowe

  • Posted 22 May 2026, 7:31 am EST

    Hello Kartik and Peter,

    Thank you both for your answers.

    It seems that we were able to find out that the issue, at least for two customers, was related to the Font. I believe that this could be connected to some Windows Updates since the issue did not happen before.

    The Report was also correctly displaying in the C1Preview, the problem did only happen during the PDF conversion.

    Changing the selected font seems to have fixed the issue. We did not suggested to remove the Windows Update Peter mentioned, but that could be causing the issue with the Windows Fonts.

    We will continue monitoring this issue and try the suggestions provided by Kartik (EmbedTrueTypeFonts).

    Thanks!

    Kind Regards

  • Posted 31 May 2026, 9:20 pm EST

    Hello Andrea and Kartik,

    We have found a solution to this mystery problem; at least for us . For us, the error is being thrown on Windows 11 pc’s and not on Windows 10 Pc’s. It’s related to a tab character being in the data that our report routine is processing. Why this has suddenly thrown an error now, we don’t know, but adding a routine that replaces tabs with the equivalent number of spaces (and cleans other control characters that may end up in the data) has solved the issue for us.

    Regards

    Peter

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels