This commit is contained in:
Kathy Ruffing 2010-08-24 13:46:10 +00:00
parent 3045458050
commit f7127f1fff
3 changed files with 23 additions and 56 deletions

View File

@ -121,7 +121,13 @@ namespace Volian.Print.Library
get { return _OpenPDF; }
set { _OpenPDF = value; }
}
public PromsPrinter(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, string backgroundFolder,bool openPDF)
private ChangeBarDefinition _MyChangeBarDefinition;
public ChangeBarDefinition MyChangeBarDefinition
{
get { return _MyChangeBarDefinition; }
set { _MyChangeBarDefinition = value; }
}
public PromsPrinter(ItemInfo myItem, string rev, string revDate, string watermark, bool debugOutput, string backgroundFolder,bool openPDF, ChangeBarDefinition cbd)
{
_MyItem = myItem;
_Rev = rev;
@ -130,6 +136,7 @@ namespace Volian.Print.Library
_DebugOutput = debugOutput;
_BackgroundFolder = backgroundFolder;
_OpenPDF = openPDF;
_MyChangeBarDefinition = cbd;
}
public string Print(string pdfFolder)
{
@ -187,8 +194,17 @@ namespace Volian.Print.Library
private PdfContentByte OpenDoc(string outputFileName)
{
PdfWriter writer=null;
iTextSharp.text.Document document = new iTextSharp.text.Document(PageSize.LETTER);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outputFileName, FileMode.Create));
try
{
writer = PdfWriter.GetInstance(document, new FileStream(outputFileName, FileMode.Create));
}
catch (Exception ex)
{
MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry", "Error on CreatePdf");
return null;
}
document.Open();
// Create Layers
CreateLayers(writer.DirectContent);
@ -225,6 +241,7 @@ namespace Volian.Print.Library
// Setup a pdf Document for printing
OnStatusChanged("Before OpenDoc", PromsPrinterStatusType.Before);
PdfContentByte cb = OpenDoc(outputFileName);
if (cb == null) return null;
OnStatusChanged("Before NewPage", PromsPrinterStatusType.Before);
cb.PdfDocument.NewPage();
OnStatusChanged("After NewPage", PromsPrinterStatusType.NewPage);
@ -348,65 +365,12 @@ namespace Volian.Print.Library
vlnParagraph.Prefix = myItemInfo.Path;
Rtf2Pdf.PdfDebug = true;
Rtf2Pdf.Offset = new PointF(24, 2.5F);
_MyHelper.ChangeBarDefinition = DetermineChangeBarSettings(myItemInfo);
_MyHelper.ChangeBarDefinition = MyChangeBarDefinition;
vlnParagraph myParagraph = new vlnParagraph(null, cb, myItemInfo, (float)myItemInfo.MyDocStyle.Layout.LeftMargin, 0, 0, myItemInfo.ColumnMode, myItemInfo.ActiveFormat);
myParagraph.ToPdf(cb, yTopMargin, yTopMargin, yBottomMargin);
cb.PdfDocument.NewPage();
OnStatusChanged("StepSection converted to PDF " + section.ShortPath, PromsPrinterStatusType.BuildStep);
}
// Determine if any menu selections for change bars have overridden the data
// supplied in the format file. Settings are location and text.
// We could also put up the dialog for change bars if option is 'User Specified',
// i.e. prompt before printing.
private ChangeBarDefinition DetermineChangeBarSettings(ItemInfo myItemInfo)
{
// get to procedure level:
ItemInfo ii = myItemInfo;
while (ii.MyContent.Type != 0)
{
ii = ii.MyActiveParent as ItemInfo;
}
DocVersionInfo dvi = ii.MyActiveParent as DocVersionInfo;
if (dvi == null) return null; // should never be null!
DocVersionConfig docverConfig = dvi.MyConfig as DocVersionConfig;
ChangeBarDefinition cbd = new ChangeBarDefinition();
// if there is not overridden data on the docversion, prompt user...
ChangeBarData changeBarData = myItemInfo.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData;
if (docverConfig == null || docverConfig.Print_ChangeBar == PrintChangeBar.SelectBeforePrinting)
{
// use these for now, i.e. this is what user would have selected from dialog.
cbd.MyChangeBarType = PrintChangeBar.WithDefault;
cbd.MyChangeBarLoc = PrintChangeBarLoc.OutsideBox;
cbd.MyChangeBarText = PrintChangeBarText.None;
}
else
{
cbd.MyChangeBarType = docverConfig.Print_ChangeBar;
cbd.MyChangeBarLoc = docverConfig.Print_ChangeBarLoc;
cbd.MyChangeBarText = docverConfig.Print_ChangeBarText;
}
if (cbd.MyChangeBarType == PrintChangeBar.WithDefault) // get data from format
{
cbd.MyChangeBarText = changeBarData.ChangeBarMessage == "ChgID" ? PrintChangeBarText.ChgID :
changeBarData.ChangeBarMessage == "DateAndChgID" ? PrintChangeBarText.DateChgID :
changeBarData.ChangeBarMessage == "None" ? PrintChangeBarText.None :
changeBarData.ChangeBarMessage == "RevNum" ? PrintChangeBarText.RevNum : PrintChangeBarText.UserDef;
}
if (cbd.MyChangeBarType != PrintChangeBar.Without)
{
// if the format has the absolutefixedchangecolumn format flag, then always use the fixedchangecolumn from the
// format, otherwise, use the default column based on the selected location, stored in the base format.
cbd.MyChangeBarColumn = (changeBarData.AbsoluteFixedChangeColumn) ?
(int)changeBarData.FixedChangeColumn :
System.Convert.ToInt32(changeBarData.DefaultCBLoc.Split(" ".ToCharArray())[System.Convert.ToInt32(cbd.MyChangeBarLoc)]);
if (cbd.MyChangeBarText == PrintChangeBarText.UserDef)
cbd.MyChangeBarMessage = docverConfig.Print_UserCBMess1 + @"\n" + docverConfig.Print_UserCBMess2;
}
return cbd;
}
private SvgPart PageItemToSvgText(PageItem pageItem, string text, float yOffset)
{
SvgText svgText = new SvgText();

View File

@ -196,6 +196,7 @@ namespace Volian.Print.Library
}
public void AddChangeBar(vlnChangeBar vcb, string cbmess)
{
if (vcb == null) return;
vlnChangeBar prevCB = null;
foreach (vlnChangeBar cb in MyChangeBars)
{

View File

@ -749,6 +749,8 @@ namespace Volian.Print.Library
private string cbMess = null;
private vlnChangeBar DoChangeBar(PdfContentByte cb, ItemInfo itemInfo, VlnSvgPageHelper myPageHelper, float xoff, float yoff, int maxRNO, FormatInfo formatInfo) //, vlnChangeBar myCB)
{
if (myPageHelper.ChangeBarDefinition.MyChangeBarType == PrintChangeBar.Without) return null;
// find column for the change bar based on format flags - this is code from 16-bit
// if AbsoluteFixedChangeColumn
// if FixedAERChangeColumn