public void LoadBook(BackgroundWorker worker, DoWorkEventArgs doWorkEventArgs)
{
_currentlyLoadedBook = BookSelection.CurrentSelection;
try
{
// In case we have any new settings since the last time we were in the Edit tab (BL-3881)
_currentlyLoadedBook.BringBookUpToDate(new NullProgress());
using(var tempHtml = MakeFinalHtmlForPdfMaker())
{
if (doWorkEventArgs.Cancel)
return;
BookletLayoutMethod layoutMethod;
if (this.BookletPortion == BookletPortions.AllPagesNoBooklet)
layoutMethod = BookletLayoutMethod.NoBooklet;
else
layoutMethod = BookSelection.CurrentSelection.GetDefaultBookletLayout();
// Check memory for the benefit of developers. The user won't see anything.
SIL.Windows.Forms.Reporting.MemoryManagement.CheckMemory(true, "about to create PDF file", false);
_pdfMaker.MakePdf(tempHtml.Key, PdfFilePath, PageLayout.SizeAndOrientation.PageSizeName,
PageLayout.SizeAndOrientation.IsLandScape, _currentlyLoadedBook.UserPrefs.ReducePdfMemoryUse,
LayoutPagesForRightToLeft, layoutMethod, BookletPortion, worker, doWorkEventArgs, View);
// Warn the user if we're starting to use too much memory.
SIL.Windows.Forms.Reporting.MemoryManagement.CheckMemory(false, "finished creating PDF file", true);
}
}
catch (Exception e)
{
//we can't safely do any ui-related work from this thread, like putting up a dialog
doWorkEventArgs.Result = e;
// SIL.Reporting.ErrorReport.NotifyUserOfProblem(e, "There was a problem creating a PDF from this book.");
// SetDisplayMode(DisplayModes.WaitForUserToChooseSomething);
// return;
}
}