Changed NextItem property to use GetNextItem method when printing
Added Profile debug Added Command-line parameters (/X= and /Y=) to specify the offset used for Compare. Changed NextItem property to use GetNextItem method when printing. Remove PrintTimer which has been replaced with ProfileTimer Added Profile debug Added code to handle special characters when printing, Added Profile debug Changed NextItem property to use GetNextItem method when printing
This commit is contained in:
@@ -275,6 +275,7 @@ namespace Volian.Print.Library
|
||||
|
||||
private void CloseDocument(PdfContentByte cb, string fileName)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> CloseDocument");
|
||||
try
|
||||
{
|
||||
cb.PdfDocument.Close();
|
||||
@@ -287,6 +288,7 @@ namespace Volian.Print.Library
|
||||
if (OpenPDF)
|
||||
System.Diagnostics.Process.Start(fileName);
|
||||
OnStatusChanged("OpenPDF", PromsPrinterStatusType.OpenPDF);
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
|
||||
private PdfContentByte OpenDoc(string outputFileName)
|
||||
@@ -352,6 +354,7 @@ namespace Volian.Print.Library
|
||||
private static List<SectionInfo> _MyFoldoutSection = null;
|
||||
private string Print(ProcedureInfo myProcedure, string pdfFolder, bool makePlacekeeper)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> PromsPrinter.Print");
|
||||
if (_TransPageNumProblems == null) _TransPageNumProblems = new List<string>();
|
||||
|
||||
if (_MyFoldoutReader != null) _MyFoldoutReader.Clear();
|
||||
@@ -383,9 +386,14 @@ namespace Volian.Print.Library
|
||||
if (!OverWrite && File.Exists(outputFileName))
|
||||
{
|
||||
if (MessageBox.Show(outputFileName + " exists. Overwrite file?", "File Exists", MessageBoxButtons.YesNo) == DialogResult.No)
|
||||
{
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return PrintProcedureOrFoldout(myProcedure, null, outputFileName, makePlacekeeper);
|
||||
string retval = PrintProcedureOrFoldout(myProcedure, null, outputFileName, makePlacekeeper);
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return retval;
|
||||
}
|
||||
|
||||
// See if the last non Foldout Section has a Final Message.
|
||||
@@ -419,6 +427,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, SectionInfo myFoldoutSection, string outputFileName, bool makePlacekeeper)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> PrintProcedureOrFoldout");
|
||||
Rtf2Pdf.TextAtCounter = 0;
|
||||
bool doingFoldout = myFoldoutSection != null;
|
||||
// The following line accounts for 16bit OverrideLeftMargin when the 'Absolute' attribute is used in the genmac.
|
||||
@@ -447,7 +456,7 @@ namespace Volian.Print.Library
|
||||
foreach (SectionInfo mySection in myProcedure.Sections)
|
||||
{
|
||||
if (((mySection.MyContent.Number.ToUpper() == "FOLDOUT" && myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.SectionLevelFoldouts)
|
||||
|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && mySection.MyContent.Text.ToUpper().Contains("FOLDOUT")))
|
||||
|| (myProcedure.ActiveFormat.PlantFormat.FormatData.PrintData.AlternateFloatingFoldout && mySection.MyContent.Text.ToUpper().Contains("FOLDOUT")))
|
||||
!= doingFoldout) continue;
|
||||
if (myFoldoutSection != null && myFoldoutSection.ItemID != mySection.ItemID) continue;
|
||||
PrintOverride.CompressSuper = mySection.ActiveFormat.PlantFormat.FormatData.SectData.StepSectionData.CompressHPSuper;
|
||||
@@ -485,10 +494,16 @@ namespace Volian.Print.Library
|
||||
// X argument below: accounts for 16-bit pdf OverrideLeftMargin = -2 characters at the plant format's default Font's
|
||||
// characters per inch.
|
||||
// 16bit OverrideLeftMargin, defined as -2 in driver\drvin.rtf, - override took 2 characters out, so we're adding it back in:
|
||||
if (mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS) // compare folder contains PROMS generated PDF
|
||||
_MyHelper.BackgroundOffset = new PointF(0, 0);
|
||||
else
|
||||
_MyHelper.BackgroundOffset = new PointF(2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI, -9.5F);
|
||||
float x = 0;
|
||||
float y = 0;
|
||||
if (!(mySection.ActiveFormat.Name.ToUpper().StartsWith("WST") || _MyHelper.Back32BitPROMS)) // compare folder contains PROMS generated PDF
|
||||
{
|
||||
x = 2 * 72F / (float)myProcedure.ActiveFormat.PlantFormat.FormatData.Font.CPI;
|
||||
y = -9.5F;
|
||||
}
|
||||
x += 72F * VlnSettings.GetCommandFloat("X", x);
|
||||
y -= 72F * VlnSettings.GetCommandFloat("Y", y);
|
||||
_MyHelper.BackgroundOffset = new PointF(x,y);
|
||||
_MyHelper.BackgroundPageOffset = 0;
|
||||
}
|
||||
_MyHelper.WatermarkLayer = _WatermarkLayer;
|
||||
@@ -555,12 +570,12 @@ namespace Volian.Print.Library
|
||||
PdfReader readerWord = null;
|
||||
string myPdfFile = null;
|
||||
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
||||
|
||||
|
||||
if (mySection.IsAutoTOCSection)
|
||||
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
||||
// is this the right place for PlaceKeeper?
|
||||
// I think we need to check if the actual PlaceKeeper section has the PlaceKeeper flag set (for auto generation)
|
||||
// users can turn this off and edit the section manaully in 16-bit.
|
||||
// is this the right place for PlaceKeeper?
|
||||
// I think we need to check if the actual PlaceKeeper section has the PlaceKeeper flag set (for auto generation)
|
||||
// users can turn this off and edit the section manaully in 16-bit.
|
||||
//else if (mySection.IsPlacekeeperSection)
|
||||
// GeneratePlaceKeeper(mySection, myProcedure, cb, _TextLayer);
|
||||
else
|
||||
@@ -590,7 +605,9 @@ namespace Volian.Print.Library
|
||||
CreateStepPdf(mySection, cb);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateWordDocPdf(cb, mySection, ref readerWord, ref myPdfFile);
|
||||
}
|
||||
}
|
||||
_MyHelper.PrintedSectionPage = 0;
|
||||
}
|
||||
@@ -612,7 +629,7 @@ namespace Volian.Print.Library
|
||||
if (_MyHelper != null && makePlacekeeper)
|
||||
{
|
||||
// Setting the default font to Arial since that is what Calvert is currently using for their Placekeeper pages
|
||||
VE_Font pkFont = new VE_Font("Arial",11,E_Style.None,12); // default font info.
|
||||
VE_Font pkFont = new VE_Font("Arial", 11, E_Style.None, 12); // default font info.
|
||||
// Ideally, we should grab the font from the DocStyle used for the Placekeeper.
|
||||
// Note that Calvert has two Placekeeper docSyles (EOPs and AOPs) in the same format.
|
||||
// Both Placekeeper DocStyles use Arial 11 pt font, so there is no need to grab it from the format file.
|
||||
@@ -625,11 +642,13 @@ namespace Volian.Print.Library
|
||||
new Placekeeper(_MyHelper.MyPlacekeepers, pkFont);
|
||||
}
|
||||
_MyHelper = null;
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
return outputFileName;
|
||||
}
|
||||
|
||||
public void CreateWordDocPdf(PdfContentByte cb, SectionInfo mySection, ref PdfReader readerWord, ref string myPdfFile)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> CreateWordDocPdf");
|
||||
_MyHelper.MySection = mySection;
|
||||
myPdfFile = BuildMSWordPDF(mySection);
|
||||
try
|
||||
@@ -705,7 +724,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
float yoff = 0;
|
||||
if (_MyHelper.DidFirstPageDocStyle) yoff = origYoff - (float)mySection.MyDocStyle.Layout.TopMargin;
|
||||
AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, (float)(mySection.MyDocStyle.Layout.MSWordXAdj??0), (float)(mySection.MyDocStyle.Layout.MSWordYAdj??0)+yoff);
|
||||
AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, (float)(mySection.MyDocStyle.Layout.MSWordXAdj ?? 0), (float)(mySection.MyDocStyle.Layout.MSWordYAdj ?? 0) + yoff);
|
||||
if(DebugPagination.IsOpen) DebugPagination.WriteLine("{0:D6},'{1}',{2}",
|
||||
_MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, mySection.ShortPath,pageNumber);
|
||||
|
||||
@@ -774,6 +793,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
_MyHelper.IsLandscape = false; // reset landscape mode to false
|
||||
}
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer)
|
||||
{
|
||||
@@ -783,7 +803,8 @@ namespace Volian.Print.Library
|
||||
float yBottomMargin = Math.Max(0, yTopMargin - (float)tocSection.MyDocStyle.Layout.PageLength); // - 2 * vlnPrintObject.SixLinesPerInch);
|
||||
if (textLayer != null) cb.BeginLayer(textLayer);
|
||||
TableOfContentsData tOfC = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData;
|
||||
ItemInfo procItem = ItemInfo.Get(myProcedure.ItemID);
|
||||
//ItemInfo procItem = ItemInfo.Get(myProcedure.ItemID);
|
||||
ItemInfo procItem = myProcedure;
|
||||
lastyLocation = 0;
|
||||
AddSectionToTOC(tocSection, procItem, tOfC, cb, yTopMargin, 0);
|
||||
if (textLayer != null) cb.EndLayer();
|
||||
@@ -1179,6 +1200,8 @@ namespace Volian.Print.Library
|
||||
private float _NoBreakYPageStart = 0;
|
||||
private void CreateStepPdf(SectionInfo section, PdfContentByte cb)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> CreateStepPdf");
|
||||
//PrintTimer pt = new PrintTimer();
|
||||
iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter;
|
||||
ItemInfo myItemInfo = section as ItemInfo;
|
||||
// 792: 72 * 11 inches - TopRow - Top is high value
|
||||
@@ -1187,7 +1210,7 @@ namespace Volian.Print.Library
|
||||
// the following line was modified to comment out the - 2 * SixLinesPerInch. this fixed a pagination problem with WCN EMG E-3.
|
||||
float yBottomMargin = Math.Max(0, yTopMargin - (float)myItemInfo.MyDocStyle.Layout.PageLength); // - 2 * vlnPrintObject.SixLinesPerInch);
|
||||
vlnParagraph.PathPrefix = myItemInfo.Path;
|
||||
Rtf2Pdf.PdfDebug = true;
|
||||
//Rtf2Pdf.PdfDebug = true;
|
||||
Rtf2Pdf.Offset = new PointF(0, 2.5F);
|
||||
if (section.MyDocStyle.LandscapePageList)
|
||||
{
|
||||
@@ -1200,7 +1223,9 @@ namespace Volian.Print.Library
|
||||
else
|
||||
_MyHelper.IsLandscape = false;
|
||||
_MyHelper.ChangeBarDefinition = MyChangeBarDefinition;
|
||||
//pt.Description = "vlnParagrph";
|
||||
vlnParagraph myParagraph = new vlnParagraph(null, cb, myItemInfo, (float)myItemInfo.MyDocStyle.Layout.LeftMargin, _NoBreakYOffset, 0, myItemInfo.ColumnMode, myItemInfo.ActiveFormat, null, null, 0,true,this);
|
||||
//pt.Description = "After vlnParagrph";
|
||||
float localYPageStart = 0;
|
||||
float yPageStart = yTopMargin;
|
||||
if (myItemInfo.HasChildren || myItemInfo.MyDocVersion.DocVersionConfig.SelectedSlave > 0)
|
||||
@@ -1212,7 +1237,7 @@ namespace Volian.Print.Library
|
||||
else if (!myItemInfo.MyDocStyle.OptionalSectionContent)
|
||||
PrintTextMessage(cb, "No Section Content", _TextLayer);
|
||||
SectionConfig.SectionPagination sp = SectionConfig.SectionPagination.Separate; // always the default
|
||||
ItemInfo nxtItem = section.GetNextItem();
|
||||
ItemInfo nxtItem = section.NextItem;
|
||||
if (nxtItem != null)
|
||||
{
|
||||
// if this section & the next section are not accessory pages, see if there is continuous pagination,
|
||||
@@ -1259,8 +1284,9 @@ namespace Volian.Print.Library
|
||||
yPageStart = localYPageStart;
|
||||
Volian.Base.Library.DebugText.WriteLine("NOBREAK:{0},'{1}','{2}','{3}','{4}','{5}'", section.ItemID, tmplocal, yTopMargin, localYPageStart, _NoBreakYOffset, myParagraph.YBottomMost);
|
||||
}
|
||||
|
||||
OnStatusChanged("StepSection converted to PDF " + section.ShortPath, PromsPrinterStatusType.BuildStep);
|
||||
//pt.Description = "End";
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
public static void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer)
|
||||
{
|
||||
@@ -1356,4 +1382,32 @@ namespace Volian.Print.Library
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
//public class PrintTimer
|
||||
//{
|
||||
// private DateTime _StartTime = DateTime.Now;
|
||||
|
||||
// public DateTime StartTime
|
||||
// {
|
||||
// get { return _StartTime; }
|
||||
// set { _StartTime = value; }
|
||||
// }
|
||||
// private string _Description = "Start";
|
||||
// public string Description
|
||||
// {
|
||||
// get { return _Description; }
|
||||
// set
|
||||
// {
|
||||
// DateTime dtNext = DateTime.Now;
|
||||
// //Console.WriteLine("{0},'{1}'", TimeSpan.FromTicks(dtNext.Ticks - LastTime.Ticks).TotalSeconds, Description);
|
||||
// _Description = value;
|
||||
// _LastTime = dtNext;
|
||||
// }
|
||||
// }
|
||||
// private DateTime _LastTime = DateTime.Now;
|
||||
// public DateTime LastTime
|
||||
// {
|
||||
// get { return _LastTime; }
|
||||
// set { _LastTime = value; }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
Reference in New Issue
Block a user