B2017-091The Checkbox for inserting blank pages for duplex printing was shortened so that it does not run into the Cancel button. It now reads “Add Blank Pages For Duplex Printing”. Also when print a procedure that has facing pages this check box is checked by default.
B2017-090 Commented out a line of code that is no longer needed for printing facing pages, but was causing the main procedure to paginate incorrectly. Sped up the logic that calculates how small to shrink the font size on the supplemental information facing page.
This commit is contained in:
parent
2055fa863e
commit
68aa1e9aab
@ -1151,9 +1151,9 @@ namespace VEPROMS
|
|||||||
this.cbxBlankPgsForDuplex.Location = new System.Drawing.Point(138, 340);
|
this.cbxBlankPgsForDuplex.Location = new System.Drawing.Point(138, 340);
|
||||||
this.cbxBlankPgsForDuplex.Margin = new System.Windows.Forms.Padding(2);
|
this.cbxBlankPgsForDuplex.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.cbxBlankPgsForDuplex.Name = "cbxBlankPgsForDuplex";
|
this.cbxBlankPgsForDuplex.Name = "cbxBlankPgsForDuplex";
|
||||||
this.cbxBlankPgsForDuplex.Size = new System.Drawing.Size(323, 19);
|
this.cbxBlankPgsForDuplex.Size = new System.Drawing.Size(262, 19);
|
||||||
this.cbxBlankPgsForDuplex.TabIndex = 101;
|
this.cbxBlankPgsForDuplex.TabIndex = 101;
|
||||||
this.cbxBlankPgsForDuplex.Text = "Add Blank Pages For Duplex Foldouts or SAMG Facing Pages";
|
this.cbxBlankPgsForDuplex.Text = "Add Blank Pages For Duplex Printing\r\n";
|
||||||
this.cbxBlankPgsForDuplex.UseVisualStyleBackColor = false;
|
this.cbxBlankPgsForDuplex.UseVisualStyleBackColor = false;
|
||||||
//
|
//
|
||||||
// cbxGeneratePlacekeeper
|
// cbxGeneratePlacekeeper
|
||||||
@ -1196,7 +1196,7 @@ namespace VEPROMS
|
|||||||
this.cbxRemoveManualPageBreaks.Location = new System.Drawing.Point(138, 306);
|
this.cbxRemoveManualPageBreaks.Location = new System.Drawing.Point(138, 306);
|
||||||
this.cbxRemoveManualPageBreaks.Margin = new System.Windows.Forms.Padding(2);
|
this.cbxRemoveManualPageBreaks.Margin = new System.Windows.Forms.Padding(2);
|
||||||
this.cbxRemoveManualPageBreaks.Name = "cbxRemoveManualPageBreaks";
|
this.cbxRemoveManualPageBreaks.Name = "cbxRemoveManualPageBreaks";
|
||||||
this.cbxRemoveManualPageBreaks.Size = new System.Drawing.Size(91, 19);
|
this.cbxRemoveManualPageBreaks.Size = new System.Drawing.Size(370, 19);
|
||||||
this.cbxRemoveManualPageBreaks.TabIndex = 101;
|
this.cbxRemoveManualPageBreaks.TabIndex = 101;
|
||||||
this.cbxRemoveManualPageBreaks.Text = "Remove Trailing Hard Returns && Manual Page Breaks";
|
this.cbxRemoveManualPageBreaks.Text = "Remove Trailing Hard Returns && Manual Page Breaks";
|
||||||
this.cbxRemoveManualPageBreaks.UseVisualStyleBackColor = false;
|
this.cbxRemoveManualPageBreaks.UseVisualStyleBackColor = false;
|
||||||
@ -1336,4 +1336,4 @@ namespace VEPROMS
|
|||||||
private DevComponents.DotNetBar.ButtonX btnPdfLocation;
|
private DevComponents.DotNetBar.ButtonX btnPdfLocation;
|
||||||
private System.Windows.Forms.CheckBox cbxGenerateConActSum;
|
private System.Windows.Forms.CheckBox cbxGenerateConActSum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace VEPROMS
|
|||||||
_AllProcedures = true;
|
_AllProcedures = true;
|
||||||
_DocVersionConfig = dvi.DocVersionConfig;
|
_DocVersionConfig = dvi.DocVersionConfig;
|
||||||
_DocVersionInfo = dvi;
|
_DocVersionInfo = dvi;
|
||||||
_MyProcedure = dvi.Procedures[0].MyProcedure;
|
MyProcedure = dvi.Procedures[0].MyProcedure;
|
||||||
btnCreatePDF.Text = "Create PDFs";
|
btnCreatePDF.Text = "Create PDFs";
|
||||||
HandleDocVersionSettings();
|
HandleDocVersionSettings();
|
||||||
PrepForAllOrOne(false);
|
PrepForAllOrOne(false);
|
||||||
@ -141,13 +141,13 @@ namespace VEPROMS
|
|||||||
_AllProcedures = true;
|
_AllProcedures = true;
|
||||||
_DocVersionConfig = dvi.DocVersionConfig;
|
_DocVersionConfig = dvi.DocVersionConfig;
|
||||||
_DocVersionInfo = dvi;
|
_DocVersionInfo = dvi;
|
||||||
_MyProcedure = dvi.Procedures[0].MyProcedure;
|
cbxBlankPgsForDuplex.Checked = dvi.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
||||||
|
MyProcedure = dvi.Procedures[0].MyProcedure;
|
||||||
btnCreatePDF.Text = "Create PDFs";
|
btnCreatePDF.Text = "Create PDFs";
|
||||||
HandleDocVersionSettings();
|
HandleDocVersionSettings();
|
||||||
PrepForAllOrOne(false);
|
PrepForAllOrOne(false);
|
||||||
// don't open all PDFs if doing All Procedures
|
// don't open all PDFs if doing All Procedures
|
||||||
//cbxOpenAfterCreate2.Checked = dvi.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
//cbxOpenAfterCreate2.Checked = dvi.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
||||||
cbxBlankPgsForDuplex.Checked = dvi.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
|
||||||
}
|
}
|
||||||
private void PrepForAllOrOne(bool oneProcedure)
|
private void PrepForAllOrOne(bool oneProcedure)
|
||||||
{
|
{
|
||||||
@ -182,12 +182,12 @@ namespace VEPROMS
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_AllProcedures = false;
|
_AllProcedures = false;
|
||||||
_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
|
_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
|
||||||
_MyProcedure = pi;
|
cbxBlankPgsForDuplex.Checked = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
||||||
|
MyProcedure = pi;
|
||||||
btnCreatePDF.Text = "Create PDF";
|
btnCreatePDF.Text = "Create PDF";
|
||||||
HandleDocVersionSettings();
|
HandleDocVersionSettings();
|
||||||
PrepForAllOrOne(true);
|
PrepForAllOrOne(true);
|
||||||
cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
||||||
cbxBlankPgsForDuplex.Checked = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
|
||||||
}
|
}
|
||||||
public DlgPrintProcedure(ProcedureInfo pi, bool automatic) // RHM20150506 Multiline ItemID TextBox
|
public DlgPrintProcedure(ProcedureInfo pi, bool automatic) // RHM20150506 Multiline ItemID TextBox
|
||||||
{
|
{
|
||||||
@ -196,12 +196,12 @@ namespace VEPROMS
|
|||||||
Rtf2iTextSharp.DoingComparison = cbxDebug.Checked;
|
Rtf2iTextSharp.DoingComparison = cbxDebug.Checked;
|
||||||
_AllProcedures = false;
|
_AllProcedures = false;
|
||||||
_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
|
_DocVersionConfig = pi.MyDocVersion.DocVersionConfig;
|
||||||
_MyProcedure = pi;
|
cbxBlankPgsForDuplex.Checked = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
||||||
|
MyProcedure = pi;
|
||||||
btnCreatePDF.Text = "Create PDF";
|
btnCreatePDF.Text = "Create PDF";
|
||||||
HandleDocVersionSettings();
|
HandleDocVersionSettings();
|
||||||
PrepForAllOrOne(true);
|
PrepForAllOrOne(true);
|
||||||
cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
cbxOpenAfterCreate2.Checked = pi.MyDocVersion.DocVersionConfig.Print_AlwaysViewPDFAfterCreate;
|
||||||
cbxBlankPgsForDuplex.Checked = pi.MyDocVersion.DocVersionConfig.Print_AddBlankPagesWhenUsingDuplexFoldouts;
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// RHM 20120925 Added so that the dialog would center over the PROMS window
|
/// RHM 20120925 Added so that the dialog would center over the PROMS window
|
||||||
@ -526,7 +526,13 @@ namespace VEPROMS
|
|||||||
public ProcedureInfo MyProcedure
|
public ProcedureInfo MyProcedure
|
||||||
{
|
{
|
||||||
get { return _MyProcedure; }
|
get { return _MyProcedure; }
|
||||||
set { _MyProcedure = value; }
|
set
|
||||||
|
{
|
||||||
|
_MyProcedure = value;
|
||||||
|
// if procedure has supplemental information, the automatially check the add blank pages for duplex printing
|
||||||
|
if (_MyProcedure.ProcHasSupInfoData)
|
||||||
|
cbxBlankPgsForDuplex.Checked = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private int _SelectedSlave = 0;
|
private int _SelectedSlave = 0;
|
||||||
public int SelectedSlave
|
public int SelectedSlave
|
||||||
|
@ -99,7 +99,7 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
else if (MyItemInfo.MyDocStyle.SupplementalInformation && MyItemInfo.IsStep)
|
else if (MyItemInfo.MyDocStyle.SupplementalInformation && MyItemInfo.IsStep)
|
||||||
{
|
{
|
||||||
if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) return 1;
|
//if (MyItemInfo.IsHigh && MyItemInfo.MyPrevious == null) return 1; // appears we don't need this line any more Forced Pagination on OR substep Ginna SAG-8 Step 1 jsj/RHM 05-19-2017
|
||||||
StepConfig sci = MyItemInfo.MyConfig as StepConfig;
|
StepConfig sci = MyItemInfo.MyConfig as StepConfig;
|
||||||
if (sci.Step_PreferredPagebreak)
|
if (sci.Step_PreferredPagebreak)
|
||||||
{
|
{
|
||||||
|
@ -1735,9 +1735,7 @@ namespace Volian.Print.Library
|
|||||||
myPageHealper.ChangeBarDefinition = MyChangeBarDefinition;
|
myPageHealper.ChangeBarDefinition = MyChangeBarDefinition;
|
||||||
float yPageStart = yTopMargin;
|
float yPageStart = yTopMargin;
|
||||||
vlnParagraph._yPageStartForSupInfo = yTopMargin;
|
vlnParagraph._yPageStartForSupInfo = yTopMargin;
|
||||||
FindSupInfoLengths(vlnParagraph); // creates a dictionary of the sup info paragraph heights
|
SupInfoAjustGroupings(vlnParagraph,cb);
|
||||||
_AdjustForParagraphShrinkage = new Dictionary<float, float>();
|
|
||||||
AdjustSupInfoFontSize(vlnParagraph,cb); // try to shrink the sup info page font to fix on the page
|
|
||||||
vlnParagraph.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
|
vlnParagraph.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1753,40 +1751,208 @@ namespace Volian.Print.Library
|
|||||||
MyReaderHelper = savMyReaderHelper;
|
MyReaderHelper = savMyReaderHelper;
|
||||||
}
|
}
|
||||||
#region ShrinkSupInfoGroupAtATime
|
#region ShrinkSupInfoGroupAtATime
|
||||||
|
private Dictionary<float, float> _AdjustForParagraphShrinkage;
|
||||||
/*
|
private float _LastOffset;
|
||||||
* Find Groups
|
private float _LastBottom;
|
||||||
* Foreach group
|
/// <summary>
|
||||||
* while measure group is greater than page length
|
/// Adjust the font size so that the Supplemental Information will fit on a single page.
|
||||||
* reduce the size for the group
|
/// </summary>
|
||||||
*/
|
/// <param name="vlnParagraph">supinfo paragraphs</param>
|
||||||
private float _Decrement = 2f;
|
/// <param name="cb">pdfcontentbyte</param>
|
||||||
private void SupInfoAjustGroupings(vlnParagraph vlnParagraph)
|
private void SupInfoAjustGroupings(vlnParagraph vlnParagraph, PdfContentByte cb)
|
||||||
{
|
{
|
||||||
|
// Get groups of SupInfo paragraphs
|
||||||
List<List<vlnParagraph>> supInfoGroups = FindSupInfoGroups(vlnParagraph);
|
List<List<vlnParagraph>> supInfoGroups = FindSupInfoGroups(vlnParagraph);
|
||||||
float pageLength = (float)vlnParagraph.MyItemInfo.MyDocStyle.Layout.PageLength;
|
float pageLength = (float)vlnParagraph.MyItemInfo.MyDocStyle.Layout.PageLength;
|
||||||
|
// Process Each Group of SupInfo paragraphs
|
||||||
foreach (List<vlnParagraph> grp in supInfoGroups)
|
foreach (List<vlnParagraph> grp in supInfoGroups)
|
||||||
{
|
{
|
||||||
|
// Initialize font decrement
|
||||||
|
float decrement = 2f;
|
||||||
float fontSize = grp[0].IParagraph.Leading; // current font size
|
float fontSize = grp[0].IParagraph.Leading; // current font size
|
||||||
// reduce the font size by _Decrement until the entire grouping fits on one page
|
float mpglen = MeasureSupInfoGroupLength(grp, cb,pageLength); // Measure the length of the group of supinfo paragraphs
|
||||||
while (MeasureLength(grp) > pageLength)
|
// If the group does not fit on a page then reduce the font size
|
||||||
|
if (mpglen > pageLength)
|
||||||
{
|
{
|
||||||
float newFontSize = fontSize - _Decrement;
|
float newFontSize=fontSize;
|
||||||
float scaler = newFontSize / fontSize;
|
// reduce the font size by _Decrement until the entire grouping fits on one page
|
||||||
ReduceGroupFontSize(grp, scaler);
|
while (mpglen > pageLength) // While the measured supinfo group length is greatere than the page length
|
||||||
fontSize = newFontSize;
|
{
|
||||||
|
newFontSize = fontSize - decrement;
|
||||||
|
float scaler = newFontSize / fontSize;// Calculate the reduction
|
||||||
|
ReduceSupInfoGroupFontSize(grp, scaler, cb); // Apply the smaller font size
|
||||||
|
fontSize = newFontSize; // adjust the base font size
|
||||||
|
mpglen = MeasureSupInfoGroupLength(grp, cb, pageLength);// Measure the length of the group of supinfo paragraphs
|
||||||
|
}
|
||||||
|
// Binary Search to find proper font size within .1
|
||||||
|
while (decrement > .1f)
|
||||||
|
{
|
||||||
|
decrement = decrement / 2f; //Reduce the decrement by half
|
||||||
|
if (mpglen > pageLength) // If the measured length is too big
|
||||||
|
newFontSize -= decrement;// Reduce the font size
|
||||||
|
else
|
||||||
|
newFontSize += decrement;//Otherwise increase the font size
|
||||||
|
float scaler = newFontSize / fontSize;// Calculate the reduction
|
||||||
|
ReduceSupInfoGroupFontSize(grp, scaler, cb);// apply the new font size
|
||||||
|
fontSize = newFontSize;// adjust the base font size
|
||||||
|
mpglen = MeasureSupInfoGroupLength(grp, cb, pageLength);// Measure the length of the group of supinfo paragraphs
|
||||||
|
}
|
||||||
|
if (mpglen > pageLength) //If the measured lenght is greater than the page length reduce the font size
|
||||||
|
{
|
||||||
|
newFontSize -= decrement;// Reduce the font size
|
||||||
|
float scaler = newFontSize / fontSize;// Calculate the reduction
|
||||||
|
ReduceSupInfoGroupFontSize(grp, scaler, cb);// apply the new font size
|
||||||
|
fontSize = newFontSize;// adjust the base font size
|
||||||
|
mpglen = MeasureSupInfoGroupLength(grp, cb, pageLength);// Measure the length of the group of supinfo paragraphs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private void ReduceGroupFontSize(List<vlnParagraph> grp, float scaler)
|
/// Method to apply a multiplier to the font size to a group of supinfo paragraphs
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="grp">group of SupInfo paragraphs</param>
|
||||||
|
/// <param name="scaler">multiplier for font size</param>
|
||||||
|
/// <param name="cb">The PDFContentByte which is needed to calculate the adjusted the paragraph height</param>
|
||||||
|
private void ReduceSupInfoGroupFontSize(List<vlnParagraph> grp, float scaler, PdfContentByte cb)
|
||||||
{
|
{
|
||||||
|
foreach (vlnParagraph pg in grp) // For each paragraph and children apply the scaler
|
||||||
|
{
|
||||||
|
// When adjusting the font size if the change causes the paragraph to change due to the number of characters
|
||||||
|
// per line these changes will impact the paragraphs below the affected paragraph
|
||||||
|
// This is kept in a dictionary. The key is the vertical offset to the affected paragraph.
|
||||||
|
// The value is the impact on the paragraph height.
|
||||||
|
_AdjustForParagraphShrinkage = new Dictionary<float, float>();
|
||||||
|
// Apply the scaler to each paragraph
|
||||||
|
ReduceSupInfoGroupFontSize(pg, scaler, cb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
private float MeasureLength(List<vlnParagraph> grp)
|
/// Method to apply a multiplier to the font size to a supinfo paragraph and children
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pg">supinfo paragraph</param>
|
||||||
|
/// <param name="scaler">font multiplier</param>
|
||||||
|
/// <param name="cb">pdfcontentbyte</param>
|
||||||
|
private void ReduceSupInfoGroupFontSize(vlnParagraph pg, float scaler, PdfContentByte cb)
|
||||||
{
|
{
|
||||||
return 0;
|
float hBefore = pg.Height;// Save initial paragraph height
|
||||||
|
NewSupInfoFixChunks(pg,scaler);// Apply multiplier to font size
|
||||||
|
pg.IParagraph.Leading = scaler * pg.IParagraph.Leading; // Adjust leading (line spacing)
|
||||||
|
float hAfter = pg.GetParagraphHeight(cb, pg.IParagraph, "", pg.Width); // Calculate new paragraph height
|
||||||
|
pg.Height = hAfter; // Save new Height;
|
||||||
|
pg.YBottomMost += hAfter - hBefore; // Adjust YbottomMost for font size and leading
|
||||||
|
float hleading = hBefore * scaler; // Calcuate leading change
|
||||||
|
// If the change in font size effects the paragraph height due to word wrapping save the impact to adjust
|
||||||
|
// Offsets below
|
||||||
|
if ((hleading > hAfter + 1 && scaler < 1f) || (hleading < hAfter + 1 && scaler > 1f))
|
||||||
|
{
|
||||||
|
if (!_AdjustForParagraphShrinkage.ContainsKey(pg.YOffset))
|
||||||
|
_AdjustForParagraphShrinkage.Add(pg.YOffset, hleading - hAfter);
|
||||||
|
}
|
||||||
|
float yoBefore = pg.YOffset;// Save the offset before
|
||||||
|
float yoAfter = pg.YOffset = NewSupInfoFixOffset(pg,scaler);// Calculate the offset after
|
||||||
|
pg.YBottomMost += yoAfter - yoBefore;// Adjust YbottomMost for changes to yOffset
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenAbove)// Process Children Above
|
||||||
|
ReduceSupInfoGroupFontSize(cpg, scaler, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenBelow)// Process Children Below
|
||||||
|
ReduceSupInfoGroupFontSize(cpg, scaler, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenLeft)// Process Children Left
|
||||||
|
ReduceSupInfoGroupFontSize(cpg, scaler, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenRight)// Process Children Right
|
||||||
|
ReduceSupInfoGroupFontSize(cpg, scaler, cb);
|
||||||
|
foreach (vlnPrintObject po in pg.PartsAbove) // Process Parts Above (headers)
|
||||||
|
NewSupInfoFixParts(po, scaler);
|
||||||
|
foreach (vlnPrintObject po in pg.PartsBelow) // Process Parts Below (unknown)
|
||||||
|
NewSupInfoFixParts(po, scaler);
|
||||||
|
foreach (vlnPrintObject po in pg.PartsLeft) // Process Parts Left (Tabs)
|
||||||
|
NewSupInfoFixParts(po, scaler);
|
||||||
|
foreach (vlnPrintObject po in pg.PartsRight) // Process Parts Right (unknown)
|
||||||
|
NewSupInfoFixParts(po, scaler);
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Adjust YOffset for Print Objects
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vpo">Print Object (tab, paragraph, etc.)</param>
|
||||||
|
/// <param name="scaler">multiplier</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private float NewSupInfoFixOffset(vlnPrintObject vpo, float scaler)
|
||||||
|
{
|
||||||
|
float fixOffSet = 0;
|
||||||
|
// determine impact of paragraphs above due to word-wrap
|
||||||
|
foreach (float off in _AdjustForParagraphShrinkage.Keys)
|
||||||
|
if (off < vpo.YOffset)
|
||||||
|
fixOffSet += _AdjustForParagraphShrinkage[off];
|
||||||
|
// combine this impact with the scaler on the YOffset
|
||||||
|
return scaler * vpo.YOffset - fixOffSet;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Adjust Font Size and offset for Parts
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="po">PrintObject</param>
|
||||||
|
/// <param name="scaler">Multiplier</param>
|
||||||
|
private void NewSupInfoFixParts(vlnPrintObject po, float scaler)
|
||||||
|
{
|
||||||
|
// Adjust the font size by the multiplier
|
||||||
|
foreach (Chunk chk in po.IParagraph.Chunks)
|
||||||
|
chk.Font.Size = scaler * chk.Font.Size;
|
||||||
|
po.IParagraph.Leading = scaler * po.IParagraph.Leading;// Apply the multiplier to the leading (line spacing)
|
||||||
|
po.YOffset = NewSupInfoFixOffset(po,scaler);// Adjust the YOffset
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Adjust the Font Size
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vlnParagraph">Paragraph</param>
|
||||||
|
/// <param name="scaler">Multiplier</param>
|
||||||
|
private void NewSupInfoFixChunks(vlnParagraph vlnParagraph, float scaler)
|
||||||
|
{
|
||||||
|
// Adjust the font size by the multiplier
|
||||||
|
foreach (Chunk chk in vlnParagraph.IParagraph.Chunks)
|
||||||
|
chk.Font.Size = scaler * chk.Font.Size;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Measure the Length of the Group
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="grp">Group of SupInfo Paragraphs</param>
|
||||||
|
/// <param name="cb">pdfContentByte</param>
|
||||||
|
/// <param name="pagelength">Page Length</param>
|
||||||
|
/// <returns>Length</returns>
|
||||||
|
private float MeasureSupInfoGroupLength(List<vlnParagraph> grp, PdfContentByte cb, float pagelength)
|
||||||
|
{
|
||||||
|
_LastBottom = 0;
|
||||||
|
_LastOffset = 12;// 24; // account for the Sup Info header (two lines)
|
||||||
|
float fontSize = grp[0].IParagraph.Leading; // current font size
|
||||||
|
// For each SupInfo Paragraph calculate length
|
||||||
|
foreach (vlnParagraph pg in grp)
|
||||||
|
{
|
||||||
|
MeasureSupInfoGroupLength(pg, cb);// Measure a SupInfo Paragraph and children
|
||||||
|
_LastOffset += _LastBottom;
|
||||||
|
_LastBottom = 0;
|
||||||
|
}
|
||||||
|
//Console.WriteLine("MeasureSupInfoGroupLength {0} {1} {2} {3}", grp[0].MyItemInfo.ItemID, _LastOffset, fontSize, pagelength);
|
||||||
|
return _LastOffset;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Measure the height of a supinfo paragraph and children
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pg">SupInfo paragraph</param>
|
||||||
|
/// <param name="cb">pdfContentByte</param>
|
||||||
|
private void MeasureSupInfoGroupLength(vlnParagraph pg, PdfContentByte cb)
|
||||||
|
{
|
||||||
|
_LastBottom = pg.YBottomMost;
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenAbove) // Measure Children Above
|
||||||
|
MeasureSupInfoGroupLength(cpg, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenBelow) // Measure Children Below
|
||||||
|
MeasureSupInfoGroupLength(cpg, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenLeft) // Measure Children Left
|
||||||
|
MeasureSupInfoGroupLength(cpg, cb);
|
||||||
|
foreach (vlnParagraph cpg in pg.ChildrenRight) // Measure Children Right
|
||||||
|
MeasureSupInfoGroupLength(cpg, cb);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Find Groups of SupInfo Paragraphs
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="vlnParagraph">SupInfo Paragraph</param>
|
||||||
|
/// <returns>List of supinfo paragraph groups</returns>
|
||||||
private List<List<vlnParagraph>> FindSupInfoGroups(vlnParagraph vlnParagraph)
|
private List<List<vlnParagraph>> FindSupInfoGroups(vlnParagraph vlnParagraph)
|
||||||
{
|
{
|
||||||
List<List<vlnParagraph>> supInfoGroups;
|
List<List<vlnParagraph>> supInfoGroups;
|
||||||
@ -1801,153 +1967,8 @@ namespace Volian.Print.Library
|
|||||||
return supInfoGroups;
|
return supInfoGroups;
|
||||||
}
|
}
|
||||||
#endregion //ShrinkSupInfoGroupAtATime
|
#endregion //ShrinkSupInfoGroupAtATime
|
||||||
#region ShrinkSupplementInfoTextFont
|
|
||||||
/*
|
|
||||||
* The logic in this region will look a the text that should appear on a supplemental information page
|
|
||||||
* and reduce the size of the text and spacing between paragraphs so that it will fit on the one page.
|
|
||||||
*/
|
|
||||||
private Dictionary<int, float> _SupInfoLengths;
|
|
||||||
static int _LastSupInfoItemID;
|
|
||||||
static float _LastBottom;
|
|
||||||
static float _LastOffset;
|
|
||||||
|
|
||||||
// create a dictionary of Supplemental Info pargraph heights
|
|
||||||
private void FindSupInfoLengths(vlnParagraph vlnParagraph)
|
|
||||||
{
|
|
||||||
_SupInfoLengths = new Dictionary<int,float>();
|
|
||||||
_LastBottom = 0;
|
|
||||||
_LastSupInfoItemID = 0;
|
|
||||||
_LastOffset = 0;
|
|
||||||
FindSupInfoLength(vlnParagraph);
|
|
||||||
if (_LastSupInfoItemID != 0)
|
|
||||||
_SupInfoLengths.Add(_LastSupInfoItemID, _LastBottom);
|
|
||||||
//ShowSupInfoPages(); //debug
|
|
||||||
|
|
||||||
}
|
|
||||||
//private void ShowSupInfoPages() // used for debug
|
|
||||||
//{
|
|
||||||
// foreach (int key in _SupInfoPages.Keys)
|
|
||||||
// Console.WriteLine("SupInfoPage {0} {1}", key, _SupInfoPages[key]);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// add the supplemental info page paragraph length (height) the dictionary
|
|
||||||
private void FindSupInfoLength(vlnParagraph vlnParagraph)
|
|
||||||
{
|
|
||||||
//Console.WriteLine("{0} {1} ybottommost {2} yoffset {3} LastOffSet {4} LastBottom {5} PrefPgBreak {6}", vlnParagraph.MyItemInfo.ItemID, vlnParagraph.MyItemInfo.ShortPath, vlnParagraph.YBottomMost, vlnParagraph.YOffset, _LastOffset, _LastBottom,vlnParagraph.PrefPageBreak);
|
|
||||||
SectionInfo supInfoSect = vlnParagraph.MyItemInfo.MyActiveSection as SectionInfo;
|
|
||||||
if (supInfoSect.StepSectPageBreaksForSupInfo != null && supInfoSect.StepSectPageBreaksForSupInfo.Contains(vlnParagraph.MyItemInfo.ItemID))
|
|
||||||
{
|
|
||||||
if (_LastSupInfoItemID != 0)
|
|
||||||
_SupInfoLengths.Add(_LastSupInfoItemID, _LastBottom + _LastOffset);
|
|
||||||
_LastOffset = 24; // account for the Sup Info header (two lines)
|
|
||||||
_LastBottom = 0;
|
|
||||||
_LastSupInfoItemID = vlnParagraph.MyItemInfo.ItemID;
|
|
||||||
}
|
|
||||||
if (vlnParagraph.YOffset == 0)
|
|
||||||
_LastOffset += _LastBottom + 12f; // the +12 accounts for blank lines between paragraphs
|
|
||||||
_LastBottom = vlnParagraph.YBottomMost;
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenAbove)
|
|
||||||
FindSupInfoLength(pg);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenBelow)
|
|
||||||
FindSupInfoLength(pg);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenLeft)
|
|
||||||
FindSupInfoLength(pg);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenRight)
|
|
||||||
FindSupInfoLength(pg);
|
|
||||||
|
|
||||||
}
|
|
||||||
private Dictionary<float, float> _AdjustForParagraphShrinkage;
|
|
||||||
private float _AdjustSupInfoSize = 0;
|
|
||||||
private void AdjustSupInfoFontSize(vlnParagraph vlnParagraph, PdfContentByte cb)
|
|
||||||
{
|
|
||||||
AdjustSupInfoFontSize(vlnParagraph, cb, 0);
|
|
||||||
}
|
|
||||||
// if there is too much supplemental info text to fit on the page at the normal font,
|
|
||||||
// reduce the size of font so it fits on the page, but only if the reduced font size is still easly readable.
|
|
||||||
private void AdjustSupInfoFontSize(vlnParagraph vlnParagraph, PdfContentByte cb, int level)
|
|
||||||
{
|
|
||||||
if (vlnParagraph.MyItemInfo.ItemID == 62805)
|
|
||||||
Console.WriteLine("stop");
|
|
||||||
if (_SupInfoLengths.ContainsKey(vlnParagraph.MyItemInfo.ItemID))
|
|
||||||
{
|
|
||||||
float hsize = _SupInfoLengths[vlnParagraph.MyItemInfo.ItemID];
|
|
||||||
//if (hsize > 900)
|
|
||||||
// Console.WriteLine("stop");
|
|
||||||
//if (hsize < 504 || hsize > 900) // not bigger than the page and not too big to shrink
|
|
||||||
float hMin = (float)vlnParagraph.MyItemInfo.MyDocStyle.Layout.PageLength;
|
|
||||||
float hMax = 1.75f * hMin;
|
|
||||||
float hMult = (1.0f - .67f) / (hMin - hMax);
|
|
||||||
float hOffSet = 1.0f - (hMult * hMin);
|
|
||||||
if (hsize < hMin)// || hsize > hMax) // not bigger than the page and not too big to shrink
|
|
||||||
_AdjustSupInfoSize = 1f; // don't adjust the font size
|
|
||||||
else
|
|
||||||
_AdjustSupInfoSize = hOffSet + hsize * hMult; // shrink the font size and line spacing
|
|
||||||
//_AdjustSupInfoSize = 1.4447F - hsize * .00088F; // shrink the font size and line spacing
|
|
||||||
}
|
|
||||||
//if (vlnParagraph.PrefPageBreak || vlnParagraph.HasPrefPageBreak)
|
|
||||||
// Console.WriteLine("path {0}, PrePageBeak = {1}, ItemID = {2}", vlnParagraph.MyItemInfo.ShortPath, vlnParagraph.PrefPageBreak, vlnParagraph.MyItemInfo.ItemID);
|
|
||||||
//if (level == 1)
|
|
||||||
// Console.WriteLine("bottom most {0}", vlnParagraph.YBottomMost - vlnParagraph.YOffset);
|
|
||||||
float hBefore = vlnParagraph.Height;
|
|
||||||
SupInfoFixChunks(vlnParagraph);
|
|
||||||
//Console.WriteLine("Orig Font Size {0}", vlnParagraph.IParagraph.Leading);
|
|
||||||
vlnParagraph.IParagraph.Leading = _AdjustSupInfoSize * vlnParagraph.IParagraph.Leading;
|
|
||||||
float hAfter = vlnParagraph.GetParagraphHeight(cb, vlnParagraph.IParagraph, "", vlnParagraph.Width);
|
|
||||||
float hleading = hBefore * _AdjustSupInfoSize;
|
|
||||||
if (vlnParagraph.YOffset == 0)
|
|
||||||
_AdjustForParagraphShrinkage = new Dictionary<float, float>();
|
|
||||||
if (hleading > hAfter +1)
|
|
||||||
{
|
|
||||||
if (!_AdjustForParagraphShrinkage.ContainsKey(vlnParagraph.YOffset))
|
|
||||||
_AdjustForParagraphShrinkage.Add(vlnParagraph.YOffset, hleading - hAfter);
|
|
||||||
//Console.WriteLine("hbefore = {0} hAfter {1} hLeading {2}", hBefore, hAfter, hleading);
|
|
||||||
}
|
|
||||||
vlnParagraph.YOffset = SupInfoFixOffset(vlnParagraph);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenAbove)
|
|
||||||
AdjustSupInfoFontSize(pg,cb,level +1);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenBelow)
|
|
||||||
AdjustSupInfoFontSize(pg,cb,level +1);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenLeft)
|
|
||||||
AdjustSupInfoFontSize(pg,cb,level +1);
|
|
||||||
foreach (vlnParagraph pg in vlnParagraph.ChildrenRight)
|
|
||||||
AdjustSupInfoFontSize(pg,cb,level +1);
|
|
||||||
foreach (vlnPrintObject po in vlnParagraph.PartsAbove)
|
|
||||||
SupInfoFixParts(po);
|
|
||||||
foreach (vlnPrintObject po in vlnParagraph.PartsBelow)
|
|
||||||
SupInfoFixParts(po);
|
|
||||||
foreach (vlnPrintObject po in vlnParagraph.PartsLeft)
|
|
||||||
SupInfoFixParts(po);
|
|
||||||
foreach (vlnPrintObject po in vlnParagraph.PartsRight)
|
|
||||||
SupInfoFixParts(po);
|
|
||||||
}
|
|
||||||
|
|
||||||
// adjust the step tabs
|
|
||||||
private float SupInfoFixOffset( vlnPrintObject vpo)
|
|
||||||
{
|
|
||||||
float fixOffSet = 0;
|
|
||||||
foreach (float off in _AdjustForParagraphShrinkage.Keys)
|
|
||||||
if (off < vpo.YOffset)
|
|
||||||
fixOffSet += _AdjustForParagraphShrinkage[off];
|
|
||||||
return _AdjustSupInfoSize * vpo.YOffset - fixOffSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
// adjust the space between the paragraphs
|
|
||||||
private void SupInfoFixParts(vlnPrintObject po)
|
|
||||||
{
|
|
||||||
foreach (Chunk chk in po.IParagraph.Chunks)
|
|
||||||
chk.Font.Size = _AdjustSupInfoSize * chk.Font.Size;
|
|
||||||
po.IParagraph.Leading = _AdjustSupInfoSize * po.IParagraph.Leading;
|
|
||||||
po.YOffset = SupInfoFixOffset(po);
|
|
||||||
}
|
|
||||||
|
|
||||||
// adjust the font size of the paragraph text
|
|
||||||
private void SupInfoFixChunks(vlnParagraph vlnParagraph)
|
|
||||||
{
|
|
||||||
foreach (Chunk chk in vlnParagraph.IParagraph.Chunks)
|
|
||||||
chk.Font.Size = _AdjustSupInfoSize * chk.Font.Size;
|
|
||||||
}
|
|
||||||
#endregion // ShrinkSupplementInfoTextFont
|
|
||||||
|
|
||||||
|
|
||||||
public void DoSupInfoPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int itemid, bool insertBlankPages)
|
public void DoSupInfoPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int itemid, bool insertBlankPages)
|
||||||
{
|
{
|
||||||
// see if the ID is in the facing page pdf - if so, get the page:
|
// see if the ID is in the facing page pdf - if so, get the page:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user