C2021-010: Print using standard pagination rules by removing trailing hard returns, spaces & manual page breaks
This commit is contained in:
@@ -116,11 +116,20 @@ namespace Volian.Print.Library
|
||||
get { return _SaveLinks; }
|
||||
set { _SaveLinks = value; }
|
||||
}
|
||||
private bool _RemoveTrailingHardReturnsAndManualPageBreaks = false;
|
||||
public bool RemoveTrailingHardReturnsAndManualPageBreaks
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
// Use these 2 lists to track the items that will need to be saved after removing trailing newlines/spaces or
|
||||
// manual page breaks, if the user selects to do that.
|
||||
private List<int> _RemoveTrailingHardReturnsAndSpaces = null;
|
||||
public List<int> RemoveTrailingHardReturnsAndSpaces
|
||||
{
|
||||
get { return _RemoveTrailingHardReturnsAndManualPageBreaks; }
|
||||
set { _RemoveTrailingHardReturnsAndManualPageBreaks = value; }
|
||||
get { return _RemoveTrailingHardReturnsAndSpaces; }
|
||||
set { _RemoveTrailingHardReturnsAndSpaces = value; }
|
||||
}
|
||||
private List<int> _RemoveManualPageBreaks = null;
|
||||
public List<int> RemoveManualPageBreaks
|
||||
{
|
||||
get { return _RemoveManualPageBreaks; }
|
||||
set { _RemoveManualPageBreaks = value; }
|
||||
}
|
||||
|
||||
private string _Prefix = ""; // RHM20150506 Multiline ItemID TextBox
|
||||
@@ -307,7 +316,7 @@ namespace Volian.Print.Library
|
||||
set { _MergedPdf = value; }
|
||||
}
|
||||
public PromsPrinter(ItemInfo myItem, string rev, string watermark, bool debugOutput, bool origPgBrk, string backgroundFolder, bool openPDF, bool overWrite,
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, bool removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf)
|
||||
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, int removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll, MergedPdf mergedPdf)
|
||||
{
|
||||
Prefix = prefix; // RHM20150506 Multiline ItemID TextBox
|
||||
_MyItem = myItem;
|
||||
@@ -324,7 +333,9 @@ namespace Volian.Print.Library
|
||||
_BatchPrint = batchPrint;
|
||||
_MyReaderHelper = new ReaderHelper(this);
|
||||
_SaveLinks = saveLinks;
|
||||
_RemoveTrailingHardReturnsAndManualPageBreaks = removeTrailngHardReturnsAndManualPageBreaks;
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
if (removeTrailngHardReturnsAndManualPageBreaks == 1 || removeTrailngHardReturnsAndManualPageBreaks == 3 ) RemoveTrailingHardReturnsAndSpaces = new List<int>();
|
||||
if (removeTrailngHardReturnsAndManualPageBreaks == 2 || removeTrailngHardReturnsAndManualPageBreaks == 3) RemoveManualPageBreaks = new List<int>();
|
||||
_BlankPageText = blankPageText;
|
||||
_DidAll = didAll;
|
||||
_MergeNotIncluded = false;
|
||||
@@ -2454,6 +2465,78 @@ namespace Volian.Print.Library
|
||||
*/
|
||||
return ms.ToArray();
|
||||
}
|
||||
// C2021-010: Remove trailing returns/spaces & manual page breaks & allow save.
|
||||
public void SavePaginationFixes()
|
||||
{
|
||||
// If manual page breaks were removed (during pagination), save those
|
||||
if (RemoveManualPageBreaks != null && RemoveManualPageBreaks.Count > 0)
|
||||
{
|
||||
foreach (int iid in RemoveManualPageBreaks)
|
||||
{
|
||||
ItemInfo ii = ItemInfo.Get(iid);
|
||||
StepConfig sc = ii.MyConfig as StepConfig;
|
||||
if (sc != null)
|
||||
{
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, "Removed Manual Page Break", null);
|
||||
sc.Step_NewManualPagebreak = false; // reset the flag that was set in the config
|
||||
itm.MyContent.Config = sc.ToString();
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// If trailing newlines and/or spages were removed, save those
|
||||
if (RemoveTrailingHardReturnsAndSpaces != null && RemoveTrailingHardReturnsAndSpaces.Count > 0)
|
||||
{
|
||||
foreach (int iid in RemoveTrailingHardReturnsAndSpaces)
|
||||
{
|
||||
// first check if it exists, if the step was empty, it may have been deleted.
|
||||
ItemInfo iitmp = ItemInfo.Get(iid);
|
||||
if (iitmp != null)
|
||||
{
|
||||
string annot = "Removed Trailing Newlines and Spaces";
|
||||
if (RemoveManualPageBreaks != null && RemoveManualPageBreaks.Contains(iid)) annot = "Removed Trailing Newlines, Spaces and ManualPageBreak";
|
||||
string tmp = Regex.Replace(iitmp.MyContent.Text, "(\\\\line|\r|\n|\\\\u160\\?| )+$", "");
|
||||
// if the step ends up empty, set the text to a space (if null or "") step gets deleted. Also, flag
|
||||
// that this is an emtpy step so that print can handle it, i.e. when text is set for step during printing,
|
||||
// if it is emtpy the string is "", which prints without height. This is flagged so that the pdf will
|
||||
// look the same, i.e. printed when trailing newlines/spaces are removed (text = "") & after the changes
|
||||
// are saved (text = " ")
|
||||
if (tmp == null || tmp == "")
|
||||
{
|
||||
StepConfig sctmp = iitmp.MyConfig as StepConfig;
|
||||
if (sctmp == null) sctmp = new StepConfig();
|
||||
sctmp.Step_EmptyStep = true;
|
||||
annot = "Empty step. Consider deleting to restore standard pagination.";
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, annot, null);
|
||||
itm.MyContent.Config = sctmp.ToString();
|
||||
itm.MyContent.Text = " ";
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Item itm = Item.Get(iid))
|
||||
{
|
||||
VEPROMS.CSLA.Library.Annotation x = VEPROMS.CSLA.Library.Annotation.MakeAnnotation(itm, AnnotationType.GetByNameOrCreate("Manual Pagination Issues"), null, annot, null);
|
||||
itm.MyContent.Text = tmp;
|
||||
itm.MyContent.DTS = DateTime.Now;
|
||||
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
|
||||
itm.MyContent.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public class ReaderHelper
|
||||
{
|
||||
|
Reference in New Issue
Block a user