Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page Break.

Added a New Object (ReaderHelper) which provides the necessary support to allow MSWord documents to use various page sizes.  MSWord has a limit of 22 inches for the largest width or height.
Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page break.
Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page break.
Updated vlnParagraph constructors to use parameter MyPromsPrinter since it is used to create page breaks.
This commit is contained in:
Rich
2015-03-26 02:21:52 +00:00
parent 5d2b0bc1b0
commit 2d6f5f443e
3 changed files with 312 additions and 72 deletions

View File

@@ -299,7 +299,7 @@ namespace Volian.Print.Library
box = null;
yoff += 1 * vlnPrintObject.SixLinesPerInch;
}
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight,true,null);
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight,true, pp);
// if doing the component list (FNP), keep track of the bottom most columns' data
// so this can be returned after the row is done.
@@ -1171,17 +1171,19 @@ namespace Volian.Print.Library
bool doThreeContinues = false;
// For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were
// at the wrong level. Reset the page helper's section.
if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse)
if (MyItemInfo.IsStepSection)
{
// if parent was continuous & this is separate, don't reset document style to subsection (next page) type
// this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments.
if ((MyParent.MyItemInfo as SectionInfo).IsSeparatePagination() || !(MyItemInfo as SectionInfo).IsSeparatePagination())
if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse)
{
MyPageHelper.MySection = MyItemInfo as SectionInfo;
MyPageHelper.ResetSvg();
// if parent was continuous & this is separate, don't reset document style to subsection (next page) type
// this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments.
if ((MyParent.MyItemInfo as SectionInfo).IsSeparatePagination() || !(MyItemInfo as SectionInfo).IsSeparatePagination())
{
MyPageHelper.MySection = MyItemInfo as SectionInfo;
MyPageHelper.ResetSvg();
}
}
}
// For Calvert Alarms: A macro exists around the CONDITION/RESPONSE portion. If the page break occurs so that
// this 'table' moved to the following page AND there is an associated note/caution that is not on the next page,
// remove the macro so that the header macro doesn't print on the page with the note (without this, an extraneous
@@ -1197,17 +1199,15 @@ namespace Volian.Print.Library
}
if (IsWordDocPara)
{
PdfReader tmp = null;
string tmpstr = null;
SectionInfo si = SectionInfo.Get(MyItemInfo.ItemID);
//Changing this caused Header issues for FNP FNP-1-FRP-1.3 Attachment 3 (Word Sub-Sections)
//SectionInfo si1 = MyItemInfo.GetSectionInfo();
//CompareSectionInfo(si, si1);
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage(true);
//_MyLog.InfoFormat("NewPage 9 {0}", cb.PdfWriter.CurrentPageNumber);
// Add Bookmark for Word Subsections
MyPageHelper.PageBookmarks.Add(si, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si, ref tmp, ref tmpstr);
MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si);
Processed = true;
{
ProfileTimer.Pop(profileDepth);
@@ -1268,7 +1268,7 @@ namespace Volian.Print.Library
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
bool doSectionContinue = !MyItemInfo.IsSection && ((docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue);
if (doSectionContinue) DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, false);
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
//_MyLog.InfoFormat("NewPage 10 {0}", cb.PdfWriter.CurrentPageNumber);
if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination())
{
@@ -1291,7 +1291,7 @@ namespace Volian.Print.Library
}
// Only do foldout page if not done for section break, i.e. check the there's a previous step.
if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1)
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
MyPromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
{
// insert a blank page if this step section had a foldout associated and the checkbox
@@ -1301,7 +1301,7 @@ namespace Volian.Print.Library
{
MyPageHelper.OnBlankPage = true;
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
//_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber);
}
}
@@ -1364,7 +1364,7 @@ namespace Volian.Print.Library
}
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, doThreeContinues);
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
if (MyItemInfo.IsStep && ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
{
// check if parent (can be HLS, Caution or Note) has the UseOldTemplate. If so,
@@ -1386,12 +1386,12 @@ namespace Volian.Print.Library
DebugText.WriteLine("Paginate2");
if (MyItemInfo.MyHLS.FoldoutIndex() > -1)
PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout
MyPromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
{
MyPageHelper.OnBlankPage = true;
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
_MyLog.InfoFormat("NewPage Break within step blank {0}", cb.PdfWriter.CurrentPageNumber);
}
@@ -1477,7 +1477,7 @@ namespace Volian.Print.Library
if (MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate)
{
DoSubs = false;
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0,false,null);
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0,false, MyPromsPrinter);
smartPara.PrintHeader = true;
float mytmpfloat = smartPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
yPageStart -= smartPara.Height;
@@ -1498,7 +1498,7 @@ namespace Volian.Print.Library
{
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
cb.PdfDocument.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection)
MyPromsPrinter.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection)
//_MyLog.InfoFormat("NewPage 12 {0}", cb.PdfWriter.CurrentPageNumber);
//Console.WriteLine("'b3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset);
ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
@@ -1510,14 +1510,14 @@ namespace Volian.Print.Library
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
}
if (MyItemInfo.FoldoutIndex() > -1)
PromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
MyPromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
{
// insert a blank page if this step section had a foldout associated and the checkbox
// on the print dialog, to add blank pages, is checked
MyPageHelper.OnBlankPage = true;
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
//_MyLog.InfoFormat("NewPage 12 lpi blank {0}", cb.PdfWriter.CurrentPageNumber);
}
if (MyItemInfo.MyDocStyle.LandscapePageList)
@@ -1573,7 +1573,7 @@ namespace Volian.Print.Library
// get to the correct section for the message, i.e. if on a section, the message should be the parent
// section (not the activesection which is myself); if on a step, the message should be the active section
ItemInfo sectForCont = MyItemInfo.IsSection && MyItemInfo.MyParent.IsSection ? MyItemInfo.MyParent : MyItemInfo.ActiveSection;
sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,null);
sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,MyPromsPrinter);
if (sectContPara.PartsLeft.Count > 0)
{
vlnTab vt = sectContPara.MyTab;
@@ -1600,7 +1600,7 @@ namespace Volian.Print.Library
}
else
{
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,null);
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter);
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
if (sectContPara.SectionContinuePrinted)
yPageStart -= sectContPara.Height + SixLinesPerInch;
@@ -1616,7 +1616,7 @@ namespace Volian.Print.Library
yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
// Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before
// a HLS. One example of this use is for backgrounds (CALBCK).
// a HLS. One example of this use is for backgrounds (CALBCK).
// 'this' below is a highlevel step, and the only time that ParaBreaks[0] will == 'this' is
// when the PageBreakOnStep flag is true.
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 &&
@@ -1626,7 +1626,7 @@ namespace Volian.Print.Library
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
MyPageHelper.BottomMessage = null;
MyPageHelper.TopMessage = null;
cb.PdfDocument.NewPage();
MyPromsPrinter.NewPage();
if (CompressPartOfStep)
{
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
@@ -1778,7 +1778,7 @@ namespace Volian.Print.Library
}
if (!inlist)
{
vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, null);
vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, MyPromsPrinter);
vpFNote.Width = (float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin;
vpFNote.Height = 0;
vpFNote.XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin;
@@ -2395,8 +2395,15 @@ namespace Volian.Print.Library
return (float)(MyItemInfo.MyDocStyle.Layout.PageLength /*- MyItemInfo.MyDocStyle.Layout.TopMargin*/ - MyItemInfo.MyDocStyle.Layout.FooterLength);
}
}
private PromsPrinter _MyPromsPrinter;
public PromsPrinter MyPromsPrinter
{
get { return _MyPromsPrinter; }
set { _MyPromsPrinter = value; }
}
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp)
{
MyPromsPrinter = pp ?? parent.MyPromsPrinter;
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph");
Prefix = prefix;
Suffix = suffix;