From b41320ed244694b46b2d001f9b02d9ac11ffdcdb Mon Sep 17 00:00:00 2001 From: John Date: Fri, 14 Feb 2020 17:16:28 +0000 Subject: [PATCH] C2020-002 Logic to use either the Letter or A4 paper size --- .../Volian.Controls.Library/DisplayLibDocs.cs | 15 +++++++++-- .../Volian.Controls.Library/DisplayReports.cs | 27 ++++++++++++++----- .../Volian.Controls.Library/DisplaySearch.cs | 13 +++++++++ PROMS/Volian.Print.Library/CompleteRORpt.cs | 1 - PROMS/Volian.Print.Library/MergedPdf.cs | 3 ++- .../PDFChronologyReport.cs | 6 +++-- .../PDFConsistencyCheckReport.cs | 6 +++-- PROMS/Volian.Print.Library/PDFReport.cs | 19 ++++++++----- .../PDFTransitionReport.cs | 7 ++++- PROMS/Volian.Print.Library/Pagination.cs | 3 +-- PROMS/Volian.Print.Library/PromsPrinter.cs | 15 ++++++----- PROMS/Volian.Print.Library/Rtf2Pdf.cs | 23 ++++++++++++---- .../Volian.Print.Library/VlnSvgPageHelper.cs | 6 ++--- PROMS/Volian.Print.Library/vlnParagraph.cs | 9 +++---- PROMS/Volian.Print.Library/vlnPrintObject.cs | 5 ++-- 15 files changed, 111 insertions(+), 47 deletions(-) diff --git a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs index 863e3267..352e7b5c 100644 --- a/PROMS/Volian.Controls.Library/DisplayLibDocs.cs +++ b/PROMS/Volian.Controls.Library/DisplayLibDocs.cs @@ -303,7 +303,9 @@ namespace Volian.Controls.Library private void btnPrint_Click(object sender, EventArgs e) { - OnPrintRequest(new DisplayLibDocEventArgs("Library Document Usage", LibDocList)); + string paperSize = "Letter"; + paperSize = LibDocList[listBoxLibDocs.SelectedIndex].LibraryDocumentUsageList[0].ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files + OnPrintRequest(new DisplayLibDocEventArgs("Library Document Usage", LibDocList, paperSize)); } } public class DisplayLibDocEventArgs @@ -321,6 +323,14 @@ namespace Volian.Controls.Library get { return _libDocList; } set { _libDocList = value; } } + + private string _PaperSize; // C2020-002 paper size is now set in the format files + + public string PaperSize + { + get { return _PaperSize; } + set { _PaperSize = value; } + } //private string _SearchString = null; //public string SearchString //{ @@ -339,10 +349,11 @@ namespace Volian.Controls.Library // get { return _MyItemInfoList; } // set { _MyItemInfoList = value; } //} - public DisplayLibDocEventArgs(string reportTitle, DocumentInfoList libDocList) + public DisplayLibDocEventArgs(string reportTitle, DocumentInfoList libDocList, string paperSize) { _ReportTitle = reportTitle; _libDocList = libDocList; + _PaperSize = paperSize; // C2020-002 paper size is now set in the format files } } public delegate void DisplayLibDocEvent(object sender, DisplayLibDocEventArgs args); diff --git a/PROMS/Volian.Controls.Library/DisplayReports.cs b/PROMS/Volian.Controls.Library/DisplayReports.cs index fae06977..11ddb9b4 100644 --- a/PROMS/Volian.Controls.Library/DisplayReports.cs +++ b/PROMS/Volian.Controls.Library/DisplayReports.cs @@ -954,6 +954,9 @@ namespace Volian.Controls.Library } private void btnPrintReport_Click(object sender, EventArgs e) { + string paperSize = "Letter"; + if (Mydocversion != null && Mydocversion.ActiveFormat != null) + paperSize = Mydocversion.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files //B2019-144 Set the document text color to Red (overlay) or Black (normal) Color lastColor = MSWordToPDF.OverrideColor;// B2019-144 Remember override color if (MSWordToPDF.OverrideColor != Color.Black) @@ -966,7 +969,7 @@ namespace Volian.Controls.Library GenerateAccIDSortedROList(); else GenerateROList(); - OnPrintRequest(new DisplayReportsEventArgs("RO Summary Report", "RO Summary Report", MyROFSTLookup, ROList)); + OnPrintRequest(new DisplayReportsEventArgs("RO Summary Report", "RO Summary Report", MyROFSTLookup, ROList, paperSize)); } else if (cbxComplete.Checked) // Complete RO Report { @@ -976,7 +979,8 @@ namespace Volian.Controls.Library GenerateROList(); string ROList = GetListOfROs(false);//don't include the RODbID in the RO list string roDataFile = BuildRODataFile(ROList); - OnPrintRequest(new DisplayReportsEventArgs("Complete RO Report", "Complete RO Report", roDataFile, MyROFSTLookup, cbxComplete.Checked, this.Mydocversion.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, cbxIncldMissingROs.Checked)); + if (Mydocversion != null) + OnPrintRequest(new DisplayReportsEventArgs("Complete RO Report", "Complete RO Report", roDataFile, MyROFSTLookup, cbxComplete.Checked, Mydocversion.ActiveFormat.PlantFormat.FormatData.SectData.ConvertCaretToDelta, cbxIncldMissingROs.Checked, paperSize)); } else if (cbxROUsage.Checked) { @@ -988,10 +992,10 @@ namespace Volian.Controls.Library { Csla.SortedBindingList sortedResults = new Csla.SortedBindingList(SearchResults); sortedResults.ApplySort("FoundROID", ListSortDirection.Ascending); - OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By RO", "RO Usage", sortedResults, usageSortedByProcedure, cbxIncldMissingROs.Checked)); + OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By RO", "RO Usage", sortedResults, usageSortedByProcedure, cbxIncldMissingROs.Checked, paperSize)); } else - OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By Procedure", "RO Usage", SearchResults, usageSortedByProcedure, cbxIncldMissingROs.Checked)); + OnPrintRequest(new DisplayReportsEventArgs("Referenced Objects Usage By Procedure", "RO Usage", SearchResults, usageSortedByProcedure, cbxIncldMissingROs.Checked, paperSize)); } else if (cbxTransFromProcs.Checked) { @@ -1079,7 +1083,13 @@ namespace Volian.Controls.Library get { return _IncludeEmptyROFields; } set { _IncludeEmptyROFields = value; } } - public DisplayReportsEventArgs(string reportTitle, string typesSelected, ICollection myItemInfoList, bool sortByProcedure, bool includeMissingROs) + private string _PaperSize = "Letter"; + public string PaperSize // C2020-002 paper size is now set in the format files + { + get { return _PaperSize; } + set { _PaperSize = value; } + } + public DisplayReportsEventArgs(string reportTitle, string typesSelected, ICollection myItemInfoList, bool sortByProcedure, bool includeMissingROs, string paperSize) { // RO Usage Report _ReportTitle = reportTitle; @@ -1087,9 +1097,10 @@ namespace Volian.Controls.Library _MyItemInfoList = myItemInfoList; _SortUsageByProcedure = sortByProcedure; _IncludeMissingROs = includeMissingROs; + _PaperSize = paperSize; // C2020-002 paper size is now set in the format files } - public DisplayReportsEventArgs(string reportTitle, string typesSelected, string roDataFile, ROFSTLookup rofstLookUp, bool completeROReport, bool convertCaretToDelta, bool includeEmptyROFields) + public DisplayReportsEventArgs(string reportTitle, string typesSelected, string roDataFile, ROFSTLookup rofstLookUp, bool completeROReport, bool convertCaretToDelta, bool includeEmptyROFields, string paperSize) { _ReportTitle = reportTitle; _TypesSelected = typesSelected; @@ -1098,14 +1109,16 @@ namespace Volian.Controls.Library _ConvertCaretToDelta = convertCaretToDelta; _rofstLookup = rofstLookUp; _IncludeEmptyROFields = includeEmptyROFields; + _PaperSize = paperSize; // C2020-002 paper size is now set in the format files } - public DisplayReportsEventArgs(string reportTitle, string typesSelected, ROFSTLookup rofstLookUp, List roListForReport) + public DisplayReportsEventArgs(string reportTitle, string typesSelected, ROFSTLookup rofstLookUp, List roListForReport, string paperSize) { // RO Summary Report _ReportTitle = reportTitle; _TypesSelected = typesSelected; _rofstLookup = rofstLookUp; _ROListForReport = roListForReport; + _PaperSize = paperSize; // C2020-002 paper size is now set in the format files } } public delegate void DisplayReportsEvent(object sender, DisplayReportsEventArgs args); diff --git a/PROMS/Volian.Controls.Library/DisplaySearch.cs b/PROMS/Volian.Controls.Library/DisplaySearch.cs index 89794528..915311b8 100644 --- a/PROMS/Volian.Controls.Library/DisplaySearch.cs +++ b/PROMS/Volian.Controls.Library/DisplaySearch.cs @@ -2413,6 +2413,13 @@ namespace Volian.Controls.Library get { return _HowLong; } set { _HowLong = value; } } + private string _PaperSize; + + public string PaperSize // C2020-002 paper size is now set in the format files + { + get { return _PaperSize; } + set { _PaperSize = value; } + } public DisplaySearchEventArgs(TimeSpan howLong) { HowLong = howLong; @@ -2423,6 +2430,12 @@ namespace Volian.Controls.Library _TypesSelected = typesSelected; _MyItemInfoList = myItemInfoList; _SearchString = searchString; + foreach (ItemInfo tmpII in myItemInfoList) + if (tmpII != null && tmpII.ActiveFormat != null) + { + _PaperSize = tmpII.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files + break; + } } } public delegate void DisplaySearchEvent(object sender, DisplaySearchEventArgs args); diff --git a/PROMS/Volian.Print.Library/CompleteRORpt.cs b/PROMS/Volian.Print.Library/CompleteRORpt.cs index bb8768ca..f43a37e1 100644 --- a/PROMS/Volian.Print.Library/CompleteRORpt.cs +++ b/PROMS/Volian.Print.Library/CompleteRORpt.cs @@ -742,7 +742,6 @@ namespace Volian.Print.Library AddText(Hdrs.strHdrs[iLoop].Replace("__"," "), F12Bold); // should be bold and first header is centered } } - static float _Top = 792; public PdfDestination MyPdfDestTop { get diff --git a/PROMS/Volian.Print.Library/MergedPdf.cs b/PROMS/Volian.Print.Library/MergedPdf.cs index 1ff8d780..d549ba4c 100644 --- a/PROMS/Volian.Print.Library/MergedPdf.cs +++ b/PROMS/Volian.Print.Library/MergedPdf.cs @@ -124,11 +124,12 @@ namespace Volian.Print.Library int numPages = reader.NumberOfPages; int currentPageNumber = 0; PdfOutline outline = null; + Rectangle paperSize = PDFPageSize.UsePaperSize(_docVersionInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files do // merging pages into complete... { currentPageNumber += 1; mergedPageNumber += 1; - doc.SetPageSize(PageSize.LETTER); + doc.SetPageSize(paperSize); 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 and numbers diff --git a/PROMS/Volian.Print.Library/PDFChronologyReport.cs b/PROMS/Volian.Print.Library/PDFChronologyReport.cs index 303c5cab..2aefd200 100644 --- a/PROMS/Volian.Print.Library/PDFChronologyReport.cs +++ b/PROMS/Volian.Print.Library/PDFChronologyReport.cs @@ -59,7 +59,8 @@ namespace Volian.Print.Library } public void BuildChronology() { - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + Rectangle paperSize = PDFPageSize.UsePaperSize(MyProc.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize);// C2020-002 paper size is now set in the format files + iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize, 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { @@ -92,7 +93,8 @@ namespace Volian.Print.Library public void BuildSummary(bool openReport) { bool hasData = false; - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + Rectangle paperSize = PDFPageSize.UsePaperSize(MyProc.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files + iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize, 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { diff --git a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs index 3d20c929..e04b344d 100644 --- a/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs +++ b/PROMS/Volian.Print.Library/PDFConsistencyCheckReport.cs @@ -37,7 +37,8 @@ namespace Volian.Print.Library } public void BuildReport() { - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + Rectangle paperSize = PDFPageSize.UsePaperSize(MyDocVersion.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files + iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize, 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { @@ -225,7 +226,8 @@ namespace Volian.Print.Library public void BuildAllReport(DocVersionInfo dvi) { MyDocVersion = dvi; - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + Rectangle paperSize = PDFPageSize.UsePaperSize(MyDocVersion.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files + iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize, 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { diff --git a/PROMS/Volian.Print.Library/PDFReport.cs b/PROMS/Volian.Print.Library/PDFReport.cs index fc614106..3887144b 100644 --- a/PROMS/Volian.Print.Library/PDFReport.cs +++ b/PROMS/Volian.Print.Library/PDFReport.cs @@ -75,8 +75,9 @@ namespace Volian.Print.Library private bool _ConvertCaretToDelta = true; private bool _IncludeEmptyROFields = false; + private string _PaperSize = "Letter"; // C2020-002 paper size is now set in the format files // Search Results Report - public PDFReport(string reportTitle, string typesSelected, ICollection resultList, string fileName) + public PDFReport(string reportTitle, string typesSelected, ICollection resultList, string fileName, string paperSize) { _ResultList = resultList; _FileName = fileName; @@ -84,21 +85,23 @@ namespace Volian.Print.Library _TypesSelected = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(typesSelected); _ReportType = (int)ReportType.SearchResults; _ByLine = "PROMS Search Results"; + _PaperSize = paperSize; } // Library Document Report - public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName) + public PDFReport(string reportTitle, DocumentInfoList libDocList, string fileName, string paperSize) { _LibDocList = libDocList; _FileName = fileName; _ReportTitle = VEPROMS.CSLA.Library.ItemInfo.ConvertToDisplayText(reportTitle); _ReportType = (int)ReportType.LibraryDocUsage; _ByLine = "Generated By PROMS"; + _PaperSize = paperSize; } // RO Usage - public PDFReport(string reportTitle, ICollection resultList, string fileName, bool sortUsageByProcedure, bool includeMissingROs) + public PDFReport(string reportTitle, ICollection resultList, string fileName, bool sortUsageByProcedure, bool includeMissingROs, string paperSize) { _ResultList = resultList; _FileName = fileName; @@ -107,10 +110,11 @@ namespace Volian.Print.Library _ByLine = "Generated By PROMS"; _SortUsageByProcedure = sortUsageByProcedure; _IncludeMissingROs = includeMissingROs; + _PaperSize = paperSize; } // RO Complete RO Report - public PDFReport(string reportTitle, string roDataFile, string outfile, ROFSTLookup fstlookup, bool completeReport, bool convertCaretToDelta, bool includeEmptyROFields) + public PDFReport(string reportTitle, string roDataFile, string outfile, ROFSTLookup fstlookup, bool completeReport, bool convertCaretToDelta, bool includeEmptyROFields, string paperSize) { _FileName = outfile; _ReportTitle = reportTitle; @@ -120,10 +124,11 @@ namespace Volian.Print.Library _ConvertCaretToDelta = convertCaretToDelta; _ROFSTLookup = fstlookup; _IncludeEmptyROFields = includeEmptyROFields; + _PaperSize = paperSize; } // RO Summary Report - public PDFReport(string reportTitle, string outfile, ROFSTLookup fstlookup, List roList) + public PDFReport(string reportTitle, string outfile, ROFSTLookup fstlookup, List roList, string paperSize) { _FileName = outfile; _ReportTitle = reportTitle; @@ -131,6 +136,7 @@ namespace Volian.Print.Library _ByLine = "RO Summary Report"; _ROFSTLookup = fstlookup; _ROList = roList; + _PaperSize = paperSize; } private string AddGroup(PdfPTable datatable, string dvPath, string lastDvPath, Font f2, bool StripLast, Color bgColor, bool skipFirst) @@ -365,7 +371,8 @@ namespace Volian.Print.Library } public void Build() { - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + //iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36); + iTextSharp.text.Document document = new iTextSharp.text.Document(PDFPageSize.UsePaperSize(_PaperSize), 36, 36, 36, 36); // C2020-002 paper size is now set in the format files if (!CreateResultsPDF(document, _ReportType)) return; try { diff --git a/PROMS/Volian.Print.Library/PDFTransitionReport.cs b/PROMS/Volian.Print.Library/PDFTransitionReport.cs index 9a08be2d..fe283a83 100644 --- a/PROMS/Volian.Print.Library/PDFTransitionReport.cs +++ b/PROMS/Volian.Print.Library/PDFTransitionReport.cs @@ -72,10 +72,13 @@ namespace Volian.Print.Library get { return _ProcedureCount; } set { _ProcedureCount = value; } } + private string _PaperSize = "Letter"; public PDFTransitionReport(FolderInfo fi, string fileName) { _FileName = fileName; folderInfo = fi; + if (fi.ActiveFormat != null) + _PaperSize = fi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files } public PDFTransitionReport(ProcedureInfo pi, string fileName) { @@ -83,10 +86,12 @@ namespace Volian.Print.Library procedureInfo = pi; transitionInfoList = TransitionInfoList.GetTransitionReportData(procedureInfo.MyDocVersion.VersionID, procedureInfo.ItemID); _TransitionInfoCount = transitionInfoList.Count; + _PaperSize = pi.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize; // C2020-002 paper size is now set in the format files } public void BuildTransitionReport() { - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER.Rotate(), 36, 36, 36, 36); + Rectangle paperSize = PDFPageSize.UsePaperSize(_PaperSize); // C2020-002 paper size is now set in the format files + iTextSharp.text.Document document = new iTextSharp.text.Document(paperSize.Rotate(), 36, 36, 36, 36); if (!CreateResultsPDF(document)) return; try { diff --git a/PROMS/Volian.Print.Library/Pagination.cs b/PROMS/Volian.Print.Library/Pagination.cs index 0c925460..08abccd4 100644 --- a/PROMS/Volian.Print.Library/Pagination.cs +++ b/PROMS/Volian.Print.Library/Pagination.cs @@ -768,8 +768,7 @@ namespace Volian.Print.Library } private float GetYPageSizeUseOnAllButFirstPage() { - //float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // A4 paper logic - float _PointsPerPage = 792; + float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files int indx = (int)MyItemInfo.MyDocStyle.IndexOtherThanFirstPage; foreach (DocStyle ds in MyItemInfo.ActiveFormat.PlantFormat.DocStyles.DocStyleList) { diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index c9de11c8..a9491b5e 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -546,7 +546,7 @@ namespace Volian.Print.Library } else // don't use Word margins { - rct = PageSize.LETTER; + rct = PDFPageSize.UsePaperSize(MyItem.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files } // C2018-004 create meta file for baseline compares if (currentSection.IsStepSection) @@ -761,7 +761,7 @@ namespace Volian.Print.Library // Create an MSWord Pdf // Setup a pdf Document for printing OnStatusChanged("Before OpenDoc", PromsPrinterStatusType.Before); - iTextSharp.text.Rectangle rct = PageSize.LETTER; + iTextSharp.text.Rectangle rct = PDFPageSize.UsePaperSize(myProcedure.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files if (myProcedure.Sections != null && !myProcedure.Sections[0].IsStepSection && !doingFoldout) // B2019-166 also don't do this if doing a foldout else it will use the margins set in word { SectionInfo si = myProcedure.Sections[0] as SectionInfo; @@ -1271,7 +1271,7 @@ namespace Volian.Print.Library private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer) { iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter; - float _PointsPerPage = 792; + float _PointsPerPage = PDFPageSize.PaperSizePoints(myProcedure.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files float yTopMargin = _PointsPerPage - (float)tocSection.MyDocStyle.Layout.TopMargin; float yBottomMargin = Math.Max(0, yTopMargin - (float)tocSection.MyDocStyle.Layout.PageLength); // - 2 * vlnPrintObject.SixLinesPerInch); if (textLayer != null) cb.BeginLayer(textLayer); @@ -1782,8 +1782,8 @@ namespace Volian.Print.Library section.StepSectPageBreaksForSupInfo.Clear(); section.StepSectPageBreaks.Clear(); } - // 792: 72 * 11 inches - TopRow - Top is high value - float _PointsPerPage = 792; + // 792: 72 * 11 inches - TopRow - Top is high value for 8.5x11 paper, 842 for A4 paper + float _PointsPerPage = PDFPageSize.PaperSizePoints(myItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files float yTopMargin = _PointsPerPage - (float)myItemInfo.MyDocStyle.Layout.TopMargin; yTopMargin -= _MyHelper.AdjustTopMarginForMultiLinePageListItems; // the following line was modified to comment out the - 2 * SixLinesPerInch. this fixed a pagination problem with WCN EMG E-3. @@ -1909,7 +1909,8 @@ namespace Volian.Print.Library if (SupInfoPdfPage == null) SupInfoPdfPage = new Dictionary(); else SupInfoPdfPage.Clear(); string SupInfoPdfName = Volian.Base.Library.VlnSettings.TemporaryFolder + @"\SupInfo" + vlnParagraph.MyItemInfo.ItemID.ToString() + @".pdf"; - PdfContentByte cb = OpenDoc(SupInfoPdfName, PageSize.LETTER); + iTextSharp.text.Rectangle pageSize = PDFPageSize.UsePaperSize(MyItem.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files + PdfContentByte cb = OpenDoc(SupInfoPdfName, pageSize); if (cb == null) return; VlnSvgPageHelper myPageHelper = new VlnSvgPageHelper(vlnParagraph.MyItemInfo as SectionInfo, this, null, 0); cb.PdfWriter.PageEvent = myPageHelper; @@ -2410,7 +2411,7 @@ namespace Volian.Print.Library string key = string.Format("{0}.{1}", sectInfo.ItemID, pageNumber); if(dicSize.ContainsKey(key)) return dicSize[key]; - return PageSize.LETTER; + return PDFPageSize.UsePaperSize(sectInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files } public void LoadTree(ItemInfo ii) { diff --git a/PROMS/Volian.Print.Library/Rtf2Pdf.cs b/PROMS/Volian.Print.Library/Rtf2Pdf.cs index 43fdb140..3ce7aa72 100644 --- a/PROMS/Volian.Print.Library/Rtf2Pdf.cs +++ b/PROMS/Volian.Print.Library/Rtf2Pdf.cs @@ -56,7 +56,8 @@ namespace Volian.Print.Library } public void Process() { - iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER); + iTextSharp.text.Document document = new iTextSharp.text.Document(PaperSizeRec); // C2020-002 paper size is now set in the format files + int paperSizePoints = PDFPageSize.PaperSizePoints(PaperSize); // C2020-002 paper size is now set in the format files PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(FileName, FileMode.Create)); document.Open(); // Open RTF Document @@ -65,9 +66,9 @@ namespace Volian.Print.Library Paragraph para = rtf2IText.Convert(); para.SetLeading(12F, 0); PdfContentByte cb = writer.DirectContent; - SampleParagraphs(para, cb, 792-36, 252, 36); - para.Add(new Chunk(" (continued)",para.Font)); - SampleParagraphs(para, cb, 792 - 36, 252, 324); + SampleParagraphs(para, cb, paperSizePoints - 36, 252, 36); // C2020-002 paper size is now set in the format files + para.Add(new Chunk(" (continued)", para.Font)); + SampleParagraphs(para, cb, paperSizePoints - 36, 252, 324); // C2020-002 paper size is now set in the format files // Close the document document.Close(); } @@ -80,6 +81,17 @@ namespace Volian.Print.Library yTop = newYTop; } } + private static string _PaperSize = "LETTER"; // default paper size + public static string PaperSize // C2020-002 paper size is now set in the format files + { + get { return Rtf2Pdf._PaperSize; } + set { Rtf2Pdf._PaperSize = value; } + } + private Rectangle _PaperSizeRec = PageSize.LETTER; // default paper size + public Rectangle PaperSizeRec + { + get { return PDFPageSize.UsePaperSize(PaperSize); } + } private static bool _PdfDebug = true; public static bool PdfDebug { @@ -310,11 +322,12 @@ namespace Volian.Print.Library float top = y + Offset.Y; float right = left + width; float bottom = top - height; + int paperSizePoints = PDFPageSize.PaperSizePoints(myGrid.MyFlexGrid.MyDVI.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files ColumnText myColumnText = new ColumnText(cb); myColumnText.SetSimpleColumn(left, top, left + width, yBottomMargin); //if (textLayer != null) cb.BeginLayer(textLayer); // RHM20150507 Table Scrunch // C2018-004 create meta file for baseline compares - if (top + GridTopAdjust > 792) // B2019-110 Table continued on the next page - off the top of page + if (top + GridTopAdjust > paperSizePoints) // B2019-110 Table continued on the next page - off the top of page { _MyLog.ErrorFormat("\r\n===> Table Printing Off the Top of Page"); Volian.Base.Library.BaselineMetaFile.WriteLine("## Error - Grid Off the Top of Page"); diff --git a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs index 7b75f391..72789e44 100644 --- a/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs +++ b/PROMS/Volian.Print.Library/VlnSvgPageHelper.cs @@ -357,7 +357,7 @@ namespace Volian.Print.Library if (myPageHelper.BottomContent != null) { cb.MoveTo(0, (float)myPageHelper.BottomContent); - cb.LineTo(792, (float)myPageHelper.BottomContent); + cb.LineTo(PDFPageSize.PaperSizePoints(MySection.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize), (float)myPageHelper.BottomContent); // C2020-002 paper size is now set in the format files } int i = 0; for (float y = yBottom; y <= yTop; y += 12) @@ -715,7 +715,7 @@ i = 0; float tmp = 0; if (NotesToFootNotes != null && NotesToFootNotes.Count > 0) { - float _PointsPerPage = 792; + float _PointsPerPage = (float)PDFPageSize.PaperSizePoints(MySection.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files float yTopMargin = _PointsPerPage - (float)MySection.MyDocStyle.Layout.TopMargin; float myYOff = NotesToFootNotesYoffset; foreach (vlnParagraph ntfn in NotesToFootNotes) @@ -1397,7 +1397,7 @@ i = 0; //token = Regex.Replace(token, @"[\xB3-\xDF]", " "); // handle any conditional PS tokens - if (plstr.Contains(@"PS=")) + if (token.Contains(@"PS=")) { ProcedureConfig procConfig = new ProcedureConfig(section.MyProcedure.MyContent.Config); if (procConfig != null) diff --git a/PROMS/Volian.Print.Library/vlnParagraph.cs b/PROMS/Volian.Print.Library/vlnParagraph.cs index c8304d1b..e2c6739c 100644 --- a/PROMS/Volian.Print.Library/vlnParagraph.cs +++ b/PROMS/Volian.Print.Library/vlnParagraph.cs @@ -1381,8 +1381,7 @@ namespace Volian.Print.Library } private void ResetDocStyleAndValues(ref float yTopMargin, ref float yBottomMargin) { - //float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // A4 paper logic - float _PointsPerPage = 792; + float _PointsPerPage = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize); // C2020-002 paper size is now set in the format files // if this document style has another style that is for pages other than first, we need to // reset the document style off of this section AND reset docstyle values used. // C2018-003 fixed use of getting the active section @@ -1706,8 +1705,7 @@ namespace Volian.Print.Library if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination()) { RefreshDocStyle(); - //yTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section // A4 paper logic - yTopMargin = 792 - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section + yTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2018-003 fixed use of getting the active section // C2020-002 paper size is now set in the format files yBottomMargin = Math.Max(0, yTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); // C2018-003 fixed use of getting the active section yPageStart = yTopMargin; } @@ -2803,8 +2801,7 @@ namespace Volian.Print.Library { if (MyItemInfo.ActiveSection != null && (MyItemInfo.ActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PrintSectOnFirst) == E_DocStructStyle.DSS_PrintSectOnFirst) // C2018-003 fixed use of getting the active section { - //float localYTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // A4 paper logic - float localYTopMargin = 792 - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; + float localYTopMargin = PDFPageSize.PaperSizePoints(MyItemInfo.ActiveFormat.PlantFormat.FormatData.PDFPageSize.PaperSize) - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.TopMargin; // C2020-002 paper size is now set in the format files yBtmMarginForMsg = Math.Max(0, localYTopMargin - (float)MyItemInfo.ActiveSection.MyDocStyle.Layout.PageLength); } } diff --git a/PROMS/Volian.Print.Library/vlnPrintObject.cs b/PROMS/Volian.Print.Library/vlnPrintObject.cs index 703e13a3..392f8a19 100644 --- a/PROMS/Volian.Print.Library/vlnPrintObject.cs +++ b/PROMS/Volian.Print.Library/vlnPrintObject.cs @@ -250,7 +250,8 @@ namespace Volian.Print.Library public static float GetHeight(PdfContentByte cb, Paragraph iParagraph, string suffix, float width, bool throwException) { ColumnText myColumnText = new ColumnText(cb); - myColumnText.SetSimpleColumn(0, 792F, width, 0); // Bottom margin + float pgHeight = cb.PdfDocument.PageSize.Height; // C2020-002 paper size is now set in the format files + myColumnText.SetSimpleColumn(0, pgHeight, width, 0); // Bottom margin if (suffix != string.Empty) { Chunk chk = iParagraph.Chunks[0] as Chunk; @@ -276,7 +277,7 @@ namespace Volian.Print.Library //throw (new Exception("Paragraph longer than a page")); Console.WriteLine("Paragraph longer than a page"); } - return 792F - myColumnText.YLine; // This gives the height of the Paragraph + return pgHeight - myColumnText.YLine; // This gives the height of the Paragraph // C2020-002 paper size is now set in the format files } public float GetTableWidth(PdfContentByte cb, Paragraph iParagraph, float? maxWidth) {