C2019-012: Merge pdfs

This commit is contained in:
Kathy Ruffing 2019-03-12 12:56:58 +00:00
parent cfcf9de352
commit 76bd61b435
13 changed files with 2331 additions and 1242 deletions

View File

@ -42,7 +42,6 @@ namespace VEPROMS
this.txbRevDate = new DevComponents.DotNetBar.Controls.TextBoxX();
this.txbPDFLocation = new DevComponents.DotNetBar.Controls.TextBoxX();
this.cbxOpenAfterCreate2 = new System.Windows.Forms.CheckBox();
this.docVersionConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.cbxOverwritePDF2 = new System.Windows.Forms.CheckBox();
this.txbRevNum = new DevComponents.DotNetBar.Controls.TextBoxX();
this.lblReviewDate = new DevComponents.DotNetBar.LabelX();
@ -96,14 +95,16 @@ namespace VEPROMS
this.tbBlankPage = new DevComponents.DotNetBar.Controls.TextBoxX();
this.lblBlPg = new DevComponents.DotNetBar.LabelX();
this.swtbtnPDFdtPrefixSuffix = new DevComponents.DotNetBar.Controls.SwitchButton();
this.docVersionConfigBindingSource = new System.Windows.Forms.BindingSource(this.components);
this.btnMergePDFs = new DevComponents.DotNetBar.ButtonX();
this.gpnlDebug.SuspendLayout();
this.grpDateSelector.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.docVersionConfigBindingSource)).BeginInit();
this.ppGpbxUserSpecTxt.SuspendLayout();
this.ppGpbxUserSpecCB.SuspendLayout();
this.panelEx2.SuspendLayout();
this.expPrnSetting.SuspendLayout();
this.ppGpDuplex.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.docVersionConfigBindingSource)).BeginInit();
this.SuspendLayout();
//
// btnPdfLocation
@ -131,7 +132,7 @@ namespace VEPROMS
this.gpnlDebug.Controls.Add(this.cbxDebugText);
this.gpnlDebug.Controls.Add(this.cbxDebugPagination);
this.gpnlDebug.DisabledBackColor = System.Drawing.Color.Empty;
this.gpnlDebug.Location = new System.Drawing.Point(587, 155);
this.gpnlDebug.Location = new System.Drawing.Point(586, 184);
this.gpnlDebug.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.gpnlDebug.Name = "gpnlDebug";
this.gpnlDebug.Size = new System.Drawing.Size(159, 119);
@ -364,7 +365,7 @@ namespace VEPROMS
this.cbxOpenAfterCreate2.BackColor = System.Drawing.Color.Transparent;
this.cbxOpenAfterCreate2.DataBindings.Add(new System.Windows.Forms.Binding("Checked", this.docVersionConfigBindingSource, "Print_AlwaysViewPDFAfterCreate", true));
this.cbxOpenAfterCreate2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.cbxOpenAfterCreate2.Location = new System.Drawing.Point(596, 113);
this.cbxOpenAfterCreate2.Location = new System.Drawing.Point(596, 111);
this.cbxOpenAfterCreate2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.cbxOpenAfterCreate2.Name = "cbxOpenAfterCreate2";
this.cbxOpenAfterCreate2.Size = new System.Drawing.Size(202, 24);
@ -373,10 +374,6 @@ namespace VEPROMS
this.cbxOpenAfterCreate2.Text = "View PDF After Create";
this.cbxOpenAfterCreate2.UseVisualStyleBackColor = false;
//
// docVersionConfigBindingSource
//
this.docVersionConfigBindingSource.DataSource = typeof(VEPROMS.CSLA.Library.DocVersionConfig);
//
// cbxOverwritePDF2
//
this.cbxOverwritePDF2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -1120,6 +1117,7 @@ namespace VEPROMS
//
this.panelEx2.CanvasColor = System.Drawing.SystemColors.Control;
this.panelEx2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.panelEx2.Controls.Add(this.btnMergePDFs);
this.panelEx2.Controls.Add(this.gpnlDebug);
this.panelEx2.Controls.Add(this.cbxMultiunitPdfLocation);
this.panelEx2.Controls.Add(this.pbPDFsStatus);
@ -1296,6 +1294,26 @@ namespace VEPROMS
this.swtbtnPDFdtPrefixSuffix.TabIndex = 111;
this.swtbtnPDFdtPrefixSuffix.ValueChanged += new System.EventHandler(this.swtbtnPDFdtPrefixSuffix_ValueChanged);
//
// docVersionConfigBindingSource
//
this.docVersionConfigBindingSource.DataSource = typeof(VEPROMS.CSLA.Library.DocVersionConfig);
//
// btnMergePDFs
//
this.btnMergePDFs.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton;
this.btnMergePDFs.BackColor = System.Drawing.SystemColors.Control;
this.btnMergePDFs.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground;
this.btnMergePDFs.Font = new System.Drawing.Font("Microsoft Sans Serif", 10.8F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnMergePDFs.Location = new System.Drawing.Point(216, 505);
this.btnMergePDFs.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.btnMergePDFs.Name = "btnMergePDFs";
this.btnMergePDFs.Size = new System.Drawing.Size(177, 46);
this.btnMergePDFs.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.superTooltip1.SetSuperTooltip(this.btnMergePDFs, new DevComponents.DotNetBar.SuperTooltipInfo("Create PDF", "", "Generate a PDF of the selected procedure.", null, null, DevComponents.DotNetBar.eTooltipColor.Gray));
this.btnMergePDFs.TabIndex = 110;
this.btnMergePDFs.Text = "Merge PDFs";
this.btnMergePDFs.Click += new System.EventHandler(this.btnMergePDFs_Click);
//
// DlgPrintProcedure
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
@ -1319,7 +1337,6 @@ namespace VEPROMS
this.gpnlDebug.PerformLayout();
this.grpDateSelector.ResumeLayout(false);
this.grpDateSelector.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.docVersionConfigBindingSource)).EndInit();
this.ppGpbxUserSpecTxt.ResumeLayout(false);
this.ppGpbxUserSpecTxt.PerformLayout();
this.ppGpbxUserSpecCB.ResumeLayout(false);
@ -1328,6 +1345,7 @@ namespace VEPROMS
this.panelEx2.PerformLayout();
this.expPrnSetting.ResumeLayout(false);
this.ppGpDuplex.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.docVersionConfigBindingSource)).EndInit();
this.ResumeLayout(false);
}
@ -1400,5 +1418,6 @@ namespace VEPROMS
private DevComponents.DotNetBar.Controls.TextBoxX tbBlankPage;
private DevComponents.DotNetBar.LabelX lblBlPg;
private DevComponents.DotNetBar.Controls.GroupPanel ppGpDuplex;
private DevComponents.DotNetBar.ButtonX btnMergePDFs;
}
}

View File

@ -10,6 +10,7 @@ using VEPROMS.CSLA.Library;
using Volian.Print.Library;
//using Volian.Controls.Library;
using Volian.Base.Library;
using JR.Utils.GUI.Forms;
namespace VEPROMS
{
@ -216,6 +217,7 @@ namespace VEPROMS
cbxGenerateConActSum.Checked = false;
swtbtnGeneratePlacekeeper.Visible = lblGeneratePlacekeeper.Visible = oneProcedure &&
((MyProcedure.ActiveFormat.PlantFormat.FormatData.PurchaseOptions & E_PurchaseOptions.AutoPlacekeeper) == E_PurchaseOptions.AutoPlacekeeper);
btnMergePDFs.Visible = !oneProcedure;
}
private string _UnitNumber;
public string UnitNumber
@ -598,6 +600,8 @@ namespace VEPROMS
}
}
private string _MultiunitPdfLocation = string.Empty;
private MergedPdf _MergedPfd = null;
private string _MergedPdfPath = null;
private void CreatePDFs()
{
if (VlnSettings.GetCommandFlag("PROFILE")) ProfileTimer.TurnOnTracking("Profile.txt");
@ -635,6 +639,7 @@ namespace VEPROMS
this.Text = string.Format("Processing {0}", _DocVersionInfo.MyFolder.Name);
foreach (ProcedureInfo myProc in _DocVersionInfo.Procedures)
{
string locpdfname = null; // get pdf file name for later merge code
MyProcedure = myProc;
if (myProc.Sections != null)
{
@ -646,21 +651,24 @@ namespace VEPROMS
pbPDFsStatus.TextVisible = true;
pbPDFsStatus.Text = string.Format("Creating PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
pbPDFsStatus.Value = i;
// this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
// this.Text = string.Format("Create PDF for {0} ({1} of {2})", myProc.DisplayNumber, ++i, n);
MyProcedure = ProcedureInfo.GetItemAndChildrenByUnit(MyProcedure.ItemID, 0, MyProcedure.MyDocVersion.DocVersionConfig.SelectedSlave);
// C2018-015 add the procedure tree path and the procedure number and title to the meta file
if (BaselineMetaFile.IsOpen && i == 1) BaselineMetaFile.WriteLine("!! {0}", MyProcedure.SearchDVPath.Replace("\a", " | "));
if (BaselineMetaFile.IsOpen) BaselineMetaFile.WriteLine("!! {0} | {1}", MyProcedure.DisplayNumber, MyProcedure.DisplayText);
string myPDFPath = GetMultiunitPDFPath();
_MergedPdfPath = myPDFPath; // If Slave, need its subdirectory/unit path for merging
// RHM 20120925 Overlay the bottom of the dialog so that cancel button is covered.
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked,
frmPDFStatusForm frmStatus = new frmPDFStatusForm(MyProcedure, RevNumAndDate, pw.ToString(), cbxDebug.Checked, cbxOrPgBrk.Checked,
cbxOpenAfterCreate2.Checked, cbxOverwritePDF2.Checked, myPDFPath, cbd, txbPDFName.Text, new Point(Left, Bottom - 50),
swtbtnBlankPgsForDuplex.Value, _AllProcedures || Automatic, Prefix, SaveLinks, RemoveTrailingHardReturnsAndManualPageBreaks, swtbtnPROMSVersion.Value, true, tbBlankPage.Text);//C2018-009 print PROMS version
frmStatus.CloseWhenDone = true;
Application.DoEvents();
frmStatus.CancelStop = true;
frmStatus.ShowDialog();
locpdfname = frmStatus.PdfFile;
if (frmStatus.CancelPrinting) break;
AddToMergeList(myProc, locpdfname);
}
// This is a master/slave for printing of all slaves (SelectedSave == 0)
else if (SelectedSlave == 0)
@ -686,7 +694,9 @@ namespace VEPROMS
Application.DoEvents();
frmStatus.CancelStop = true;
frmStatus.ShowDialog();
locpdfname = frmStatus.PdfFile;
if (frmStatus.CancelPrinting) break;
AddToMergeList(myProc, locpdfname);
}
}
// Not master/slave
@ -715,7 +725,9 @@ namespace VEPROMS
Application.DoEvents();
frmStatus.CancelStop = true;
frmStatus.ShowDialog();
locpdfname = frmStatus.PdfFile;
if (frmStatus.CancelPrinting) break;
AddToMergeList(myProc, locpdfname);
}
}
}
@ -731,6 +743,20 @@ namespace VEPROMS
}
}
private void AddToMergeList(ProcedureInfo myProc, string locpdfname)
{
// if doing a merge and this procedure should be included, add it to _MergedPdf:
if (_MergedPfd != null && !(myProc.MyConfig as ProcedureConfig).Print_NotInMergeAll)
{
// pdf name from printing has the path, remove it.
string pdfname = locpdfname.Substring(locpdfname.LastIndexOf(@"\") + 1);
MergedPdfProc mpp = new MergedPdfProc(myProc.DisplayText, pdfname);
if (_MergedPfd.MergedPdfs == null) _MergedPfd.MergedPdfs = new List<MergedPdfProc>();
mpp.PageCount = PromsPrinter.ProcPageCount;
_MergedPfd.MergedPdfs.Add(mpp);
}
}
private string GetMultiunitPDFPath()
{
string newPDFPath = string.Empty;
@ -880,6 +906,11 @@ namespace VEPROMS
return cbd;
}
private void btnCreatePDF_Click(object sender, EventArgs e)
{
DoCreatePDF();
}
private void DoCreatePDF()
{
Rtf2iTextSharp.DoingComparison = cbxDebug.Checked;
if (_AllProcedures)
@ -891,23 +922,26 @@ namespace VEPROMS
CreatePDFs();
PromsPrinter.ReportTransPageNumProblems();
this.Cursor = Cursors.Default;
if (VlnSettings.DebugMode)
if (_MergedPfd == null)
{
MessageBox.Show(string.Format("{0} Minutes to Print All Procedures"
, TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes),
"Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information);
if (VlnSettings.DebugMode)
{
MessageBox.Show(string.Format("{0} Minutes to Print All Procedures"
, TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes),
"Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else // Production or Demo mode
{
MessageBox.Show("Completed Successfully", "Print All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
this.Close();
}
else // Production or Demo mode
{
MessageBox.Show("Completed Successfully", "Print All Procedures", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
this.Close();
}
else
{
// B2016-249 Output Procedure to folder associated with Parent Child
// B2017-009 If the selected item is null don't add a folder
if(cbxMultiunitPdfLocation.SelectedItem != null)
if (cbxMultiunitPdfLocation.SelectedItem != null)
_MultiunitPdfLocation = cbxMultiunitPdfLocation.SelectedItem.ToString();
this.Cursor = Cursors.WaitCursor;
CreatePDF();
@ -1084,6 +1118,36 @@ namespace VEPROMS
tbBlankPage.Enabled = swtbtnBlankPgsForDuplex.Value;
}
// Merge the pdfs into one pdf file (C2019-012)
private void btnMergePDFs_Click(object sender, EventArgs e)
{
DateTime dtStart = DateTime.Now;
_MergedPfd = new MergedPdf(PDFPath, _DocVersionInfo);
DoCreatePDF(); // create indivitual pdfs
if (_MergedPdfPath != null && _MergedPdfPath != PDFPath) PDFPath = _MergedPfd.Folder = _MergedPdfPath;
if (!_MergedPfd.DoTheMerge()) return; // merge them together.
// if the property to show the file after printing is set (on the version dialog), display it. Otherwise do a dialog to let user know it's done
if (_DocVersionConfig.Print_MergedPdfsViewAfter)
{
if (_MergedPfd.MergedPdfs != null && _MergedPfd.MergedPdfs.Count > 0)
{
System.Diagnostics.Process sdp = System.Diagnostics.Process.Start(_MergedPfd.MergedFileName);
sdp.WaitForInputIdle();
}
}
else if (VlnSettings.DebugMode)
{
FlexibleMessageBox.Show(string.Format("{0} Minutes to Print and Merge Procedures"
, TimeSpan.FromTicks(DateTime.Now.Ticks - dtStart.Ticks).TotalMinutes),
"Printing Duration", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else // Production or Demo mode
{
FlexibleMessageBox.Show("Completed Successfully", "Print All and Merge Procedures", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
this.Close();
}
//private void cbxDebug_CheckedChanged(object sender, EventArgs e)
//{
// cbxCmpPRMSpfd.Visible = cbxDebug.Checked;

View File

@ -89,7 +89,7 @@ namespace VEPROMS
InitializeComponent();
// if the version number of PROMS is 1.0, then we are running a Demo version.
// When running a Demo version, force a "Sample" watermark when printing.
MyPromsPrinter = new PromsPrinter(myItem, rev, (VlnSettings.ReleaseMode.Equals("DEMO")) ? "Sample" : watermark, debugOutput, origPgBrk, pdfPath + @"\\Compare", false, overWrite, cbd, pdfFile, insertBlankPages, allOrAuto,Prefix,saveLinks,removeTrailingHardReturnsAndManualPageBreaks, blankPageText);
MyPromsPrinter = new PromsPrinter(myItem, rev, (VlnSettings.ReleaseMode.Equals("DEMO")) ? "Sample" : watermark, debugOutput, origPgBrk, pdfPath + @"\\Compare", false, overWrite, cbd, pdfFile, insertBlankPages, allOrAuto,Prefix,saveLinks,removeTrailingHardReturnsAndManualPageBreaks, blankPageText, DidAll);
MyPromsPrinter.PromsVersion = (showPROMSVer) ? AboutVEPROMS.PROMSVersion : ""; //C2018-009 print PROMS version
PDFPath = pdfPath;
this.Text = "Creating PDF of " + myItem.DisplayNumber;
@ -139,7 +139,11 @@ namespace VEPROMS
}
private string _PdfFile;
public string PdfFile
{
get { return _PdfFile; }
set { _PdfFile = value; }
}
private bool _MakePlaceKeeper = false;
public bool MakePlaceKeeper
@ -193,7 +197,7 @@ namespace VEPROMS
PartInfo.RestoreCacheList(cachePartInfo);
}
}
while (_PdfFile == null && MessageBox.Show("Try Again?", "PDF Creation Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
while (!MyPromsPrinter.MergeNotIncluded && _PdfFile == null && MessageBox.Show("Try Again?", "PDF Creation Failed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes);
if (_PdfFile == null)
{
this.Close();

File diff suppressed because it is too large Load Diff

View File

@ -68,6 +68,7 @@ namespace VEPROMS
// Save whether we should display the default values on this property page
Settings.Default.ShowDefaultProcedureProp = ppCbShwDefSettings.Checked;
Settings.Default.Save();
_ProcedureConfig.Print_NotInMergeAll = cbNotIncludeInMerged.Checked;
_ProcedureConfig.MyProcedure.Save().Dispose();
SaveText(ppProcTitleStpRTB);
SaveText(ppProcNumStpRTB);
@ -248,6 +249,7 @@ namespace VEPROMS
DocVersionConfig dvc = _ProcedureConfig.MyProcedure.MyProcedureInfo.MyDocVersion.MyConfig as DocVersionConfig;
if (_ProcedureConfig.CreatingNew && dvc != null && dvc.MyEnhancedDocuments != null && dvc.MyEnhancedDocuments.Count > 0 && dvc.MyEnhancedDocuments[0].Type != 0)
cbEnhanced.Visible = true;
cbNotIncludeInMerged.Checked = _ProcedureConfig.Print_NotInMergeAll;
_Initializing = false;
}

File diff suppressed because it is too large Load Diff

View File

@ -234,6 +234,16 @@ namespace VEPROMS
_DocVersionConfig.Print_UnitNumberForPageList = ppTxbxUnitNum.Text;
// save the merge pdf settings:
_DocVersionConfig.Print_MergedPdfsPageOf = (MergedPdfsPageOf)ppCmbxMOSformat.SelectedIndex;
_DocVersionConfig.Print_MergedPdfsPageNumFormatOther = tbxMOSother.Text;
_DocVersionConfig.Print_MergedPdfsPageNumFont = (string)ppCmbxMOSfontName.SelectedValue;
_DocVersionConfig.Print_MergedPdfsPageNumFontSize = tbxMOSfontSz.Text;
_DocVersionConfig.Print_MergedPdfsPageNumLocX = float.Parse(tbxMOSxloc.Text);
_DocVersionConfig.Print_MergedPdfsPageNumLocY = float.Parse(tbxMOSyloc.Text);
_DocVersionConfig.Print_MergedPdfsPageNumCorner = (MergedPdfsPageNumCorner)ppCmbxMOScornerLoc.SelectedIndex;
_DocVersionConfig.Print_MergedPdfsViewAfter = ppChbxMOSview.Checked;
//docVersionConfigBindingSource.EndEdit();
// Save Default settings for User
//
@ -415,6 +425,20 @@ namespace VEPROMS
ppCmbxProcSetType.ValueMember = "EValue";
ppCmbxProcSetType.Enabled = false; // maybe enable this if used for version creation
ppCmbxMOSformat.DataSource = EnumDetail<MergedPdfsPageOf>.Details();
ppCmbxMOSformat.DisplayMember = "Description";
ppCmbxMOSformat.ValueMember = "EValue";
ppCmbxMOSformat.SelectedIndex = -1;
ppCmbxMOSfontName.DataSource = FontFamily.Families;// need font list
ppCmbxMOSfontName.ValueMember = "Name";
ppCmbxMOSfontName.SelectedIndex = -1;
ppCmbxMOScornerLoc.DataSource = EnumDetail<MergedPdfsPageNumCorner>.Details();
ppCmbxMOScornerLoc.DisplayMember = "Description";
ppCmbxMOScornerLoc.ValueMember = "EValue";
ppCmbxMOScornerLoc.SelectedIndex = -1;
// check active format to see if the unit number text box on the format tab is visible.
if (_DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.UnitNumber)
{
@ -491,6 +515,29 @@ namespace VEPROMS
btnPhoneList.Visible = _DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.PlantFormat.FormatData.SectData.PrintPhoneList;
btnUnlinkDocVersion.Visible = false;
InitEnhanced();
// set the merge pdf settings:
ppCmbxMOSformat.SelectedIndex = (int)_DocVersionConfig.Print_MergedPdfsPageOf;
if (_DocVersionConfig.Print_MergedPdfsPageOf == MergedPdfsPageOf.Other)
{
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSother.Enabled = true;
}
else
tbxMOSother.Enabled = false;
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSfontSz.Text = _DocVersionConfig.Print_MergedPdfsPageNumFontSize;
tbxMOSxloc.Text = _DocVersionConfig.Print_MergedPdfsPageNumLocX.ToString();
tbxMOSyloc.Text = _DocVersionConfig.Print_MergedPdfsPageNumLocY.ToString();
ppCmbxMOScornerLoc.SelectedIndex = (int)_DocVersionConfig.Print_MergedPdfsPageNumCorner;
ppCmbxMOSfontName.DataSource = FontFamily.Families;
ppCmbxMOSfontName.DisplayMember = "Name";
if (_DocVersionConfig.Print_MergedPdfsPageNumFont == null || _DocVersionConfig.Print_MergedPdfsPageNumFont == "")
ppCmbxMOSfontName.SelectedIndex = -1;
else
ppCmbxMOSfontName.SelectedValue = _DocVersionConfig.Print_MergedPdfsPageNumFont;
ppChbxMOSview.Checked = _DocVersionConfig.Print_MergedPdfsViewAfter;
_Initializing = false;
}
private void InitEnhanced()
@ -984,7 +1031,12 @@ namespace VEPROMS
}
#endregion
#region MergedOutputSettings
private void btnMergedOutputSettngs_Click(object sender, EventArgs e)
{
ProcessButtonClick(tiMergedOutputSettings, btnMergedOutputSettngs);
}
#endregion
#region Generic functions used on this property page
/// <summary>
@ -1625,6 +1677,24 @@ namespace VEPROMS
}
}
}
private void ppCmbxMOSformat_SelectedIndexChanged(object sender, EventArgs e)
{
if (!_Initializing)
{
// The Other textbox for defining the merged pdf file page of format is only enabled if the user
// has selected 'Other' as the format type.
if ((MergedPdfsPageOf)ppCmbxMOSformat.SelectedValue == MergedPdfsPageOf.Other)
{
tbxMOSother.Text = _DocVersionConfig.Print_MergedPdfsPageNumFormatOther;
tbxMOSother.Enabled = true;
}
else
tbxMOSother.Enabled = false;
}
}
}
[XmlRoot("Enhanced")]
public class EnhancedMiniConfig

View File

@ -210,15 +210,15 @@ Check "Show Default Settings" to display the "default" duplexing setting (below
<metadata name="bsEnhanced.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>817, 17</value>
</metadata>
<metadata name="documentInfoListBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>181, 113</value>
</metadata>
<metadata name="bsMiniApple.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>118, 17</value>
</metadata>
<metadata name="bsApples.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="documentInfoListBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>181, 113</value>
</metadata>
<metadata name="ROPrefixBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>238, 17</value>
</metadata>

View File

@ -157,6 +157,43 @@ namespace VEPROMS.CSLA.Library
[Description("HrMn Yr-Mt-Dy")]
HHmm__yyyy_MM_dd
}
//
//}
// Merged Pdfs enums
// Page Numbers
/// <summary>
/// The description is used in the drop down list
/// The enum is the format used for page/of for merged pdfs.
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum MergedPdfsPageOf : int
{
[Description("Page <page> of <of>")]
PageOf = 0,
[Description("Merged Page <page> of <of>")]
MergedPageOf,
[Description("<page>/<of>")]
SlashOnly,
[Description("<set> Page <page> of <of>")]
SetPageOf,
[Description("None")]
None,
[Description("Other")]
Other
}
// Page Number Location
/// <summary>
/// The description is used in the drop down list
/// The enum defines which corner the page number will be printed.
/// </summary>
[TypeConverter(typeof(EnumDescConverter))]
public enum MergedPdfsPageNumCorner : int
{
[Description("Top/Left")]
TopLeft = 0,
[Description("Top/Right")]
TopRight,
[Description("Bottom/Left")]
BottomLeft,
[Description("Bottom/Right")]
BottomRight
}
}

View File

@ -1180,6 +1180,201 @@ namespace VEPROMS.CSLA.Library
}
}
}
#region MergedPdfs
[Category("Print Settings")]
[DisplayName("MergedPdfPageOf")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf Page Number Format")]
public MergedPdfsPageOf Print_MergedPdfsPageOf
{
get
{
string s = _Xp["PrintSettings", "MergedPdfPageOf"];
if (s == string.Empty)
return MergedPdfsPageOf.PageOf;
return (MergedPdfsPageOf)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfPageOf"]; // get the original value to see if a change
MergedPdfsPageOf originalpo = (s==string.Empty)?MergedPdfsPageOf.PageOf:(MergedPdfsPageOf)int.Parse(s);
if (originalpo == value) return; // no change.
_Xp["PrintSettings", "MergedPdfPageOf"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfPageOf");
}
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFormatOther")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Other")]
public string Print_MergedPdfsPageNumFormatOther
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumFormatOther"];
return s;
}
set
{
_Xp["PrintSettings", "MergedPdfsPageNumFormatOther"] = value.ToString();
OnPropertyChanged("Print_MergedPdfsPageNumFormatOther");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFont")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Font")]
public string Print_MergedPdfsPageNumFont
{
get
{
// if this isn't set, then it will be empty. Empty will flag for code that prints page number to use working draft's format's font
string s = _Xp["PrintSettings", "MergedPdfsPageNumFont"];
return s;
}
set
{
if (value == null) return;
string origstr = _Xp["PrintSettings", "MergedPdfsPageNumFont"]; // get the original value to see if a change
if (origstr == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumFont"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumFont");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumFontSize")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Format Font Size")]
public string Print_MergedPdfsPageNumFontSize
{
get
{
// if this isn't set, then it will be empty. Empty will flag for code that prints page number to use working draft's format's font
string s = _Xp["PrintSettings", "MergedPdfsPageNumFontSize"];
return s;
}
set
{
string origstr = _Xp["PrintSettings", "MergedPdfsPageNumFontSize"]; // get the original value to see if a change
if (origstr == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumFontSize"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumFontSize");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumLocX")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Loc X")]
public float? Print_MergedPdfsPageNumLocX
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocX"];
if (s == string.Empty) return 0.5f;
float test = 0;
try
{
test = float.Parse(s);
}
catch (Exception ex)
{
return 0.5f;
}
return float.Parse(s);
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocX"];
float orig = (s == string.Empty) ? 0.5f : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumLocX"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumLocX");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumLocY")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdfs Page Num Loc Y")]
public float? Print_MergedPdfsPageNumLocY
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocY"];
if (s == string.Empty) return 0.5f;
float test = 0;
try
{
test = float.Parse(s);
}
catch (Exception ex)
{
return 0.5f;
}
return float.Parse(s);
}
set
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumLocY"];
float orig = (s == string.Empty) ? 0.5f : float.Parse(s);
if (orig == value) return;
_Xp["PrintSettings", "MergedPdfsPageNumLocY"] = value.ToString();
OnPropertyChanged("MergedPdfsPageNumLocY");
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsPageNumCorner")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf Page Number Corner")]
public MergedPdfsPageNumCorner Print_MergedPdfsPageNumCorner
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumCorner"];
if (s == string.Empty)
return MergedPdfsPageNumCorner.TopRight;
return (MergedPdfsPageNumCorner)int.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfsPageNumCorner"]; // get the original value to see if a change
MergedPdfsPageNumCorner original = (s == string.Empty) ? MergedPdfsPageNumCorner.TopRight : (MergedPdfsPageNumCorner)int.Parse(s);
if (original == value) return; // no change.
_Xp["PrintSettings", "MergedPdfsPageNumCorner"] = ((int)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfsPageNumCorner");
}
}
}
[Category("Print Settings")]
[DisplayName("MergedPdfsViewAfter")]
[RefreshProperties(RefreshProperties.All)]
[Description("Merged Pdf View After Print")]
public bool Print_MergedPdfsViewAfter
{
get
{
string s = _Xp["PrintSettings", "MergedPdfsViewAfter"];
if (s == string.Empty)
return false;
return bool.Parse(s);
}
set
{
if (_SaveChangesToDocVersionConfig)
{
string s = _Xp["PrintSettings", "MergedPdfsViewAfter"]; // get the original value to see if a change
bool original = (s == string.Empty) ? false : bool.Parse(s);
if (original == value) return; // no change.
_Xp["PrintSettings", "MergedPdfsViewAfter"] = ((bool)value).ToString(); // save selected value
OnPropertyChanged("Print_MergedPdfsViewAfter");
}
}
}
#endregion
#endregion
#region Unit // From PROC.INI
//MultiUnitCount

View File

@ -600,6 +600,29 @@ namespace VEPROMS.CSLA.Library
OnPropertyChanged("Print_DisableDuplex");
}
}
[Category("Print Settings")]
[DisplayName("Print All Not In Merge Pdfs")]
[RefreshProperties(RefreshProperties.All)]
[Description("Print All Do Not Include In Merge Pdfs")]
public bool Print_NotInMergeAll
{
get
{
string s = _Xp["PrintSettings", "NotInMergeAll"];
// If there is no parent value, then use the volian default, false. Note that there is no
// parent value for this, it is only defined on the procedure.
if (s == string.Empty) s = "false";
return bool.Parse(s);
}
set
{
string s = _Xp["PrintSettings", "NotInMergeAll"]; // get the original value to see if a change
bool original = (s==string.Empty) ? false : bool.Parse(s);
if (original == value) return;
_Xp["PrintSettings", "NotInMergeAll"] = ((bool)value).ToString(); // save selected value
OnPropertyChanged("Print_NotInMergeAll");
}
}
// Change Bar Use from 16-bit code:
// No Default
// Without Change Bars

View File

@ -0,0 +1,220 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
using VEPROMS.CSLA.Library;
using iTextSharp.text;
using iTextSharp.text.pdf;
using DescriptiveEnum;
using JR.Utils.GUI.Forms;
namespace Volian.Print.Library
{
public class MergedPdfProc
{
private string _Title;
public string Title
{
get { return _Title; } // used for pdf outline
set { _Title = value; }
}
private int _PageCount; // number of pages in the particular pdf, to aid in determining total page count for merged pdf
public int PageCount
{
get { return _PageCount; }
set { _PageCount = value; }
}
private string _PdfFileName; // used for finding the procedure's pdf file to merge
public string PdfFileName
{
get { return _PdfFileName; }
set { _PdfFileName = value; }
}
public MergedPdfProc(string title, string pfname)
{
_Title = title;
_PdfFileName = pfname;
}
}
// this class will manage the data & do subsequent merging of pdf files. It is used if the user
// selects the 'Merge' button off of the print dialog when doing a Print All. (C2019-012)
public class MergedPdf
{
private List<MergedPdfProc> _mergedPdfs = null; // This list has all procedure pdfs that will be included in the merged file.
public List<MergedPdfProc> MergedPdfs
{
get { return _mergedPdfs; }
set { _mergedPdfs = value; }
}
string _mergedFileName = null; // this is the name to be given the merged file
public string MergedFileName
{
get { return _mergedFileName; }
set { _mergedFileName = value; }
}
private string _folder; // this is folder to create the merged file in
public string Folder
{
get { return _folder; }
set { _folder = value; }
}
private DocVersionInfo _docVersionInfo;
private string _pageof = null;
private iTextSharp.text.Font _itextFont = null;
private MergedPdfsPageNumCorner _corner;
private float _xloc = 0;
private float _yloc = 0;
// the following constructs the class that contains data for merging a group of pdfs.
public MergedPdf(string folder, DocVersionInfo dvi)
{
_folder = folder;
_docVersionInfo = dvi;
}
// the following merges the procedure pdfs into a single pdf
public bool DoTheMerge()
{
if (MergedPdfs == null)
{
FlexibleMessageBox.Show("There are no PDFs to merge.", "Merging Pdfs Error", MessageBoxButtons.OK);
return false;
}
iTextSharp.text.Document doc = new iTextSharp.text.Document();
string slashReplace = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SlashReplace ?? "_";
MergedFileName = _folder + @"\" + _docVersionInfo.MyFolder.Name.Replace("/", slashReplace).Replace("\\", slashReplace) + ".pdf";
MergedFileName = ItemInfo.StripRtfFormatting(MergedFileName);
PdfWriter writer = null;
// see if it can be created and if not, see if it is open and tell user:
try
{
writer = PdfWriter.GetInstance(doc, new FileStream(MergedFileName, FileMode.Create));
}
catch (Exception ex)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Could not create");
sb.AppendLine();
sb.AppendLine(MergedFileName + ".");
sb.AppendLine();
sb.AppendLine("If it is open, close and retry.");
FlexibleMessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
if (writer == null) return false;
doc.Open();
PdfContentByte canvas = writer.DirectContent;
int mergedPageNumber = 0; // this is the number that will be used for the <page> token (for <page> of <of>)
int totalPages = 0; // this is the number that will be used for the <of> token (for <page> of <of>)
foreach (MergedPdfProc mpp in MergedPdfs) totalPages += mpp.PageCount;
bool doPageNum = GetPageOfInfo(); // get the format and location of page number - this can be reused for each procedure
// the MergedPdfs contains a list of all of the procedures' pdfs that will be merged into the final pdf
foreach (MergedPdfProc mpp in MergedPdfs)
{
string pdffilename = _folder + @"\" + mpp.PdfFileName;
if (!File.Exists(pdffilename))
{
FlexibleMessageBox.Show("Error in finding pdf files to merge. Cannot print with date/time as part of pdf name. Or check that individual pdfs were generated.", "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return false;
}
PdfReader reader = new PdfReader(_folder + @"\" + mpp.PdfFileName);
int numPages = reader.NumberOfPages;
int currentPageNumber = 0;
PdfOutline outline = null;
do // merging pages into complete...
{
currentPageNumber += 1;
mergedPageNumber += 1;
doc.SetPageSize(PageSize.LETTER);
doc.NewPage();
PdfImportedPage page = writer.GetImportedPage(reader, currentPageNumber); // gets a page that is 'ready' to be written to combined pdf
if (doPageNum) // get the string & fill in with <page> and <of> numbers
{
string outputpageof = _pageof.Replace("<page>", mergedPageNumber.ToString()).Replace("<of>", totalPages.ToString());
AddPageNumberToPage(page, canvas, outputpageof);
}
PdfDestination dest = new PdfDestination(PdfDestination.FIT);
// if on the first page, add the pdfname & title as part of outline. If on remaining pages, just put out page number.
// Later this may need expanded to put sections/steps/etc.
if (currentPageNumber == 1)
outline = new PdfOutline(canvas.RootOutline, dest, mpp.PdfFileName.Replace(".pdf", "")+" - "+mpp.Title, false);
else
new PdfOutline(outline, dest, "Page " + currentPageNumber.ToString(), false);
canvas.AddTemplate(page, 0, 0); // adds the page to the combined pdf
} while (currentPageNumber < numPages);
}
doc.Close();
return true;
}
// this method adds the page number to the page before it is merged in. It determines the position from the properties
// that were set on the doc version properties dialog (these values were set as local class variables from GetPageOfInfo)
private void AddPageNumberToPage(PdfImportedPage page, PdfContentByte cb, string outputpage)
{
float pgright = page.BoundingBox.Right;
float pgleft = page.BoundingBox.Left;
float pgtop = page.BoundingBox.Top;
float pgbot = page.BoundingBox.Bottom;
Phrase ph = new Phrase();
Chunk chk = new Chunk(outputpage, _itextFont);
ph.Add(chk);
Paragraph pg = new Paragraph(ph);
ColumnText columnText = new ColumnText(cb);
switch (_corner)
{
case MergedPdfsPageNumCorner.TopRight:
columnText.Alignment = Element.ALIGN_RIGHT;
columnText.SetSimpleColumn(0, pgtop - _yloc, pgright - _xloc, 0);
break;
case MergedPdfsPageNumCorner.BottomRight:
columnText.Alignment = Element.ALIGN_RIGHT;
columnText.SetSimpleColumn(0, _yloc, pgright - _xloc, 0);
break;
case MergedPdfsPageNumCorner.TopLeft:
columnText.SetSimpleColumn(_xloc, pgtop - _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
break;
case MergedPdfsPageNumCorner.BottomLeft:
columnText.SetSimpleColumn(_xloc, _yloc, pgright, 0); // page alignment defaults to ALIGN_LEFT
break;
}
columnText.AddText(pg);
columnText.Go();
}
// this method gets the format, font & location data from the doc version properties that are stored on the doc version's
// config field. It saves them as local class variables to be used in other places in this class.
private bool GetPageOfInfo()
{
DocVersionConfig dvc = (DocVersionConfig) _docVersionInfo.MyConfig;
MergedPdfsPageOf po = dvc.Print_MergedPdfsPageOf;
string tmp = EnumDescConverter.GetEnumDescription((Enum)dvc.Print_MergedPdfsPageOf);
if (tmp == "None") return false; // no page number, return false so no page number is put out.
// If 'Other' for the format, use text in textbox to format the <page> of <of> string, note that <page> and <of> are
// resolved when adding pages to the merge document. The only other 'token' that is supported is '<set>'
if (tmp == "Other") tmp = dvc.Print_MergedPdfsPageNumFormatOther;
_pageof = tmp.Replace("<set>", _docVersionInfo.MyFolder.Name);
// If font data is not supplied, use the default from the format for this working draft
string famtmp = dvc.Print_MergedPdfsPageNumFont;
if (famtmp == null || famtmp == "")
{
famtmp = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Family;
}
tmp = dvc.Print_MergedPdfsPageNumFontSize;
float? tmpi=0;
if (tmp == null || tmp == "")
{
// use the default from the format from this working draft
tmpi = _docVersionInfo.ActiveFormat.PlantFormat.FormatData.Font.Size;
}
else
tmpi = int.Parse(tmp);
// set local values of variables to be used in various other methods in this class.
_itextFont = Volian.Svg.Library.Svg.GetFont(famtmp, (float)tmpi, 0, System.Drawing.Color.Black);
_xloc = (float)dvc.Print_MergedPdfsPageNumLocX * 72;
_yloc = (float)dvc.Print_MergedPdfsPageNumLocY * 72;
_corner = dvc.Print_MergedPdfsPageNumCorner;
return true;
}
}
}

View File

@ -259,9 +259,22 @@ namespace Volian.Print.Library
get { return _BlankPageText; }
set { _BlankPageText = value; }
}
// use DidAll & MergeNotIncuded to know that printing all (not single) was done. Used w/ merge code to know when to return, i.e. not include in merged pdf
private bool _DidAll;
public bool DidAll // value passed in from frmPdfStatusForm
{
get { return _DidAll; }
set { _DidAll = value; }
}
private bool _MergeNotIncluded;
public bool MergeNotIncluded
{
get { return _MergeNotIncluded; }
set { _MergeNotIncluded = 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)
ChangeBarDefinition cbd, String pdfFile, bool insertBlankPages, bool batchPrint, string prefix, bool saveLinks, bool removeTrailngHardReturnsAndManualPageBreaks, string blankPageText, bool didAll)
{
Prefix = prefix; // RHM20150506 Multiline ItemID TextBox
_MyItem = myItem;
@ -280,6 +293,8 @@ namespace Volian.Print.Library
_SaveLinks = saveLinks;
_RemoveTrailingHardReturnsAndManualPageBreaks = removeTrailngHardReturnsAndManualPageBreaks;
_BlankPageText = blankPageText;
_DidAll = didAll;
_MergeNotIncluded = false;
//_MyReaderHelper.LoadTree(myItem);
}
// Pass 1 PDF Name
@ -299,7 +314,14 @@ namespace Volian.Print.Library
public string Print(string pdfFolder, bool makePlacekeeper, bool makeContinuousActionSummary)
{
if (_MyItem is ProcedureInfo)
{ // B2017-186 First do Procedures that don't have page number transitions
{
ProcedureConfig pcfg = (ProcedureConfig)(_MyItem as ProcedureInfo).MyConfig;
if (DidAll && pcfg.Print_NotInMergeAll) // will be merging a pdf, so don't print this procedure if user set that on procedure propertures
{
_MergeNotIncluded = true;
return null;
}
// B2017-186 First do Procedures that don't have page number transitions
if (!(_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseTransitionModifier ||
_MyItem.ActiveFormat.PlantFormat.FormatData.TransData.UseSpecificTransitionModifier))
{
@ -446,11 +468,13 @@ namespace Volian.Print.Library
_PROMSVersionLayer.SetPrint("PROMS Version", true);
}
}
public static int ProcPageCount = -1; // Used to count page numbers in each pdf. This will be used if/when pdfs are merged together.
private void CloseDocument(string fileName)
{
int profileDepth = ProfileTimer.Push(">>>> CloseDocument");
try
{
ProcPageCount = MyContentByte.PdfWriter.CurrentPageNumber - 1;
MyContentByte.PdfDocument.Close();
MyContentByte = null;
}