I'm trying to print using built-in Print command from sfReportViewer, but on print preview page images doesn't show up.
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
writer.Format = BarcodeFormat.DATA_MATRIX;
writer.Options = new DatamatrixEncodingOptions
{
SymbolShape = ZXing.Datamatrix.Encoder.SymbolShapeHint.FORCE_SQUARE,
Height = 64,
Width = 64,
MaxSize = new Dimension(64, 64),
MinSize = new Dimension(32, 32),
GS1Format = true
};
Assembly assembly = typeof(MainPage).GetTypeInfo().Assembly;
Stream reportStream = assembly.GetManifestResourceStream("TrackAndTrace.Report3.rdlc");
sfReport.ProcessingMode = Syncfusion.UI.Xaml.Reports.ProcessingMode.Local;
sfReport.ExportMode = Syncfusion.UI.Xaml.Reports.ExportMode.Local;
//sfReport.PaperOrientation = PaperOrientation.Landscape;
sfReport.LoadReport(reportStream);
ViewModel = new IzvozPodatakaViewModel(App.ViewModel.OdabraniPlan);
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
AppViewModel.UcitavaSe = true;
});
await ViewModel.UcitajPlanPakovanja();
List<Task<string>> tasks = new List<Task<string>>();
foreach (var j in ViewModel.Jedinacne)
{
j.Code = await GetDMCode(j.SerijskiBroj.Replace("(", "").Replace(")", ""));
}
Task task = Task.Run(()=>App.SbRepository.UpdateJedinacneAsync(ViewModel.Jedinacne));
await task.ContinueWith(async t1 =>
{
if (t1.Status == TaskStatus.RanToCompletion)
{
await sfReport.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
sfReport.DataSources.Clear();
sfReport.DataSources.Add(new ReportDataSource("DataSet1", ViewModel.Jedinacne));
sfReport.RefreshReport();
});
}
});
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
{
AppViewModel.UcitavaSe = false;
});
}
private async Task<byte[]> GetDMCode(string serBroj)
{
WriteableBitmap bitmap = writer.Write(serBroj);
byte[] bytes;
using (InMemoryRandomAccessStream ms = new InMemoryRandomAccessStream())
{
BitmapEncoder bitmapEncoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, ms);
bitmapEncoder.SetSoftwareBitmap(SoftwareBitmap.CreateCopyFromBuffer(
bitmap.PixelBuffer, BitmapPixelFormat.Bgra8, bitmap.PixelWidth, bitmap.PixelHeight));
await bitmapEncoder.FlushAsync();
bitmap = null;
bytes = new byte[ms.Size];
await ms.AsStream().ReadAsync(bytes, 0, bytes.Length);
}
return bytes;
}
Exports work properly and images are shown without problem.