This commit is contained in:
Kathy Ruffing 2011-01-19 16:24:32 +00:00
parent fcf38d2bec
commit ea0d4749e2

View File

@ -84,6 +84,10 @@ namespace Volian.Print.Library
} }
public class PromsPrinter public class PromsPrinter
{ {
// the following boolean is to help testing of various formats. If the plant has an alternating foldout
// and you want a blank page, until foldouts are developed, set to true.
// AEP DU1 - do a blank page for foldout
private bool _DoBlankForFoldout = false;
public event PromsPrinterStatusEvent StatusChanged; public event PromsPrinterStatusEvent StatusChanged;
private void OnStatusChanged(object sender, PromsPrintStatusArgs args) private void OnStatusChanged(object sender, PromsPrintStatusArgs args)
{ {
@ -308,36 +312,44 @@ namespace Volian.Print.Library
else else
{ {
myPdfFile = BuildMSWordPDF(mySection); myPdfFile = BuildMSWordPDF(mySection);
readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null; try
OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection);
if (mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length !=0) //.SectionConfig.Section_NumPages != "")
{ {
int sectPageCount = (int)(Math.Ceiling(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length)); //decimal.Parse(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length))); readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null;
for (int ii = 0; ii < sectPageCount; ii++) OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection);
if (mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length != 0) //.SectionConfig.Section_NumPages != "")
{ {
int pageNumber = 1 + ii; int sectPageCount = (int)(Math.Ceiling(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length)); //decimal.Parse(mySection.MyContent.MyEntry.MyDocument.DocumentConfig.Printing_Length)));
if (readerWord != null) for (int ii = 0; ii < sectPageCount; ii++)
{ {
bool doimport2 = true; int pageNumber = 1 + ii;
PdfImportedPage fgPage = null; if (readerWord != null)
try
{ {
fgPage = cb.PdfWriter.GetImportedPage(readerWord, ii + 1); bool doimport2 = true;
PdfImportedPage fgPage = null;
try
{
fgPage = cb.PdfWriter.GetImportedPage(readerWord, ii + 1);
}
catch (Exception ex)
{
Console.WriteLine(ex);
doimport2 = false;
}
OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord);
if (doimport2) AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, 0);
OnStatusChanged("Merge MSWord", PromsPrinterStatusType.MergeMSWord);
} }
catch (Exception ex) OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
{ cb.PdfDocument.NewPage();
Console.WriteLine(ex); OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
doimport2 = false;
}
OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord);
if (doimport2) AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, 0);
OnStatusChanged("Merge MSWord", PromsPrinterStatusType.MergeMSWord);
} }
OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
cb.PdfDocument.NewPage();
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
} }
} }
catch (Exception ex)
{
cb.PdfDocument.NewPage(); // can we put out 'error on page'?
}
} }
} }
if (_MyHelper.BackgroundFile != null) if (_MyHelper.BackgroundFile != null)
@ -390,6 +402,11 @@ namespace Volian.Print.Library
myParagraph.ToPdf(cb, yTopMargin, yTopMargin, yBottomMargin); myParagraph.ToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
else else
PrintTextMessage(cb, "No Section Content"); PrintTextMessage(cb, "No Section Content");
if (_DoBlankForFoldout && section.IsDefaultSection)
{
cb.PdfDocument.NewPage();
cb.Circle(400, 100, 50);
}
cb.PdfDocument.NewPage(); cb.PdfDocument.NewPage();
OnStatusChanged("StepSection converted to PDF " + section.ShortPath, PromsPrinterStatusType.BuildStep); OnStatusChanged("StepSection converted to PDF " + section.ShortPath, PromsPrinterStatusType.BuildStep);
} }