From f97433e12a86ec2ebb3cb422f2b949aa89d99683 Mon Sep 17 00:00:00 2001 From: Rich Date: Fri, 6 Mar 2015 11:50:27 +0000 Subject: [PATCH] Changed the name of the temporary file used for MSWord PDFs. Gave it a PDF extensison so that it caan be more easily opened. Add useful information to the PDF file properties so that the verssion of the code used to create the PDF can be identified. --- .../Extension/DocumentExt.cs | 2 +- PROMS/Volian.Print.Library/PromsPrinter.cs | 64 ++++++++++++------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs index 0caed113..4448c8bc 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/DocumentExt.cs @@ -1239,7 +1239,7 @@ namespace VEPROMS.CSLA.Library } private static string GetFileName(ItemInfo sect) { - string fileName = VlnSettings.TemporaryFolder + @"\Doc " + sect.MyContent.MyEntry.DocID.ToString(); // +" " + (sect.DisplayNumber == "" ? sect.DisplayText : sect.DisplayNumber); + string fileName = VlnSettings.TemporaryFolder + @"\Doc_" + sect.MyContent.MyEntry.DocID.ToString()+".Pdf"; // +" " + (sect.DisplayNumber == "" ? sect.DisplayText : sect.DisplayNumber); return fileName; } public static RectangleF CreatePlot(string pngFile, string xyPlot, float resolution, System.Windows.Forms.Form myForm) diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 936abe03..ef1bd609 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -249,6 +249,8 @@ namespace Volian.Print.Library // re-evaluated. if (page.Height < page.Width) image.RotationDegrees = 90F; + //if (page.Height < page.Width) + // image.RotationDegrees = 90F; image.SetAbsolutePosition(xOff, yOff); cb.AddImage(image); cb.EndLayer(); @@ -438,6 +440,7 @@ namespace Volian.Print.Library // Setup a pdf Document for printing OnStatusChanged("Before OpenDoc", PromsPrinterStatusType.Before); PdfContentByte cb = OpenDoc(outputFileName); + SetupProperties(cb.PdfDocument, myProcedure); if (cb == null) { ProfileTimer.Pop(profileDepth); @@ -653,6 +656,14 @@ namespace Volian.Print.Library ProfileTimer.Pop(profileDepth); return outputFileName; } + + private void SetupProperties(PdfDocument document, ProcedureInfo myProcedure) + { + document.AddTitle(string.Format("{0} {1}",myProcedure.DisplayNumber,myProcedure.DisplayText)); + document.AddSubject(myProcedure.SearchDVPath); + document.AddCreator(string.Format("{0} {1}",Application.ProductName, Application.ProductVersion)); + document.AddAuthor(Volian.Base.Library.VlnSettings.UserID); + } private Placekeeper _MyPlacekeeper = null; public Placekeeper MyPlacekeeper @@ -718,6 +729,11 @@ namespace Volian.Print.Library try { fgPage = cb.PdfWriter.GetImportedPage(readerWord, ii + 1); + //if (ii + 2 < readerWord.NumberOfPages) + //{ + // iTextSharp.text.Rectangle rc = readerWord.GetPageSizeWithRotation(ii + 2); + // cb.PdfDocument.SetPageSize(rc); + //} } catch (Exception ex) { @@ -769,33 +785,33 @@ namespace Volian.Print.Library } OnStatusChanged("Merge MSWord", PromsPrinterStatusType.MergeMSWord); } - OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before); - if (mySection.MyDocStyle.LandscapePageList)// && mySection.MyDocStyle.Layout.PageWidth > mySection.MyDocStyle.Layout.PageLength) - _MyHelper.IsLandscape = true; - else - _MyHelper.IsLandscape = false; - cb.PdfDocument.NewPage(); // Word Document - //_MyLog.InfoFormat("NewPage 3 {0}", cb.PdfWriter.CurrentPageNumber); + OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before); + if (mySection.MyDocStyle.LandscapePageList)// && mySection.MyDocStyle.Layout.PageWidth > mySection.MyDocStyle.Layout.PageLength) + _MyHelper.IsLandscape = true; + else + _MyHelper.IsLandscape = false; + cb.PdfDocument.NewPage(); // Word Document + //_MyLog.InfoFormat("NewPage 3 {0}", cb.PdfWriter.CurrentPageNumber); - // 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. - _MyHelper.DidFirstPageDocStyle = true; + // 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. + _MyHelper.DidFirstPageDocStyle = true; - // Calvert has a case in their stp landscape word docs where a ' (Continued)' message - // appears in their pagelist item for printing the section title, {ATTACHTITLECONT} pagelist - // However, other sections use this token, but do NOT have the continue message - so - // the docstyle was added to flag the difference between them (STP-Landscape Attachments has it, - // STP-Attachments do not) - if (resetSvgForCont && (mySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListAddSectCont) == E_DocStructStyle.DSS_PageListAddSectCont) - { - _MyHelper.ResetSvg(); - resetSvgForCont = false; // only need to reset it once (for all pages after 1st page) - } + // Calvert has a case in their stp landscape word docs where a ' (Continued)' message + // appears in their pagelist item for printing the section title, {ATTACHTITLECONT} pagelist + // However, other sections use this token, but do NOT have the continue message - so + // the docstyle was added to flag the difference between them (STP-Landscape Attachments has it, + // STP-Attachments do not) + if (resetSvgForCont && (mySection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListAddSectCont) == E_DocStructStyle.DSS_PageListAddSectCont) + { + _MyHelper.ResetSvg(); + resetSvgForCont = false; // only need to reset it once (for all pages after 1st page) + } - //DebugPagination.WriteLine("CreateWordDocPdf"); - if ((mySection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) - _MyHelper.MySection = mySection; // this resets the docstyle/pagestyle in pagehelper - OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); + //DebugPagination.WriteLine("CreateWordDocPdf"); + if ((mySection.MyDocStyle.StructureStyle.Where & E_DocStyleUse.UseOnFirstPage) > 0) + _MyHelper.MySection = mySection; // this resets the docstyle/pagestyle in pagehelper + OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage); } } catch (Exception ex)