Given the folowing: FlLayPanel with PdfViewer control (one and only ;-)
ToonDocument(@"D:\marce\Downloads\vw.pdf", null);
ToonDocument(@"D:\marce\Downloads\pr.pdf", null);
Is no problem, both PdfViewer are showing correctly.
But with two streams, the is showing correctly, the second is showing a waitcycle (see attachment).
using (FileStream s = new FileStream(@"D:\marce\Downloads\vw.pdf", FileMode.Open, FileAccess.Read))
{
MemoryStream ms = new MemoryStream();
s.CopyTo(ms);
ToonDocument(string.Empty, ms);
}
using (FileStream s = new FileStream(@"D:\marce\Downloads\pr.pdf", FileMode.Open, FileAccess.Read))
{
MemoryStream ms = new MemoryStream();
s.CopyTo(ms);
ToonDocument(string.Empty, ms);
}
The sub to create the panel:
public void ToonDocument(string documentnaam, MemoryStream stream = null)
{
UiDocPanel uiDocPanel = new UiDocPanel();
if (documentnaam != string.Empty)
uiDocPanel.LoadDoc(documentnaam);
else
uiDocPanel.LoadDoc(stream);
dcmMain.SetDockLabel(uiDocPanel.FlLayPanel, "Document");
dcmMain.SetEnableDocking(uiDocPanel.FlLayPanel, true);
}
And the class UiDocPanel
using Syncfusion.Windows.Forms.PdfViewer;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace va.WinUI
{
class UiDocPanel : UiPanel
{
private PdfViewerControl pdfView = new PdfViewerControl();
public UiDocPanel() : base("Document")
{
InitControls();
}
public void LoadDoc(MemoryStream stream)
{
pdfView.Load(stream);
}
public void LoadDoc(String bestandsnaam)
{
pdfView.Load(bestandsnaam);
}
private void InitControls()
{
pdfView.Location = new System.Drawing.Point(6, 3);
pdfView.Size = new System.Drawing.Size(963, 445);
FlLayPanel.Resize += new System.EventHandler(Doc_Resize);
FlLayPanel.Controls.Add(pdfView);
}
private void Doc_Resize(object sender, EventArgs e)
{
pdfView.Width = FlLayPanel.Width - 8;
pdfView.Height = FlLayPanel.Height -10;
}
}
}
And the class UiPanel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace va.WinUI
{
class UiPanel
{
private FlowLayoutPanel panel = new FlowLayoutPanel();
private string iBaseName = "Panel";
public string Basename
{
get
{
return iBaseName;
}
set
{
iBaseName = value;
}
}
public FlowLayoutPanel FlLayPanel
{
get
{
return panel ?? null;
}
}
public UiPanel(string bname)
{
Basename = bname;
// panel
panel.BorderStyle = BorderStyle.Fixed3D;
panel.Location = new System.Drawing.Point(1, 1);
panel.Name = "pan" + Basename;
panel.Size = new System.Drawing.Size(627, 161);
panel.TabIndex = 2;
}
}
}
See attachment:
Attachment:
PDFViewer_4da0c66.zip