Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page Break.
Added a New Object (ReaderHelper) which provides the necessary support to allow MSWord documents to use various page sizes. MSWord has a limit of 22 inches for the largest width or height. Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page break. Use new PromsPrinter Method (NewPage) to set the page size properly before outputing the page break. Updated vlnParagraph constructors to use parameter MyPromsPrinter since it is used to create page breaks.
This commit is contained in:
parent
5d2b0bc1b0
commit
2d6f5f443e
@ -591,7 +591,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private void ForcePagination(PdfContentByte cb, ref float yPageStart, float yTopMargin, float yBottomMargin, ref float yLocation, ref float retval)
|
||||
{
|
||||
cb.PdfDocument.NewPage(); // pagination issue
|
||||
MyPromsPrinter.NewPage();
|
||||
DebugText.WriteLine("*****PaginateError");
|
||||
yPageStart = yTopMargin + YVeryTop;
|
||||
yLocation = yPageStart - YOffset;
|
||||
@ -999,7 +999,7 @@ namespace Volian.Print.Library
|
||||
// `88b ooo 888 888 888 888 888 888 888 888 888 .o o. )88b o. )88b 888 d8( 888 888 888 .
|
||||
// `Y8bood8P' `Y8bod8P' o888o o888o o888o 888bod8P' d888b `Y8bod8P' 8""888P' 8""888P' o888o `Y888""8o d888b "888"
|
||||
// 888
|
||||
// o888o
|
||||
// o888o
|
||||
//
|
||||
// | Step over a Number of Pages |
|
||||
// | First Page | Second Page | Third Page |
|
||||
|
@ -107,6 +107,11 @@ namespace Volian.Print.Library
|
||||
}
|
||||
private string _Rev;
|
||||
private ItemInfo _MyItem;
|
||||
public ItemInfo MyItem
|
||||
{
|
||||
get { return _MyItem; }
|
||||
set { _MyItem = value; }
|
||||
}
|
||||
private string _Watermark;
|
||||
private string _PDFFile;
|
||||
|
||||
@ -184,6 +189,12 @@ namespace Volian.Print.Library
|
||||
}
|
||||
return DialogResult.No;
|
||||
}
|
||||
private ReaderHelper _MyReaderHelper;
|
||||
public ReaderHelper MyReaderHelper
|
||||
{
|
||||
get { return _MyReaderHelper; }
|
||||
set { _MyReaderHelper = 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)
|
||||
{
|
||||
_MyItem = myItem;
|
||||
@ -197,6 +208,8 @@ namespace Volian.Print.Library
|
||||
_PDFFile = pdfFile;
|
||||
_OriginalPageBreak = origPgBrk;
|
||||
_InsertBlankPages = insertBlankPages;
|
||||
_MyReaderHelper = new ReaderHelper(this);
|
||||
//_MyReaderHelper.LoadTree(myItem);
|
||||
}
|
||||
private string _BeforePageNumberPdf = null;
|
||||
public string BeforePageNumberPdf
|
||||
@ -222,14 +235,15 @@ namespace Volian.Print.Library
|
||||
if (retstr == null) return null;
|
||||
BeforePageNumberPdf = retstr;
|
||||
ProcedureInfo.RefreshPageNumTransitions(_MyItem as ProcedureInfo);
|
||||
MyContentByte = null;
|
||||
_MyReaderHelper = new ReaderHelper(this);
|
||||
return Print(_MyItem as ProcedureInfo, pdfFolder, makePlacekeeper);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
private string BuildMSWordPDF(SectionInfo section)
|
||||
internal string BuildMSWordPDF(SectionInfo section)
|
||||
{
|
||||
if (section.PageNumber == 0) section.PageNumber = _MyHelper.CurrentPageNumber;
|
||||
DateTime tStart = DateTime.Now;
|
||||
string MSWordFile = null;
|
||||
if (section.MyContent.ContentEntryCount == 1)
|
||||
@ -248,9 +262,10 @@ namespace Volian.Print.Library
|
||||
// a portrait page. If, at some point, we print a total landscape page, not a mix, this will need
|
||||
// re-evaluated.
|
||||
if (page.Height < page.Width)
|
||||
image.RotationDegrees = 90F;
|
||||
//if (page.Height < page.Width)
|
||||
// image.RotationDegrees = 90F;
|
||||
{
|
||||
if (cb.PdfDocument.PageSize.Height > cb.PdfDocument.PageSize.Width)
|
||||
image.RotationDegrees = 90F;
|
||||
}
|
||||
image.SetAbsolutePosition(xOff, yOff);
|
||||
cb.AddImage(image);
|
||||
cb.EndLayer();
|
||||
@ -292,11 +307,110 @@ namespace Volian.Print.Library
|
||||
OnStatusChanged("OpenPDF", PromsPrinterStatusType.OpenPDF);
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
|
||||
private PdfContentByte OpenDoc(string outputFileName)
|
||||
private PdfContentByte _MyContentByte = null;
|
||||
public PdfContentByte MyContentByte
|
||||
{
|
||||
get { return _MyContentByte; }
|
||||
set
|
||||
{
|
||||
_MyContentByte = value;
|
||||
MyReaderHelper.LoadTree(MyItem);
|
||||
}
|
||||
}
|
||||
public void NewPage()
|
||||
{
|
||||
string path = Volian.Base.Library.vlnStackTrace.StackToStringLocal(2, 1);
|
||||
NewPage(false);
|
||||
}
|
||||
public void NewPage(bool sectionChange)
|
||||
{
|
||||
iTextSharp.text.Rectangle rct = MyReaderHelper.MyPromsPrinter.MyContentByte.PdfDocument.PageSize;
|
||||
if (_MyHelper != null)
|
||||
{
|
||||
SectionInfo currentSection = _MyHelper.MySection;
|
||||
//if (currentSection.InList(79359)) Console.WriteLine("Here");
|
||||
//currentSection = currentSection.ActiveParent as SectionInfo;
|
||||
SectionInfo nextSection = GetNextSection(currentSection); // _MyHelper.MySection.NextItem as SectionInfo;
|
||||
//if (nextSection == null) Console.WriteLine("Here");
|
||||
//if (nextSection != null && nextSection.InList(79359)) Console.WriteLine("Here");
|
||||
SectionConfig sc = (nextSection ?? currentSection).MyConfig as SectionConfig;
|
||||
bool wordMargins = (sc != null && sc.Section_WordMargin == "Y");
|
||||
if (wordMargins)
|
||||
{
|
||||
if (nextSection != null && (sectionChange) && !nextSection.IsStepSection) //change to a word section
|
||||
{
|
||||
LastWordSection = nextSection;
|
||||
_PageCountOfWordSection = 1;
|
||||
MyReaderHelper.MySectionInfo = LastWordSection;
|
||||
ShowNeedForPageSize();
|
||||
rct = MyReaderHelper.GetSize(LastWordSection, 1);
|
||||
}
|
||||
else if (!currentSection.IsStepSection) //current section is a word section
|
||||
{
|
||||
if (currentSection != LastWordSection)
|
||||
{
|
||||
LastWordSection = currentSection;
|
||||
_PageCountOfWordSection = 1;
|
||||
}
|
||||
else
|
||||
_PageCountOfWordSection++;
|
||||
MyReaderHelper.MySectionInfo = LastWordSection;
|
||||
ShowNeedForPageSize();
|
||||
rct = MyReaderHelper.GetSize(LastWordSection, _PageCountOfWordSection);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rct = PageSize.LETTER;
|
||||
}
|
||||
Console.WriteLine("\"{0}\"\t\"{1}\"\t\"{2}\"\t\"{3}\"\t{4}"
|
||||
, currentSection == null ? "" : currentSection.DisplayNumber + " " + currentSection.DisplayText
|
||||
, nextSection == null ? "" : nextSection.DisplayNumber + " " + nextSection.DisplayText
|
||||
, sectionChange, wordMargins,_PageCountOfWordSection);
|
||||
}
|
||||
MyContentByte.PdfDocument.SetPageSize(rct);
|
||||
MyContentByte.PdfDocument.NewPage();
|
||||
}
|
||||
private SectionInfo GetNextSection(SectionInfo currentSection)
|
||||
{
|
||||
if (currentSection.Sections != null)
|
||||
return currentSection.Sections[0] as SectionInfo;
|
||||
if (currentSection.NextItem != null)
|
||||
return currentSection.NextItem as SectionInfo;
|
||||
SectionInfo parent = currentSection.ActiveParent as SectionInfo;
|
||||
while (parent != null && parent.NextItem == null)
|
||||
parent = parent.ActiveParent as SectionInfo;
|
||||
if (parent == null) return null;
|
||||
return parent.NextItem as SectionInfo;
|
||||
}
|
||||
private SectionInfo _PreviousWordSection = null;
|
||||
public SectionInfo PreviousWordSection
|
||||
{
|
||||
get { return _PreviousWordSection; }
|
||||
set { _PreviousWordSection = value; }
|
||||
}
|
||||
private SectionInfo _LastWordSection = null;
|
||||
public SectionInfo LastWordSection
|
||||
{
|
||||
get { return _LastWordSection; }
|
||||
set
|
||||
{
|
||||
PreviousWordSection = _LastWordSection;
|
||||
_LastWordSection = value;
|
||||
}
|
||||
}
|
||||
private int _PageCountOfWordSection = 0;
|
||||
private void ShowNeedForPageSize()
|
||||
{
|
||||
if(PreviousWordSection != null && PreviousWordSection != LastWordSection)
|
||||
Console.WriteLine("Switch From {0}.{1} ",PreviousWordSection.DisplayNumber,PreviousWordSection.DisplayText);
|
||||
Console.WriteLine("To {0}.{1} Page: {2}",LastWordSection.DisplayNumber,LastWordSection.DisplayText,_PageCountOfWordSection);
|
||||
PreviousWordSection = LastWordSection;
|
||||
}
|
||||
private PdfContentByte OpenDoc(string outputFileName, iTextSharp.text.Rectangle rect)
|
||||
{
|
||||
PdfWriter writer=null;
|
||||
iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER);
|
||||
iTextSharp.text.Document document = new iTextSharp.text.Document(rect);
|
||||
try
|
||||
{
|
||||
writer = PdfWriter.GetInstance(document, new FileStream(outputFileName, FileMode.Create));
|
||||
@ -329,7 +443,7 @@ namespace Volian.Print.Library
|
||||
PrintOverride.ChangeBarColor = System.Drawing.Color.Red;
|
||||
PrintOverride.DebugColor = System.Drawing.Color.CadetBlue;
|
||||
}
|
||||
return writer.DirectContent;
|
||||
return MyContentByte = writer.DirectContent;
|
||||
}
|
||||
//private string CreateFileName(string procNumber, string sectNumber, string sectTitle)
|
||||
//{
|
||||
@ -427,6 +541,7 @@ namespace Volian.Print.Library
|
||||
get { return _AllowAllWatermarks; }
|
||||
set { _AllowAllWatermarks = value; }
|
||||
}
|
||||
private PdfReader readerWord;
|
||||
private string PrintProcedureOrFoldout(ProcedureInfo myProcedure, SectionInfo myFoldoutSection, string outputFileName, bool makePlacekeeper)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> PrintProcedureOrFoldout");
|
||||
@ -439,7 +554,29 @@ namespace Volian.Print.Library
|
||||
// Create an MSWord Pdf
|
||||
// Setup a pdf Document for printing
|
||||
OnStatusChanged("Before OpenDoc", PromsPrinterStatusType.Before);
|
||||
PdfContentByte cb = OpenDoc(outputFileName);
|
||||
iTextSharp.text.Rectangle rct = PageSize.LETTER;
|
||||
if (myProcedure.Sections != null && !myProcedure.Sections[0].IsStepSection)
|
||||
{
|
||||
SectionInfo si = myProcedure.Sections[0] as SectionInfo;
|
||||
SectionConfig sc = si.MyConfig as SectionConfig;
|
||||
bool wordMargins = (sc != null && sc.Section_WordMargin == "Y");
|
||||
if (wordMargins)
|
||||
{
|
||||
string pdfFile =BuildMSWordPDF(si);
|
||||
try
|
||||
{
|
||||
PdfReader reader = new PdfReader(pdfFile);
|
||||
rct = reader.GetPageSizeWithRotation(1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
_MyLog.Warn(string.Format("Error of ReadPDf [{0}],{1}.{2}",si.ItemID,si.DisplayNumber,si.DisplayText),ex);
|
||||
throw new Exception("Error in readPDF", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
PdfContentByte cb = OpenDoc(outputFileName, rct);
|
||||
if (cb == null)
|
||||
{
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
@ -447,7 +584,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
SetupProperties(cb.PdfDocument, myProcedure);
|
||||
OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
|
||||
cb.PdfDocument.NewPage(); // Start of print
|
||||
NewPage(); // Start of print
|
||||
//_MyLog.InfoFormat("NewPage 1 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
|
||||
if (myProcedure.Sections == null)
|
||||
@ -578,8 +715,6 @@ namespace Volian.Print.Library
|
||||
}
|
||||
}
|
||||
}
|
||||
PdfReader readerWord = null;
|
||||
string myPdfFile = null;
|
||||
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
||||
|
||||
if (mySection.IsAutoTOCSection)
|
||||
@ -608,7 +743,7 @@ namespace Volian.Print.Library
|
||||
// and the checkbox on the print dialog to add blank pages is checked
|
||||
_MyHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
NewPage();
|
||||
//_MyLog.InfoFormat("NewPage Begin Step Sect blank {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
}
|
||||
@ -617,7 +752,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateWordDocPdf(cb, mySection, ref readerWord, ref myPdfFile);
|
||||
CreateWordDocPdf(cb, mySection);
|
||||
}
|
||||
}
|
||||
_MyHelper.PrintedSectionPage = 0;
|
||||
@ -628,7 +763,7 @@ namespace Volian.Print.Library
|
||||
while (cb.PdfWriter.CurrentPageNumber <= _MyHelper.BackgroundPageCount)
|
||||
{
|
||||
PrintTextMessage(cb, "No Proms Output", _TextLayer);
|
||||
cb.PdfDocument.NewPage(); // only have 16bit pages left (for DebugMode)
|
||||
NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 2 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
if (DebugPagination.IsOpen) DebugPagination.WriteLine("{0:D6},'{1}'",
|
||||
_MyHelper.MyPdfContentByte.PdfWriter.CurrentPageNumber, "No PROMS Output");
|
||||
@ -671,14 +806,12 @@ namespace Volian.Print.Library
|
||||
get { return _MyPlacekeeper; }
|
||||
set { _MyPlacekeeper = value; }
|
||||
}
|
||||
public void CreateWordDocPdf(PdfContentByte cb, SectionInfo mySection, ref PdfReader readerWord, ref string myPdfFile)
|
||||
public void CreateWordDocPdf(PdfContentByte cb, SectionInfo mySection)
|
||||
{
|
||||
int profileDepth = ProfileTimer.Push(">>>> CreateWordDocPdf");
|
||||
_MyHelper.MySection = mySection;
|
||||
myPdfFile = BuildMSWordPDF(mySection);
|
||||
try
|
||||
{
|
||||
readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null;
|
||||
OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection);
|
||||
int sectPageCount = 0;
|
||||
float locEndOfWordDoc = 0;
|
||||
@ -722,18 +855,13 @@ namespace Volian.Print.Library
|
||||
didFoldout = true;
|
||||
DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper, 0, false);
|
||||
}
|
||||
if (readerWord != null)
|
||||
if (this.MyReaderHelper != null)
|
||||
{
|
||||
bool doimport2 = true;
|
||||
PdfImportedPage fgPage = null;
|
||||
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);
|
||||
//}
|
||||
fgPage = this.MyReaderHelper.GetPage(mySection, ii + 1);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -749,7 +877,7 @@ namespace Volian.Print.Library
|
||||
// and the checkbox on the print dialog to add blank pages is checked
|
||||
_MyHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 3 blank {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
float yoff = 0;
|
||||
@ -790,7 +918,7 @@ namespace Volian.Print.Library
|
||||
_MyHelper.IsLandscape = true;
|
||||
else
|
||||
_MyHelper.IsLandscape = false;
|
||||
cb.PdfDocument.NewPage(); // Word Document
|
||||
NewPage(ii == sectPageCount-1); // 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
|
||||
@ -816,7 +944,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
cb.PdfDocument.NewPage(); // can we put out 'error on page'?
|
||||
NewPage(); // can we put out 'error on page'?
|
||||
_MyLog.InfoFormat("NewPage error on page {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
finally
|
||||
@ -838,7 +966,7 @@ namespace Volian.Print.Library
|
||||
lastyLocation = 0;
|
||||
AddSectionToTOC(tocSection, procItem, tOfC, cb, yTopMargin, 0);
|
||||
if (textLayer != null) cb.EndLayer();
|
||||
cb.PdfDocument.NewPage();
|
||||
NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 4 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
_NoBreakYOffset = 0;
|
||||
}
|
||||
@ -957,7 +1085,7 @@ namespace Volian.Print.Library
|
||||
float retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||
if (retval == 0) // couldn't fit, flags need for a page break.
|
||||
{
|
||||
cb.PdfDocument.NewPage();
|
||||
NewPage();
|
||||
_MyHelper.ResetSvg(); // needed to reset so that PSNotFirst pagelist justify flag gets used for BGE
|
||||
yLocation = lastyLocation = 0;
|
||||
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||
@ -1292,7 +1420,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
_MyHelper.IsLandscape = false;
|
||||
}
|
||||
cb.PdfDocument.NewPage(); // end of step section
|
||||
NewPage(true); // end of step section
|
||||
//_MyLog.InfoFormat("NewPage 6 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
_NoBreakYOffset = 0;
|
||||
yPageStart = yTopMargin;
|
||||
@ -1318,15 +1446,7 @@ namespace Volian.Print.Library
|
||||
//pt.Description = "End";
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
}
|
||||
public static void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer)
|
||||
{
|
||||
|
||||
//cb.Circle(400, 100, 50);
|
||||
PrintTextMessage(cb, "Foldout for: " + str, textLayer);
|
||||
cb.PdfDocument.NewPage(); // Temporary for foldout/16bit-32bit page alignment
|
||||
//_MyLog.InfoFormat("NewPage 7 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
public static void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx, bool insertBlankPages)
|
||||
public void DoFoldoutPage(PdfContentByte cb, string str, PdfLayer textLayer, VlnSvgPageHelper myPageHelper, int foldoutindx, bool insertBlankPages)
|
||||
{
|
||||
if (_MyFoldoutSection == null || _MyFoldoutSection.Count==0) return;
|
||||
|
||||
@ -1344,7 +1464,7 @@ namespace Volian.Print.Library
|
||||
// as the first page so that duplex printing is correct for this condition.
|
||||
myPageHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
NewPage();
|
||||
}
|
||||
|
||||
SectionInfo saveSect = myPageHelper.MySection;
|
||||
@ -1372,7 +1492,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
//_MyLog.InfoFormat("DoFoldoutPage {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
//PrintTextMessage(cb, "Foldout for: " + str, textLayer);
|
||||
cb.PdfDocument.NewPage(); // Temporary for foldout/16bit-32bit page alignment
|
||||
NewPage();// Temporary for foldout/16bit-32bit page alignment
|
||||
//_MyLog.InfoFormat("NewPage 8 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
myPageHelper.MySection = saveSect;
|
||||
myPageHelper.OnFoldoutPage = false;
|
||||
@ -1412,6 +1532,119 @@ namespace Volian.Print.Library
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
public class ReaderHelper
|
||||
{
|
||||
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private Dictionary<string, PdfImportedPage> dicPage = new Dictionary<string, PdfImportedPage>();
|
||||
private Dictionary<string, iTextSharp.text.Rectangle> dicSize = new Dictionary<string, iTextSharp.text.Rectangle>();
|
||||
private PromsPrinter _MyPromsPrinter;
|
||||
public PromsPrinter MyPromsPrinter
|
||||
{
|
||||
get { return _MyPromsPrinter; }
|
||||
set { _MyPromsPrinter = value; }
|
||||
}
|
||||
private SectionInfo _MySectionInfo;
|
||||
public SectionInfo MySectionInfo
|
||||
{
|
||||
get { return _MySectionInfo; }
|
||||
set
|
||||
{
|
||||
if (_MySectionInfo == null || value.ItemID != _MySectionInfo.ItemID)
|
||||
{
|
||||
_MySectionInfo = value;
|
||||
//MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(MySectionInfo);
|
||||
//try
|
||||
//{
|
||||
// MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
|
||||
// string key = string.Empty;
|
||||
// for (int i = 1; i <= MyReader.NumberOfPages; i++)
|
||||
// {
|
||||
// key = string.Format("{0}.{1}", MySectionInfo.ItemID, i);
|
||||
// dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i));
|
||||
// dicSize.Add(key, MyReader.GetPageSizeWithRotation(i));
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// MyReader = null;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
private string _MyPdfFile;
|
||||
public string MyPdfFile
|
||||
{
|
||||
get { return _MyPdfFile; }
|
||||
set { _MyPdfFile = value; }
|
||||
}
|
||||
private int _DocID;
|
||||
public int DocID
|
||||
{
|
||||
get { return _DocID; }
|
||||
set { _DocID = value; }
|
||||
}
|
||||
private PdfReader _MyReader;
|
||||
public PdfReader MyReader
|
||||
{
|
||||
get { return _MyReader; }
|
||||
set { _MyReader = value; }
|
||||
}
|
||||
public ReaderHelper(PromsPrinter pp)
|
||||
{
|
||||
MyPromsPrinter = pp;
|
||||
//this.LoadTree(pp.MyItem);
|
||||
}
|
||||
public PdfImportedPage GetPage(SectionInfo sectInfo, int pageNumber)
|
||||
{
|
||||
string key = string.Format("{0}.{1}", sectInfo.ItemID, pageNumber);
|
||||
return dicPage[key];
|
||||
}
|
||||
public iTextSharp.text.Rectangle GetSize(SectionInfo sectInfo, int pageNumber)
|
||||
{
|
||||
string key = string.Format("{0}.{1}", sectInfo.ItemID, pageNumber);
|
||||
if(dicSize.ContainsKey(key))
|
||||
return dicSize[key];
|
||||
return PageSize.LETTER;
|
||||
}
|
||||
public void LoadTree(ItemInfo ii)
|
||||
{
|
||||
if (dicPage.Count == 0)
|
||||
LoadSectionTree(ii);
|
||||
}
|
||||
private void LoadSectionTree(ItemInfo ii)
|
||||
{
|
||||
foreach (SectionInfo si in ii.Sections)
|
||||
{
|
||||
if (si.IsStepSection)
|
||||
{
|
||||
if(si.Sections != null)LoadSectionTree(si);
|
||||
}
|
||||
else
|
||||
{
|
||||
MyPdfFile = _MyPromsPrinter.BuildMSWordPDF(si);
|
||||
if (MyPdfFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
MyReader = MyPdfFile != null ? new PdfReader(MyPdfFile) : null;
|
||||
string key = string.Empty;
|
||||
for (int i = 1; i <= MyReader.NumberOfPages; i++)
|
||||
{
|
||||
key = string.Format("{0}.{1}", si.ItemID, i);
|
||||
dicPage.Add(key, MyPromsPrinter.MyContentByte.PdfWriter.GetImportedPage(MyReader, i));
|
||||
dicSize.Add(key, MyReader.GetPageSizeWithRotation(i));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, ex.GetType().FullName, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
_MyLog.Warn(string.Format("Error in LoadSectionTree [{0}],{1}.{2}", si.ItemID, si.DisplayNumber, si.DisplayText), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//public class PrintTimer
|
||||
//{
|
||||
// private DateTime _StartTime = DateTime.Now;
|
||||
|
@ -299,7 +299,7 @@ namespace Volian.Print.Library
|
||||
box = null;
|
||||
yoff += 1 * vlnPrintObject.SixLinesPerInch;
|
||||
}
|
||||
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight,true,null);
|
||||
vlnParagraph para = new vlnParagraph(Parent, cb, childItemInfo, xoff, yoff, rnoLevel, maxRNO, formatInfo, null, null, yoffRight,true, pp);
|
||||
|
||||
// if doing the component list (FNP), keep track of the bottom most columns' data
|
||||
// so this can be returned after the row is done.
|
||||
@ -1171,17 +1171,19 @@ namespace Volian.Print.Library
|
||||
bool doThreeContinues = false;
|
||||
// For BGE, the very first subsection's pagelist items were not correct - the section/meta section titles were
|
||||
// at the wrong level. Reset the page helper's section.
|
||||
if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse)
|
||||
if (MyItemInfo.IsStepSection)
|
||||
{
|
||||
// if parent was continuous & this is separate, don't reset document style to subsection (next page) type
|
||||
// this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments.
|
||||
if ((MyParent.MyItemInfo as SectionInfo).IsSeparatePagination() || !(MyItemInfo as SectionInfo).IsSeparatePagination())
|
||||
if (MyItemInfo.IsSection && MyItemInfo.MyPrevious == null && MyItemInfo.MyParent.IsSection && !MyItemInfo.ActiveFormat.PlantFormat.FormatData.PrintData.SpecialCaseWestinghouse)
|
||||
{
|
||||
MyPageHelper.MySection = MyItemInfo as SectionInfo;
|
||||
MyPageHelper.ResetSvg();
|
||||
// if parent was continuous & this is separate, don't reset document style to subsection (next page) type
|
||||
// this was putting incorrect pagelist item on parent section's page. This occurred in BGE/OI3 set/OI-7 procedure/10.0 Attachments.
|
||||
if ((MyParent.MyItemInfo as SectionInfo).IsSeparatePagination() || !(MyItemInfo as SectionInfo).IsSeparatePagination())
|
||||
{
|
||||
MyPageHelper.MySection = MyItemInfo as SectionInfo;
|
||||
MyPageHelper.ResetSvg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For Calvert Alarms: A macro exists around the CONDITION/RESPONSE portion. If the page break occurs so that
|
||||
// this 'table' moved to the following page AND there is an associated note/caution that is not on the next page,
|
||||
// remove the macro so that the header macro doesn't print on the page with the note (without this, an extraneous
|
||||
@ -1197,17 +1199,15 @@ namespace Volian.Print.Library
|
||||
}
|
||||
if (IsWordDocPara)
|
||||
{
|
||||
PdfReader tmp = null;
|
||||
string tmpstr = null;
|
||||
SectionInfo si = SectionInfo.Get(MyItemInfo.ItemID);
|
||||
//Changing this caused Header issues for FNP FNP-1-FRP-1.3 Attachment 3 (Word Sub-Sections)
|
||||
//SectionInfo si1 = MyItemInfo.GetSectionInfo();
|
||||
//CompareSectionInfo(si, si1);
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage(true);
|
||||
//_MyLog.InfoFormat("NewPage 9 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
// Add Bookmark for Word Subsections
|
||||
MyPageHelper.PageBookmarks.Add(si, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
|
||||
MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si, ref tmp, ref tmpstr);
|
||||
MyPageHelper.MyPromsPrinter.CreateWordDocPdf(cb, si);
|
||||
Processed = true;
|
||||
{
|
||||
ProfileTimer.Pop(profileDepth);
|
||||
@ -1268,7 +1268,7 @@ namespace Volian.Print.Library
|
||||
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
|
||||
bool doSectionContinue = !MyItemInfo.IsSection && ((docstyle.StructureStyle.Style & E_DocStructStyle.BottomSectionContinue) == E_DocStructStyle.BottomSectionContinue);
|
||||
if (doSectionContinue) DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, false);
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 10 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
if (MyItemInfo.IsSection && MyParent != null && MyParent.MyItemInfo.IsSection && (MyItemInfo as SectionInfo).IsSeparatePagination())
|
||||
{
|
||||
@ -1291,7 +1291,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
// Only do foldout page if not done for section break, i.e. check the there's a previous step.
|
||||
if (MyItemInfo.MyPrevious != null && MyItemInfo.FoldoutIndex() > -1)
|
||||
PromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||
MyPromsPrinter.DoFoldoutPage(cb, "HLS", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||
{
|
||||
// insert a blank page if this step section had a foldout associated and the checkbox
|
||||
@ -1301,7 +1301,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
MyPageHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 10 blank {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
}
|
||||
@ -1364,7 +1364,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
|
||||
DoBottomContinueMsg(cb, yBottomMargin, yLocation, docstyle, doThreeContinues);
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
if (MyItemInfo.IsStep && ((MyItemInfo.MyActiveSection.MyDocStyle.StructureStyle.Style & E_DocStructStyle.DSS_PageListSpBckgrnd) == E_DocStructStyle.DSS_PageListSpBckgrnd))
|
||||
{
|
||||
// check if parent (can be HLS, Caution or Note) has the UseOldTemplate. If so,
|
||||
@ -1386,12 +1386,12 @@ namespace Volian.Print.Library
|
||||
|
||||
DebugText.WriteLine("Paginate2");
|
||||
if (MyItemInfo.MyHLS.FoldoutIndex() > -1)
|
||||
PromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout
|
||||
MyPromsPrinter.DoFoldoutPage(cb, "Break within Step", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.MyHLS.FoldoutIndex(), false); // temporary foldout
|
||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||
{
|
||||
MyPageHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
_MyLog.InfoFormat("NewPage Break within step blank {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
|
||||
@ -1477,7 +1477,7 @@ namespace Volian.Print.Library
|
||||
if (MyItemInfo.MyHLS != null && MyItemInfo.MyHLS.FormatStepData.UseSmartTemplate)
|
||||
{
|
||||
DoSubs = false;
|
||||
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0,false,null);
|
||||
vlnParagraph smartPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.MyHLS, MyParent.XOffset, yPageStart, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, " (Continued)", 0,false, MyPromsPrinter);
|
||||
smartPara.PrintHeader = true;
|
||||
float mytmpfloat = smartPara.ParagraphToPdf(cb, yPageStart, yTopMargin, yBottomMargin);
|
||||
yPageStart -= smartPara.Height;
|
||||
@ -1498,7 +1498,7 @@ namespace Volian.Print.Library
|
||||
{
|
||||
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
|
||||
if (MyPageHelper.NotesToFootNotes != null && MyPageHelper.NotesToFootNotes.Count > 0) MyPageHelper.NotesToFootNotesYoffset = CalculateYLocation(yLocation, yTopMargin);
|
||||
cb.PdfDocument.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection)
|
||||
MyPromsPrinter.NewPage(); // HLS (7 lpi) breakif (MyItemInfo.IsSection)
|
||||
//_MyLog.InfoFormat("NewPage 12 {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
//Console.WriteLine("'b3',{0},'{1}',{2},{3},{4},{5},{6}", MyItemInfo.ItemID, MyItemInfo.ShortPath, yTopMargin, yPageStart, yLocation, YTopMost, YOffset);
|
||||
ResetDocStyleAndValues(ref yTopMargin, ref yBottomMargin);
|
||||
@ -1510,14 +1510,14 @@ namespace Volian.Print.Library
|
||||
MyPageHelper.PageBookmarks.Add(MyItemInfo, ((si.DisplayNumber ?? "") == "" ? "" : si.DisplayNumber + " - ") + si.DisplayText, null);
|
||||
}
|
||||
if (MyItemInfo.FoldoutIndex() > -1)
|
||||
PromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||
MyPromsPrinter.DoFoldoutPage(cb, "HLS (7 lpi) break", MyPageHelper.TextLayer, MyPageHelper, MyItemInfo.FoldoutIndex(), false);
|
||||
else if (PromsPrinter.MyFoldoutReader.Count > 0 && MyPageHelper.MyPromsPrinter.InsertBlankPages)
|
||||
{
|
||||
// insert a blank page if this step section had a foldout associated and the checkbox
|
||||
// on the print dialog, to add blank pages, is checked
|
||||
MyPageHelper.OnBlankPage = true;
|
||||
cb.PdfDocument.Add(new iTextSharp.text.Table(1));
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
//_MyLog.InfoFormat("NewPage 12 lpi blank {0}", cb.PdfWriter.CurrentPageNumber);
|
||||
}
|
||||
if (MyItemInfo.MyDocStyle.LandscapePageList)
|
||||
@ -1573,7 +1573,7 @@ namespace Volian.Print.Library
|
||||
// get to the correct section for the message, i.e. if on a section, the message should be the parent
|
||||
// section (not the activesection which is myself); if on a step, the message should be the active section
|
||||
ItemInfo sectForCont = MyItemInfo.IsSection && MyItemInfo.MyParent.IsSection ? MyItemInfo.MyParent : MyItemInfo.ActiveSection;
|
||||
sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,null);
|
||||
sectContPara = new vlnParagraph(MyParent.MyParent, cb, sectForCont, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,MyPromsPrinter);
|
||||
if (sectContPara.PartsLeft.Count > 0)
|
||||
{
|
||||
vlnTab vt = sectContPara.MyTab;
|
||||
@ -1600,7 +1600,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
else
|
||||
{
|
||||
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false,null);
|
||||
sectContPara = new vlnParagraph(MyParent.MyParent, cb, MyItemInfo.ActiveSection, MyParent.XOffset, 0, 0, 0, MyParent.MyItemInfo.ActiveFormat, null, (contMsg == null || contMsg == "") ? " (Continued)" : contMsg, 0, false, MyPromsPrinter);
|
||||
float mytmpfloat = sectContPara.ParagraphToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
|
||||
if (sectContPara.SectionContinuePrinted)
|
||||
yPageStart -= sectContPara.Height + SixLinesPerInch;
|
||||
@ -1616,7 +1616,7 @@ namespace Volian.Print.Library
|
||||
yPageStart = ChildrenLeft.ToPdf(cb, yPageStart, ref yTopMargin, ref yBottomMargin);
|
||||
|
||||
// Handle the PageBreakOnStep flag for a HLS. This will put out the page break right before
|
||||
// a HLS. One example of this use is for backgrounds (CALBCK).
|
||||
// a HLS. One example of this use is for backgrounds (CALBCK).
|
||||
// 'this' below is a highlevel step, and the only time that ParaBreaks[0] will == 'this' is
|
||||
// when the PageBreakOnStep flag is true.
|
||||
if (MyPageHelper.ParaBreaks != null && MyPageHelper.ParaBreaks.Count > 0 &&
|
||||
@ -1626,7 +1626,7 @@ namespace Volian.Print.Library
|
||||
OutputOtherPageSteps(cb, YTopMost, yPageStart, yTopMargin, yBottomMargin);
|
||||
MyPageHelper.BottomMessage = null;
|
||||
MyPageHelper.TopMessage = null;
|
||||
cb.PdfDocument.NewPage();
|
||||
MyPromsPrinter.NewPage();
|
||||
if (CompressPartOfStep)
|
||||
{
|
||||
MyPageHelper.YMultiplier = _SevenLinesPerInch / SixLinesPerInch;
|
||||
@ -1778,7 +1778,7 @@ namespace Volian.Print.Library
|
||||
}
|
||||
if (!inlist)
|
||||
{
|
||||
vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, null);
|
||||
vlnParagraph vpFNote = new vlnParagraph(null, cb, inote, (float)MyItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, 0, MyItemInfo.ActiveFormat, null, null, 0, false, MyPromsPrinter);
|
||||
vpFNote.Width = (float)MyItemInfo.MyDocStyle.Layout.PageWidth - (float)MyItemInfo.MyDocStyle.Layout.LeftMargin;
|
||||
vpFNote.Height = 0;
|
||||
vpFNote.XOffset = (float)MyItemInfo.MyDocStyle.Layout.LeftMargin;
|
||||
@ -2395,8 +2395,15 @@ namespace Volian.Print.Library
|
||||
return (float)(MyItemInfo.MyDocStyle.Layout.PageLength /*- MyItemInfo.MyDocStyle.Layout.TopMargin*/ - MyItemInfo.MyDocStyle.Layout.FooterLength);
|
||||
}
|
||||
}
|
||||
private PromsPrinter _MyPromsPrinter;
|
||||
public PromsPrinter MyPromsPrinter
|
||||
{
|
||||
get { return _MyPromsPrinter; }
|
||||
set { _MyPromsPrinter = value; }
|
||||
}
|
||||
public vlnParagraph(vlnParagraph parent, PdfContentByte cb, ItemInfo itemInfo, float xoff, float yoff, int rnoLevel, int maxRNO, FormatInfo formatInfo, string prefix, string suffix, float yoffRightParent, bool loadChildren, PromsPrinter pp)
|
||||
{
|
||||
MyPromsPrinter = pp ?? parent.MyPromsPrinter;
|
||||
int profileDepth = ProfileTimer.Push(">>>> vlnParagraph");
|
||||
Prefix = prefix;
|
||||
Suffix = suffix;
|
||||
|
Loading…
x
Reference in New Issue
Block a user