Welcome to the Xamarin.Forms feedback portal. We’re happy you’re here! If you have feedback on how to improve the Xamarin.Forms, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
My Xamarin.Forms application is using Syncfusion v17.4.0.41 and logs debug info to a text file during normal operation. Under user control it can either email that file to a recipient or view it onscreen by first converting to a PDF file and using SfPDFViewer to view it.
I have the application running on a Samsung A40 (Android 9) and it has produced a text file of approx 1Mb. However when I select to view on-screen it never returns from the attempt to create the PDF file, and does not emit any errors or exceptions, even after several minutes.
In the code below the line element.Draw(page, bounds, layoutFormat) never returns.
// We view the log file(s) as a PDF because the Syncfusion pdf viewer seems to be
// the only control which will let us select, copy, search & zoom.
// This method will create a single PDF files from all the specified files, then
// set the associated property so it will be displayed in the PDF viewer
private void CreatePDFFromFilesList(Fileslist filesList)
{
if (filesList == null)
return;
PdfDocument doc = new PdfDocument();
PdfPage page;
PdfGraphics graphics;
PdfTextElement element;
PdfFont headingFont = new PdfStandardFont(PdfFontFamily.Helvetica, 20);
PdfFont detailFont = new PdfStandardFont(PdfFontFamily.Courier, 10);
PdfSolidBrush detailBrush = new PdfSolidBrush(Syncfusion.Drawing.Color.Black);
int filesAdded = 0;
doc.PageSettings.Margins.All = 5;
// Include each file, one per page
foreach (string filename in filesList.Filenames)
{
var fullFilename = Path.Combine(filesList.Filepath, filename);
if (File.Exists(fullFilename))
{
page = doc.Pages.Add();
graphics = page.Graphics;
// Display filename as heading
graphics.DrawString(filename, headingFont, PdfBrushes.Black, new Syncfusion.Drawing.PointF(0, 0));
// Display detail
var fileContent = File.ReadAllText(fullFilename);
element = new PdfTextElement(fileContent);
element.Brush = detailBrush;
element.Font = detailFont;
PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
layoutFormat.Break = PdfLayoutBreakType.FitPage;
layoutFormat.Layout = PdfLayoutType.Paginate;
Syncfusion.Drawing.RectangleF bounds = new Syncfusion.Drawing.RectangleF(new Syncfusion.Drawing.PointF(0, 30), page.Graphics.ClientSize);
element.Draw(page, bounds, layoutFormat);
filesAdded++;
}
};
if (filesAdded > 0)
{
// Save document to memory stream
MemoryStream stream = new MemoryStream(0);
doc.Save(stream);
doc.Close(true);
// Load stream into property used by PdfViewer
stream.Position = 0;
PdfDocumentStream = stream;
}
}
This has previously been working fine and the code has not changed, thought the Samsung device (and also Android 9) is a relatively new addition to our development and test environment
I have attached the text file in question (though I have had to rename it from .log to .txt to get around your attachment restrictions) in case there is something about the content or size causing this.
Thanks
Paul