C2019-012: Merge pdfs
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user