This commit is contained in:
parent
c7383915ec
commit
fed3b1e913
@ -365,7 +365,7 @@ namespace Volian.Print.Library
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!mySection.IsStepSection)_MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
|
if (!mySection.IsStepSection) _MyHelper.PageBookmarks.Add((ItemInfo)mySection, ((mySection.DisplayNumber ?? "") == "" ? "" : mySection.DisplayNumber + " - ") + mySection.DisplayText, null);
|
||||||
_MyHelper.MySection = mySection;
|
_MyHelper.MySection = mySection;
|
||||||
OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG);
|
OnStatusChanged("After Set Svg", PromsPrinterStatusType.SetSVG);
|
||||||
}
|
}
|
||||||
@ -373,89 +373,87 @@ namespace Volian.Print.Library
|
|||||||
string myPdfFile = null;
|
string myPdfFile = null;
|
||||||
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
_MyHelper.FinalMessageSectionID = finalMessageSectionID; // set VlnSvgPageHelper with the finalMessageSectionID
|
||||||
SectionConfig sc = mySection.MyConfig as SectionConfig;
|
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")
|
if (mySection.IsAutoTOCSection)
|
||||||
{
|
|
||||||
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
GenerateTOC(mySection, myProcedure, cb, _TextLayer);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
if (mySection.IsStepSection)
|
if (mySection.IsStepSection)
|
||||||
{
|
|
||||||
if ((mySection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
|
||||||
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper);
|
|
||||||
CreateStepPdf(mySection, cb);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
myPdfFile = BuildMSWordPDF(mySection);
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null;
|
if ((mySection.MyDocStyle.StructureStyle.Style ?? 0 & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||||
OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection);
|
DoFoldoutPage(cb, "Beginning of Step Section", _TextLayer, _MyHelper);
|
||||||
int sectPageCount = 0;
|
CreateStepPdf(mySection, cb);
|
||||||
float locEndOfWordDoc = 0;
|
|
||||||
float pdfSize = 0;
|
|
||||||
using (PdfInfo myPdf = PdfInfo.Get(mySection))
|
|
||||||
{
|
|
||||||
sectPageCount = (int)(Math.Ceiling(myPdf.PageCount));
|
|
||||||
locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount-1)) * 100;
|
|
||||||
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++)
|
|
||||||
{
|
|
||||||
int pageNumber = 1 + ii;
|
|
||||||
//mySection.PageNumForDocStyle = pageNumber;
|
|
||||||
if (((mySection.MyDocStyle.StructureStyle.Style ?? 0) & E_DocStructStyle.UseSectionFoldout) != 0)
|
|
||||||
DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper);
|
|
||||||
if (readerWord != null)
|
|
||||||
{
|
|
||||||
bool doimport2 = true;
|
|
||||||
PdfImportedPage fgPage = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
fgPage = cb.PdfWriter.GetImportedPage(readerWord, ii + 1);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine(ex);
|
|
||||||
doimport2 = false;
|
|
||||||
}
|
|
||||||
OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord);
|
|
||||||
if (doimport2) AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, 0);
|
|
||||||
if (ii == sectPageCount - 1)
|
|
||||||
{
|
|
||||||
// if there's and end message, add it to the appropriate location on the last page of
|
|
||||||
// the word document:
|
|
||||||
if ((mySection.MyDocStyle.End.Message ?? "") != "")
|
|
||||||
{
|
|
||||||
float ylocation = cb.PdfDocument.PageSize.Height - ((float)mySection.MyDocStyle.Layout.TopMargin + locEndOfWordDoc * 72); // 72 - pts per inch.
|
|
||||||
iTextSharp.text.Font fnt = VolianPdf.GetFont(mySection.MyDocStyle.End.Font.WindowsFont);
|
|
||||||
fnt.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
|
|
||||||
iTextSharp.text.Paragraph para = new Paragraph(mySection.MyDocStyle.End.Message, fnt);
|
|
||||||
float wtpm = (float)mySection.MyDocStyle.Layout.PageWidth - (float)mySection.MyDocStyle.Layout.LeftMargin;
|
|
||||||
float centerpos = (float)mySection.MyDocStyle.Layout.LeftMargin + (wtpm - (mySection.MyDocStyle.End.Message.Length * mySection.MyDocStyle.End.Font.CharsToTwips)) / 2;
|
|
||||||
float yBottomMargin = Math.Max(0, (float)mySection.MyDocStyle.Layout.TopMargin - (float)mySection.MyDocStyle.Layout.PageLength - 2 * vlnPrintObject.SixLinesPerInch);
|
|
||||||
Rtf2Pdf.TextAt(cb, para, centerpos, ylocation + 6, 100, 12, "", yBottomMargin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OnStatusChanged("Merge MSWord", PromsPrinterStatusType.MergeMSWord);
|
|
||||||
}
|
|
||||||
OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
|
|
||||||
cb.PdfDocument.NewPage(); // Word Document
|
|
||||||
|
|
||||||
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
else
|
||||||
{
|
{
|
||||||
cb.PdfDocument.NewPage(); // can we put out 'error on page'?
|
myPdfFile = BuildMSWordPDF(mySection);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
readerWord = myPdfFile != null ? new PdfReader(myPdfFile) : null;
|
||||||
|
OnStatusChanged("Get Section", PromsPrinterStatusType.GetSection);
|
||||||
|
int sectPageCount = 0;
|
||||||
|
float locEndOfWordDoc = 0;
|
||||||
|
float pdfSize = 0;
|
||||||
|
using (PdfInfo myPdf = PdfInfo.Get(mySection))
|
||||||
|
{
|
||||||
|
sectPageCount = (int)(Math.Ceiling(myPdf.PageCount));
|
||||||
|
locEndOfWordDoc = (float)(myPdf.PageCount - (sectPageCount - 1)) * 100;
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
int pageNumber = 1 + ii;
|
||||||
|
if (((mySection.MyDocStyle.StructureStyle.Style ?? 0) & E_DocStructStyle.UseSectionFoldout) != 0)
|
||||||
|
DoFoldoutPage(cb, "Word Document", _TextLayer, _MyHelper);
|
||||||
|
if (readerWord != null)
|
||||||
|
{
|
||||||
|
bool doimport2 = true;
|
||||||
|
PdfImportedPage fgPage = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
fgPage = cb.PdfWriter.GetImportedPage(readerWord, ii + 1);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine(ex);
|
||||||
|
doimport2 = false;
|
||||||
|
}
|
||||||
|
OnStatusChanged("Read MSWord", PromsPrinterStatusType.ReadMSWord);
|
||||||
|
if (doimport2) AddImportedPageToLayer(cb.PdfWriter.DirectContent, _MSWordLayer, fgPage, 0, 0);
|
||||||
|
if (ii == sectPageCount - 1)
|
||||||
|
{
|
||||||
|
// if there's and end message, add it to the appropriate location on the last page of
|
||||||
|
// the word document:
|
||||||
|
if ((mySection.MyDocStyle.End.Message ?? "") != "")
|
||||||
|
{
|
||||||
|
float ylocation = cb.PdfDocument.PageSize.Height - ((float)mySection.MyDocStyle.Layout.TopMargin + locEndOfWordDoc * 72); // 72 - pts per inch.
|
||||||
|
iTextSharp.text.Font fnt = VolianPdf.GetFont(mySection.MyDocStyle.End.Font.WindowsFont);
|
||||||
|
fnt.Color = new iTextSharp.text.Color(PrintOverride.OverrideTextColor(System.Drawing.Color.Black));
|
||||||
|
iTextSharp.text.Paragraph para = new Paragraph(mySection.MyDocStyle.End.Message, fnt);
|
||||||
|
float wtpm = (float)mySection.MyDocStyle.Layout.PageWidth - (float)mySection.MyDocStyle.Layout.LeftMargin;
|
||||||
|
float centerpos = (float)mySection.MyDocStyle.Layout.LeftMargin + (wtpm - (mySection.MyDocStyle.End.Message.Length * mySection.MyDocStyle.End.Font.CharsToTwips)) / 2;
|
||||||
|
float yBottomMargin = Math.Max(0, (float)mySection.MyDocStyle.Layout.TopMargin - (float)mySection.MyDocStyle.Layout.PageLength - 2 * vlnPrintObject.SixLinesPerInch);
|
||||||
|
Rtf2Pdf.TextAt(cb, para, centerpos, ylocation + 6, 100, 12, "", yBottomMargin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
OnStatusChanged("Merge MSWord", PromsPrinterStatusType.MergeMSWord);
|
||||||
|
}
|
||||||
|
OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
|
||||||
|
cb.PdfDocument.NewPage(); // Word Document
|
||||||
|
|
||||||
|
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
cb.PdfDocument.NewPage(); // can we put out 'error on page'?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,6 +488,16 @@ namespace Volian.Print.Library
|
|||||||
_NoBreakYOffset = 0;
|
_NoBreakYOffset = 0;
|
||||||
}
|
}
|
||||||
float lastyLocation = 0;
|
float lastyLocation = 0;
|
||||||
|
private string GetRtfToC(string txt, TableOfContentsData tOfCData)
|
||||||
|
{
|
||||||
|
StringBuilder _RtfSB = new StringBuilder();
|
||||||
|
Volian.Controls.Library.DisplayText toctxt = new Volian.Controls.Library.DisplayText(txt, tOfCData.Font, false);
|
||||||
|
System.Drawing.Font myFont = toctxt.TextFont.WindowsFont;
|
||||||
|
_RtfSB.Append(vlnPrintObject.AddFontTable(myFont));
|
||||||
|
_RtfSB.Append(toctxt.StartText);
|
||||||
|
_RtfSB.Append("}");
|
||||||
|
return _RtfSB.ToString();
|
||||||
|
}
|
||||||
private float AddSectionToTOC(SectionInfo tocSection, ItemInfo ii, TableOfContentsData tOfC, PdfContentByte cb, float yPageStart, float yLocation)
|
private float AddSectionToTOC(SectionInfo tocSection, ItemInfo ii, TableOfContentsData tOfC, PdfContentByte cb, float yPageStart, float yLocation)
|
||||||
{
|
{
|
||||||
// The following adjustments are for WCN1:
|
// The following adjustments are for WCN1:
|
||||||
@ -504,11 +512,10 @@ namespace Volian.Print.Library
|
|||||||
|
|
||||||
float yPageStartAdj = yPageStart - yadj;
|
float yPageStartAdj = yPageStart - yadj;
|
||||||
float leftMargin = (float)tocSection.MyDocStyle.Layout.LeftMargin;
|
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 secNumPos = (float)tOfC.TofCSecNumPos + xAdjNumber;
|
||||||
float secTitlePos = (float)tOfC.TofCSecTitlePos + xAdjTitle;
|
float secTitlePos = (float)tOfC.TofCSecTitlePos + xAdjTitle;
|
||||||
float secPagePos = (float)tOfC.TofCPageNumPos + xAdjNumber;
|
float secPagePos = (float)tOfC.TofCPageNumPos + xAdjNumber;
|
||||||
|
float height = tOfC.Font.WindowsFont.Size * 1.5F;
|
||||||
|
|
||||||
if (ii.Sections != null)
|
if (ii.Sections != null)
|
||||||
{
|
{
|
||||||
@ -519,29 +526,28 @@ namespace Volian.Print.Library
|
|||||||
{
|
{
|
||||||
// need to do the section number, section title & page number. Page number
|
// 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.
|
// 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);
|
string rtfText = GetRtfToC(mySection.MyContent.Number, tOfC);
|
||||||
Paragraph myparagraph = new Paragraph(chk);
|
Paragraph myparagraphn = vlnPrintObject.RtfToParagraph(rtfText);
|
||||||
myparagraph.Leading = font.Size;
|
float width = 0;
|
||||||
float height = font.Size * 1.5F;
|
foreach (Chunk chkt in myparagraphn.Chunks)
|
||||||
float width = chk.GetWidthPoint();
|
width += chkt.GetWidthPoint();
|
||||||
float numwidth = width;
|
float numwidth = width;
|
||||||
float yBottomMargin = Math.Max(0, (float)tocSection.MyDocStyle.Layout.TopMargin - (float)tocSection.MyDocStyle.Layout.PageLength - 2 * vlnPrintObject.SixLinesPerInch);
|
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);
|
Rtf2Pdf.Offset = new PointF(0, 2.5F);
|
||||||
float retval = Rtf2Pdf.TextAt(cb, myparagraph, leftMargin + secNumPos, yPageStart - yLocation, width*1.3F, height, "", yBottomMargin);
|
float retval = Rtf2Pdf.TextAt(cb, myparagraphn, leftMargin + secNumPos, yPageStart - yLocation, width*1.3F, height, "", yBottomMargin);
|
||||||
if (retval == 0) // do a newpage, it couldn't fit on current page.
|
if (retval == 0) // do a newpage, it couldn't fit on current page.
|
||||||
{
|
{
|
||||||
cb.PdfDocument.NewPage();
|
cb.PdfDocument.NewPage();
|
||||||
yLocation = 0;
|
yLocation = 0;
|
||||||
retval = Rtf2Pdf.TextAt(cb, myparagraph, leftMargin + secNumPos, yPageStart - yLocation, width*1.3F, height, "", yBottomMargin);
|
retval = Rtf2Pdf.TextAt(cb, myparagraphn, 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
|
// 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.
|
// a few spaces after the number. The '18' below represents 3 chars.
|
||||||
Chunk chkt = new Chunk(mySection.MyContent.Text, font);
|
|
||||||
float adjSecTitlePos = secTitlePos;
|
float adjSecTitlePos = secTitlePos;
|
||||||
if (secNumPos + numwidth > secTitlePos)
|
if (secNumPos + numwidth > secTitlePos)
|
||||||
adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent;
|
adjSecTitlePos = secNumPos + numwidth + 18 - xAdjTitleIndent;
|
||||||
Paragraph myparagrapht = new Paragraph(chkt);
|
rtfText = GetRtfToC(mySection.MyContent.Text, tOfC);
|
||||||
myparagrapht.Leading = font.Size;
|
Paragraph myparagrapht = vlnPrintObject.RtfToParagraph(rtfText);
|
||||||
width = secPagePos - adjSecTitlePos - 6;
|
width = secPagePos - adjSecTitlePos - 6;
|
||||||
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
retval = Rtf2Pdf.TextAt(cb, myparagrapht, leftMargin + adjSecTitlePos, yPageStart - yLocation, width, height, "", yBottomMargin);
|
||||||
// add a template for the page number:
|
// add a template for the page number:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user