This commit is contained in:
parent
afde4b2516
commit
38ef93b9fd
@ -54,7 +54,10 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
string fstr = pct.Text.Replace("{OF}", _Total.ToString());
|
string fstr = pct.Text.Replace("{OF}", _Total.ToString());
|
||||||
|
if (pct.Text.Contains("{TOCPAGE}"))
|
||||||
|
{
|
||||||
|
fstr = pct.Text.Replace("{TOCPAGE}", _Total.ToString());
|
||||||
|
}
|
||||||
if (fstr.Contains("{FINALPAGE}"))
|
if (fstr.Contains("{FINALPAGE}"))
|
||||||
{
|
{
|
||||||
fstr = fstr.Replace("{FINALPAGE}", (cnt == MyTemplates.Count) ? FinalPageMessage : "");
|
fstr = fstr.Replace("{FINALPAGE}", (cnt == MyTemplates.Count) ? FinalPageMessage : "");
|
||||||
@ -95,6 +98,7 @@ namespace Volian.Print.Library
|
|||||||
Increment();
|
Increment();
|
||||||
PageCountTemplate retTemplate = new PageCountTemplate(pdfWriter, text.Replace("{PAGE}",Total.ToString()), myFont, alignment, color);
|
PageCountTemplate retTemplate = new PageCountTemplate(pdfWriter, text.Replace("{PAGE}",Total.ToString()), myFont, alignment, color);
|
||||||
MyTemplates.Add(retTemplate);
|
MyTemplates.Add(retTemplate);
|
||||||
|
|
||||||
return retTemplate.MyTemplate;
|
return retTemplate.MyTemplate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,7 +116,11 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
public PdfTemplate AddToTemplateList(string key, PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
|
public PdfTemplate AddToTemplateList(string key, PdfWriter pdfWriter, string text, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
|
||||||
{
|
{
|
||||||
if (!this.ContainsKey(key)) this.Add(key, new PageCount());
|
if (!this.ContainsKey(key))
|
||||||
|
{
|
||||||
|
this.Add(key, new PageCount());
|
||||||
|
if (key.StartsWith("TOC")) this[key].CanIncrement = false;
|
||||||
|
}
|
||||||
return (this[key].AddToTemplateList(pdfWriter, text, myFont, alignment,color));
|
return (this[key].AddToTemplateList(pdfWriter, text, myFont, alignment,color));
|
||||||
}
|
}
|
||||||
public PdfTemplate AddToTemplateList(string key, PdfWriter pdfWriter, string text, string finalPageMessage, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
|
public PdfTemplate AddToTemplateList(string key, PdfWriter pdfWriter, string text, string finalPageMessage, System.Drawing.Font myFont, int alignment, System.Drawing.Color color)
|
||||||
|
@ -256,7 +256,6 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
return Regex.Replace(name, "[ .,/]", "_") + ".pdf";
|
return Regex.Replace(name, "[ .,/]", "_") + ".pdf";
|
||||||
}
|
}
|
||||||
int _StepPageNumber = 0;
|
|
||||||
private VlnSvgPageHelper _MyHelper = null;
|
private VlnSvgPageHelper _MyHelper = null;
|
||||||
private static PdfReader _MyFoldoutReader = null;
|
private static PdfReader _MyFoldoutReader = null;
|
||||||
private static SectionInfo _MyFoldoutSection = null;
|
private static SectionInfo _MyFoldoutSection = null;
|
||||||
@ -364,7 +363,13 @@ namespace Volian.Print.Library
|
|||||||
PdfReader readerWord = null;
|
PdfReader readerWord = null;
|
||||||
string myPdfFile = null;
|
string myPdfFile = null;
|
||||||
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
||||||
if (mySection.IsStepSection)
|
SectionConfig sc = mySection.MyConfig as SectionConfig;
|
||||||
|
if ((myProcedure.ActiveFormat.PlantFormat.FormatData.PurchaseOptions & E_PurchaseOptions.AutoTableOfContents) == E_PurchaseOptions.AutoTableOfContents && mySection.MyContent.Text.ToUpper() == "TABLE OF CONTENTS")
|
||||||
|
{
|
||||||
|
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (mySection.IsStepSection)
|
||||||
{
|
{
|
||||||
if ((mySection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
if ((mySection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||||
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper);
|
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper);
|
||||||
@ -386,6 +391,13 @@ namespace Volian.Print.Library
|
|||||||
locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount-1)) * 100;
|
locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount-1)) * 100;
|
||||||
pdfSize = (float)myPdf.PageCount;
|
pdfSize = (float)myPdf.PageCount;
|
||||||
}
|
}
|
||||||
|
string tocKey = string.Format("TOC{0}", mySection.ItemID);
|
||||||
|
if (_MyHelper.MyTOCPageCounts.ContainsKey(tocKey))
|
||||||
|
{
|
||||||
|
PageCount pc = _MyHelper.MyTOCPageCounts[tocKey];
|
||||||
|
pc.Total = _MyHelper.CurrentPageNumber;
|
||||||
|
pc.DrawTemplates();
|
||||||
|
}
|
||||||
for (int ii = 0; ii < sectPageCount; ii++)
|
for (int ii = 0; ii < sectPageCount; ii++)
|
||||||
{
|
{
|
||||||
int pageNumber = 1 + ii;
|
int pageNumber = 1 + ii;
|
||||||
@ -453,6 +465,92 @@ namespace Volian.Print.Library
|
|||||||
return outputFileName;
|
return outputFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void GenerateTOC(SectionInfo tocSection, ProcedureInfo myProcedure, PdfContentByte cb, PdfLayer textLayer)
|
||||||
|
{
|
||||||
|
iTextSharp.text.pdf.PdfWriter writer = cb.PdfWriter;
|
||||||
|
float _PointsPerPage = 792;
|
||||||
|
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);
|
||||||
|
TableOfContentsData tOfC = tocSection.ActiveFormat.PlantFormat.FormatData.SectData.AccSectionData.TableOfContentsData;
|
||||||
|
ItemInfo procItem = ItemInfo.Get(myProcedure.ItemID);
|
||||||
|
lastyLocation = 0;
|
||||||
|
AddSectionToTOC(tocSection, procItem, tOfC, cb, yTopMargin, 0);
|
||||||
|
if (textLayer != null) cb.EndLayer();
|
||||||
|
cb.PdfDocument.NewPage();
|
||||||
|
_NoBreakYOffset = 0;
|
||||||
|
}
|
||||||
|
float lastyLocation = 0;
|
||||||
|
private float AddSectionToTOC(SectionInfo tocSection, ItemInfo ii, TableOfContentsData tOfC, PdfContentByte cb, float yPageStart, float yLocation)
|
||||||
|
{
|
||||||
|
// The following adjustments are for WCN1:
|
||||||
|
// for xAdjNumber: 6 is for 1 char less in 16bit (\promsnt\exe\print\tabocont.c, method 'howMany'.
|
||||||
|
// 1.2 is a tweak to get output to match between 16 & 32 bit.
|
||||||
|
// for xAdjTitle: .8 & 1.2 are both tweaks to get output to match.
|
||||||
|
// for xAdjTitleIndent: 6 is for 1 char less. 2.4 is a tweak
|
||||||
|
float xAdjNumber = -6 + 1.2F;
|
||||||
|
float xAdjTitle = .8F + 1.2F;
|
||||||
|
float xAdjTitleIndent = -6 + 2.4F;
|
||||||
|
float yadj = 0.5F; // tweak to get 16 & 32 bit output to match.
|
||||||
|
|
||||||
|
float yPageStartAdj = yPageStart - yadj;
|
||||||
|
float leftMargin = (float)tocSection.MyDocStyle.Layout.LeftMargin;
|
||||||
|
iTextSharp.text.Font font = FontFactory.GetFont(tOfC.Font.WindowsFont.Name, tOfC.Font.WindowsFont.Size, new iTextSharp.text.Color(PrintOverride.TextColor));
|
||||||
|
iTextSharp.text.Font font12cpi = FontFactory.GetFont(tOfC.Font.WindowsFont.Name, 10, new iTextSharp.text.Color(PrintOverride.TextColor));
|
||||||
|
float secNumPos = (float)tOfC.TofCSecNumPos + xAdjNumber;
|
||||||
|
float secTitlePos = (float)tOfC.TofCSecTitlePos + xAdjTitle;
|
||||||
|
float secPagePos = (float)tOfC.TofCPageNumPos + xAdjNumber;
|
||||||
|
|
||||||
|
if (ii.Sections != null)
|
||||||
|
{
|
||||||
|
foreach (SectionInfo mySection in ii.Sections)
|
||||||
|
{
|
||||||
|
SectionConfig sc = mySection.MyConfig as SectionConfig;
|
||||||
|
if (sc != null && sc.Section_TOC == "Y")
|
||||||
|
{
|
||||||
|
// need to do the section number, section title & page number. Page number
|
||||||
|
// has to be put on at end after number of page is known, so use a Template.
|
||||||
|
Chunk chk = new Chunk(mySection.MyContent.Number, font);
|
||||||
|
Paragraph myparagraph = new Paragraph(chk);
|
||||||
|
myparagraph.Leading = font.Size;
|
||||||
|
float height = font.Size * 1.5F;
|
||||||
|
float width = chk.GetWidthPoint();
|
||||||
|
float numwidth = width;
|
||||||
|
float yBottomMargin = Math.Max(0, (float)tocSection.MyDocStyle.Layout.TopMargin - (float)tocSection.MyDocStyle.Layout.PageLength - 2 * vlnPrintObject.SixLinesPerInch);
|
||||||
|
Rtf2Pdf.Offset = new PointF(0, 2.5F);
|
||||||
|
float retval = Rtf2Pdf.TextAt(cb, myparagraph, leftMargin + secNumPos, yPageStart - yLocation, width*1.3F, height, "", yBottomMargin);
|
||||||
|
if (retval == 0) // do a newpage, it couldn't fit on current page.
|
||||||
|
{
|
||||||
|
cb.PdfDocument.NewPage();
|
||||||
|
yLocation = 0;
|
||||||
|
retval = Rtf2Pdf.TextAt(cb, myparagraph, leftMargin + secNumPos, yPageStart - yLocation, width*1.3F, height, "", yBottomMargin);
|
||||||
|
}
|
||||||
|
// if the starting column of text would be in 'middle of' the number, just put it
|
||||||
|
// a few spaces after the number. The '18' below represents 3 chars.
|
||||||
|
Chunk chkt = new Chunk(mySection.MyContent.Text, font);
|
||||||
|
float adjSecTitlePos = secTitlePos;
|
||||||
|
if (secNumPos + numwidth > secTitlePos)
|
||||||
|
adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent;
|
||||||
|
Paragraph myparagrapht = new Paragraph(chkt);
|
||||||
|
myparagrapht.Leading = font.Size;
|
||||||
|
width = secPagePos - adjSecTitlePos - 6;
|
||||||
|
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||||
|
// add a template for the page number:
|
||||||
|
if (lastyLocation != 0 && ((lastyLocation - retval) > vlnPrintObject.SixLinesPerInch))
|
||||||
|
yLocation += (lastyLocation - retval - vlnPrintObject.SixLinesPerInch);
|
||||||
|
lastyLocation = retval;
|
||||||
|
|
||||||
|
string key = "TOC" + mySection.ItemID.ToString();
|
||||||
|
PdfTemplate tmp = _MyHelper.MyTOCPageCounts.AddToTemplateList(key, _MyHelper.MyPdfWriter, "{TOCPAGE}", tOfC.Font.WindowsFont, Element.ALIGN_LEFT, PrintOverride.TextColor);
|
||||||
|
_MyHelper.MyPdfContentByte.AddTemplate(tmp, leftMargin + secPagePos, (yPageStartAdj - yLocation) - height / 2);
|
||||||
|
|
||||||
|
yLocation += vlnPrintObject.SixLinesPerInch;
|
||||||
|
yLocation = AddSectionToTOC(tocSection, mySection, tOfC, cb, yPageStart, yLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return yLocation;
|
||||||
|
}
|
||||||
private static void PrintTextMessage(PdfContentByte cb, string message, PdfLayer textLayer)
|
private static void PrintTextMessage(PdfContentByte cb, string message, PdfLayer textLayer)
|
||||||
{
|
{
|
||||||
if (textLayer != null) cb.BeginLayer(textLayer);
|
if (textLayer != null) cb.BeginLayer(textLayer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user