Added “(red ? in the editor)” to the Include Missing ROs checkbox label. Default the checkbox to be unchecked, and added anApplication.DoEvents()

Fixed the preview of images containing more than one sample layer (iTextSharp error)
Fixed the printing of images containing more than one sample layer (iTextSharp error), added better error handling, added an Error bookmark group.
This commit is contained in:
John Jenko 2015-01-30 20:14:46 +00:00
parent 3ba1e71b4b
commit af99b05c2c
6 changed files with 272 additions and 86 deletions

View File

@ -722,10 +722,13 @@ namespace Volian.Controls.Library
{ {
string fname = selectedChld.value.Substring(0, selectedChld.value.IndexOf('\n')); string fname = selectedChld.value.Substring(0, selectedChld.value.IndexOf('\n'));
int thedot = fname.LastIndexOf('.'); int thedot = fname.LastIndexOf('.');
ROImageInfo tmp = null;
if (thedot == -1 || (thedot != (fname.Length - 4))) if (thedot == -1 || (thedot != (fname.Length - 4)))
{
tmp = ROImageInfo.GetByROFstID_FileName(MyROFST.ROFstID, fname);
fname += string.Format(".{0}", MyROFST.MyRODb.RODbConfig.GetDefaultGraphicExtension()); fname += string.Format(".{0}", MyROFST.MyRODb.RODbConfig.GetDefaultGraphicExtension());
ROImageInfo tmp = ROImageInfo.GetByROFstID_FileName(MyROFST.ROFstID, fname); }
if (tmp == null) tmp = ROImageInfo.GetByROFstID_FileName(MyROFST.ROFstID, fname);
if (tmp !=null) if (tmp !=null)
{ {
ROImageConfig rc = new ROImageConfig(tmp); ROImageConfig rc = new ROImageConfig(tmp);

View File

@ -57,6 +57,7 @@ namespace Volian.Controls.Library
this.nodeConnector1 = new DevComponents.AdvTree.NodeConnector(); this.nodeConnector1 = new DevComponents.AdvTree.NodeConnector();
this.btnPrintReport = new DevComponents.DotNetBar.ButtonX(); this.btnPrintReport = new DevComponents.DotNetBar.ButtonX();
this.xpSelROs = new DevComponents.DotNetBar.ExpandablePanel(); this.xpSelROs = new DevComponents.DotNetBar.ExpandablePanel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
((System.ComponentModel.ISupportInitialize)(this.tctrlReports)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.tctrlReports)).BeginInit();
this.tctrlReports.SuspendLayout(); this.tctrlReports.SuspendLayout();
this.tabControlPanel2.SuspendLayout(); this.tabControlPanel2.SuspendLayout();
@ -143,10 +144,10 @@ namespace Volian.Controls.Library
this.cbxIncldMissingROs.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; this.cbxIncldMissingROs.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;
this.cbxIncldMissingROs.Location = new System.Drawing.Point(7, 61); this.cbxIncldMissingROs.Location = new System.Drawing.Point(7, 61);
this.cbxIncldMissingROs.Name = "cbxIncldMissingROs"; this.cbxIncldMissingROs.Name = "cbxIncldMissingROs";
this.cbxIncldMissingROs.Size = new System.Drawing.Size(138, 23); this.cbxIncldMissingROs.Size = new System.Drawing.Size(241, 23);
this.cbxIncldMissingROs.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.cbxIncldMissingROs.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
this.cbxIncldMissingROs.TabIndex = 10; this.cbxIncldMissingROs.TabIndex = 10;
this.cbxIncldMissingROs.Text = "Include Missing ROs"; this.cbxIncldMissingROs.Text = "Include Missing ROs (a red ? in the editor)";
// //
// cbxSummary // cbxSummary
// //
@ -399,7 +400,7 @@ namespace Volian.Controls.Library
this.xpSetToReport.TitleStyle.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; this.xpSetToReport.TitleStyle.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder;
this.xpSetToReport.TitleStyle.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; this.xpSetToReport.TitleStyle.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText;
this.xpSetToReport.TitleStyle.GradientAngle = 90; this.xpSetToReport.TitleStyle.GradientAngle = 90;
this.xpSetToReport.TitleText = "Select Procedures"; this.xpSetToReport.TitleText = "Select Procedure Set";
// //
// advTreeProcSets // advTreeProcSets
// //
@ -545,5 +546,6 @@ namespace Volian.Controls.Library
private DevComponents.DotNetBar.ExpandablePanel xpSelROs; private DevComponents.DotNetBar.ExpandablePanel xpSelROs;
private DevComponents.DotNetBar.PanelEx panelEx1; private DevComponents.DotNetBar.PanelEx panelEx1;
private DevComponents.DotNetBar.Controls.CheckBoxX cbxIncldMissingROs; private DevComponents.DotNetBar.Controls.CheckBoxX cbxIncldMissingROs;
private System.Windows.Forms.ToolTip toolTip1;
} }
} }

View File

@ -195,10 +195,10 @@ namespace Volian.Controls.Library
cbxComplete.Enabled = true; cbxComplete.Enabled = true;
cbxSummary.Enabled = true; cbxSummary.Enabled = true;
if (cbxROUsage.Checked) if (cbxROUsage.Checked)
cbxIncldMissingROs.Text = "Include Missing ROs"; cbxIncldMissingROs.Text = "Include Missing ROs (red ? in the editor)";
else if (cbxComplete.Checked) else if (cbxComplete.Checked)
cbxIncldMissingROs.Text = "Include Empty RO Fields"; cbxIncldMissingROs.Text = "Include Empty RO Fields";
cbxIncldMissingROs.Checked = !cbxSummary.Checked; cbxIncldMissingROs.Checked = false;// !cbxSummary.Checked;
cbxIncldMissingROs.Visible = cbxROUsage.Checked || cbxComplete.Checked; cbxIncldMissingROs.Visible = cbxROUsage.Checked || cbxComplete.Checked;
} }
@ -247,10 +247,10 @@ namespace Volian.Controls.Library
break; break;
} }
if (cbxROUsage.Checked) if (cbxROUsage.Checked)
cbxIncldMissingROs.Text = "Include Missing ROs"; cbxIncldMissingROs.Text = "Include Missing ROs (red ? in the editor)";
else if (cbxComplete.Checked) else if (cbxComplete.Checked)
cbxIncldMissingROs.Text = "Include Empty RO Fields"; cbxIncldMissingROs.Text = "Include Empty RO Fields";
cbxIncldMissingROs.Checked = cbxROUsage.Checked || cbxComplete.Checked; //cbxIncldMissingROs.Checked = cbxROUsage.Checked || cbxComplete.Checked;
cbxIncldMissingROs.Visible = cbxROUsage.Checked || cbxComplete.Checked; cbxIncldMissingROs.Visible = cbxROUsage.Checked || cbxComplete.Checked;
} }
@ -270,6 +270,7 @@ namespace Volian.Controls.Library
cmbxROUsageSort.Enabled = cbxROUsage.Checked; cmbxROUsageSort.Enabled = cbxROUsage.Checked;
xpSelROs.Enabled = true; xpSelROs.Enabled = true;
xpSelROs.Expanded = true; xpSelROs.Expanded = true;
cbxIncldMissingROs.Checked = false;// !cbxSummary.Checked;
EnableOrDisablePrintButton(); EnableOrDisablePrintButton();
} }
@ -281,6 +282,7 @@ namespace Volian.Controls.Library
// reset the RO tree and clear anything that was selected // reset the RO tree and clear anything that was selected
advTreeROFillIn(true); advTreeROFillIn(true);
lstCheckedROs.Clear(); lstCheckedROs.Clear();
cbxIncldMissingROs.Checked = false;// !cbxSummary.Checked;
EnableOrDisablePrintButton(); EnableOrDisablePrintButton();
} }
#region Procedure List #region Procedure List
@ -774,6 +776,7 @@ namespace Volian.Controls.Library
private void cbxComplete_CheckedChanged(object sender, EventArgs e) private void cbxComplete_CheckedChanged(object sender, EventArgs e)
{ {
cbxIncldMissingROs.Checked = false;// !cbxSummary.Checked;
EnableOrDisablePrintButton(); EnableOrDisablePrintButton();
} }
@ -827,6 +830,7 @@ namespace Volian.Controls.Library
System.Diagnostics.Process p = System.Diagnostics.Process.Start(cmpRptExePath, roloc); System.Diagnostics.Process p = System.Diagnostics.Process.Start(cmpRptExePath, roloc);
// need to wait, sometimes the Print.tmp file that is generated is not available // need to wait, sometimes the Print.tmp file that is generated is not available
p.WaitForExit(); // without arguments, this will wait indefinately p.WaitForExit(); // without arguments, this will wait indefinately
Application.DoEvents();
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -117,4 +117,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root> </root>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.IO; using System.IO;
using System.Windows.Forms;
using iTextSharp.text.pdf; using iTextSharp.text.pdf;
using iTextSharp.text; using iTextSharp.text;
using VEPROMS.CSLA.Library; using VEPROMS.CSLA.Library;
@ -13,11 +14,13 @@ namespace Volian.Print.Library
{ {
class CompleteROReport class CompleteROReport
{ {
private static readonly log4net.ILog _MyLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
//Dictionary<string, PdfDestination> _MyErrorBookMarks = new Dictionary<string, PdfDestination>();
Headers Hdrs; // Header stack object. Headers Hdrs; // Header stack object.
RODataFile RO_df = null; RODataFile RO_df = null;
int curheaderlen; int curheaderlen;
string RODataFileName; string RODataFileName;
iTextSharp.text.Document pdfReportDoc = null; iTextSharp.text.Document _pdfReportDoc = null;
PdfPTable datatable = null; PdfPTable datatable = null;
private iTextSharp.text.Font _f14; // = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK); private iTextSharp.text.Font _f14; // = pdf.GetFont("Arial Unicode MS", 14, 1, Color.BLACK);
@ -83,7 +86,7 @@ namespace Volian.Print.Library
public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields) public CompleteROReport(PdfWriter mypdfwriter, iTextSharp.text.Document document, string dataFileName, bool convertCaretToDelta, bool includeEmptyROFields)
{ {
Hdrs = new Headers(); Hdrs = new Headers();
pdfReportDoc = document; _pdfReportDoc = document;
RODataFileName = dataFileName; RODataFileName = dataFileName;
_ConvertCaretToDelta = convertCaretToDelta; _ConvertCaretToDelta = convertCaretToDelta;
_MyPDFWriter = mypdfwriter; _MyPDFWriter = mypdfwriter;
@ -92,7 +95,7 @@ namespace Volian.Print.Library
public void StartNewDataTable() public void StartNewDataTable()
{ {
datatable = new PdfPTable(1); datatable = new PdfPTable(1);
datatable.TotalWidth = pdfReportDoc.PageSize.Width - pdfReportDoc.LeftMargin - pdfReportDoc.RightMargin; datatable.TotalWidth = _pdfReportDoc.PageSize.Width - _pdfReportDoc.LeftMargin - _pdfReportDoc.RightMargin;
datatable.LockedWidth = true; datatable.LockedWidth = true;
PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14)); PdfPCell cell = new PdfPCell(new Phrase(ReportTitle, F14));
cell.HorizontalAlignment = Element.ALIGN_CENTER; cell.HorizontalAlignment = Element.ALIGN_CENTER;
@ -223,7 +226,39 @@ namespace Volian.Print.Library
{ {
ROImageConfig rc = new ROImageConfig(roImage); ROImageConfig rc = new ROImageConfig(roImage);
int size = Convert.ToInt32(rc.Image_Size); int size = Convert.ToInt32(rc.Image_Size);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size)); byte[] cnt = roImage.Content;
byte[] dcnt = ROImageInfo.Decompress(cnt, size);
iTextSharp.text.Image it_image;
try
{
it_image = iTextSharp.text.Image.GetInstance(dcnt);
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
}
catch (Exception ex)
{
try
{
MemoryStream ms = new MemoryStream(dcnt);
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms);
using (MemoryStream ms2 = new MemoryStream())
{
bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
ms2.Seek(0, SeekOrigin.Begin);
byte[] newdcnt = new byte[ms2.Length];
ms2.Read(newdcnt, 0, (int)ms2.Length);
it_image = iTextSharp.text.Image.GetInstance(newdcnt);
}
}
catch (Exception ex2)
{
PdfPCell cell2 = new PdfPCell(new Phrase(string.Format("Bad Image File: {0}", filename)));
cell2.BorderColor = Color.WHITE;
datatable.AddCell(cell2);
GenerateErrorMessage(ex2, "Bad Image File. ", string.Format("Image File: {0}", filename));
//_MyErrorBookMarks.Add(filename, pdfDest);
return;
}
}
it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216); it_image.ScaleToFit(_MyPDFWriter.DirectContent.PdfDocument.PageSize.Width - 144, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height - 216);
PdfPCell cell = new PdfPCell(it_image); PdfPCell cell = new PdfPCell(it_image);
cell.BorderColor = Color.WHITE; cell.BorderColor = Color.WHITE;
@ -231,9 +266,11 @@ namespace Volian.Print.Library
} }
else else
{ {
PdfPCell messageCell = new PdfPCell(new Phrase(string.Format("Image File {0} is missing.",filename))); PdfPCell messageCell = new PdfPCell(new Phrase(string.Format("Image File {0} is missing.", filename)));
messageCell.BorderColor = Color.WHITE; messageCell.BorderColor = Color.WHITE;
datatable.AddCell(messageCell); datatable.AddCell(messageCell);
GenerateErrorMessage(null, "Image File Missing. ", string.Format("Image File: {0}", filename));
//_MyErrorBookMarks.Add(filename, pdfDest);
} }
} }
@ -253,84 +290,144 @@ namespace Volian.Print.Library
datatable.AddCell(cell); datatable.AddCell(cell);
} }
private string processingRO = "";
public void PrintReport() public void PrintReport()
{ {
bool StopPrinting = false; bool StopPrinting = false;
bool UserTerminate = false; bool UserTerminate = false;
Int16 iRecType = 0; Int16 iRecType = 0;
if (RO_df.GetFileLength() > 0) try
{ {
// Loop until either printing is aborted or end of file. if (RO_df.GetFileLength() > 0)
while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{ {
//Console.WriteLine("Record Type: {0}", iRecType); // Loop until either printing is aborted or end of file.
switch (iRecType) while (!StopPrinting && (iRecType = RO_df.ReadInteger16()) != -1)
{ {
case 1: // Set Header //Console.WriteLine("Record Type: {0}", iRecType);
SetHeader(); switch (iRecType)
break; {
case 2: // Push Header case 1: // Set Header
PushHeader(); SetHeader();
break; break;
case 3: // Pop Header case 2: // Push Header
PopHeader(); PushHeader();
break; break;
case 4: // RRO Begin case 3: // Pop Header
RROBegin(); PopHeader();
break; break;
case 5: // RRO End case 4: // RRO Begin
RROEnd(); RROBegin();
break; break;
case 6: // Msg case 5: // RRO End
Msg(); RROEnd();
break; processingRO = "";
case 7: break;
KeyField(); case 6: // Msg
break; Msg();
case 100: // Text Field - sometimes also XY Plot break;
Text(); case 7:
break; processingRO = KeyField();
case 101: // Plot Field break;
XYPlot(); case 100: // Text Field - sometimes also XY Plot
break; Text();
case 102: // Image Field break;
ImageFile(); case 101: // Plot Field
break; XYPlot();
case 103: // Multi Begin - Display data for setpoints break;
Multiple(); case 102: // Image Field
break; ImageFile();
case 104: // Multi End break;
break; case 103: // Multi Begin - Display data for setpoints
case 0: // nothing was entered in that field Multiple();
if (_IncludeEmptyROFields) break;
NoInformatEntered(); case 104: // Multi End
break; break;
case 255: case 0: // nothing was entered in that field
pdfReportDoc.Add(datatable); if (_IncludeEmptyROFields)
pdfReportDoc.NewPage(); NoInformatEntered();
StartNewDataTable(); break;
//Console.WriteLine("Record Type: {0} No Operation", iRecType); case 255:
//Console.WriteLine("----------------------------------------------"); _pdfReportDoc.Add(datatable);
break; _pdfReportDoc.NewPage();
default: // Problem StartNewDataTable();
//Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType); //Console.WriteLine("Record Type: {0} No Operation", iRecType);
StopPrinting = true; ; //Console.WriteLine("----------------------------------------------");
UserTerminate = true; break;
break; default: // Problem
}; //Console.WriteLine("Record Type: {0} Unrecognized record type", iRecType);
StopPrinting = true;
UserTerminate = true;
MessageBox.Show(string.Format("Unrecognized record type [{0}]", iRecType), "Error Creating Complete RO Report", MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
};
}
}
else
{
StartNewDataTable();
datatable.HeaderRows = 1;
AddText("Selected Referenced Object has no data.", F12);
} }
}
else
{
StartNewDataTable();
datatable.HeaderRows = 1;
AddText("Selected Referenced Object has no data.", F12);
}
//Console.WriteLine("Record Type: {0}\n** Done **", iRecType); //Console.WriteLine("Record Type: {0}\n** Done **", iRecType);
pdfReportDoc.Add(datatable); _pdfReportDoc.Add(datatable);
}
catch (Exception e)
{
Console.WriteLine("Exception : {0}", e.Message);
RO_df.close();
_pdfReportDoc.Add(datatable);
GenerateErrorMessage(e, "Error Processing Complete RO Report. ", null);
}
AddErrorBookmarks();
return; return;
} }
private void GenerateErrorMessage( Exception e, string erMsg, string erMsg2)
{
// if there is lenght then we are in the mist of processing an RO
string headers = erMsg;
for (int iLoop = 0; iLoop < Hdrs.HdrCnt; iLoop++)
headers += Hdrs.strHdrs[iLoop] + "\n ";
if (processingRO.Length > 0)
headers += processingRO;
if (erMsg2 != null && erMsg2.Length > 0)
headers += "\n" + erMsg2;
//MessageBox.Show(headers, erMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
if (e != null)
_MyLog.Error(headers, e);
else
_MyLog.Error(headers);
PdfOutline outl = new PdfOutline(MyErrorOutline, MyPdfDestPage, processingRO.Length > 0 ? processingRO : "Problem Reading Header");
//DestSample(outl);
}
//private void DestSample(PdfOutline outl)
//{
// new PdfOutline(outl, new PdfDestination(PdfDestination.FIT), "FIT");
// new PdfOutline(outl, new PdfDestination(PdfDestination.FITV, 700), "FITV,700");
// new PdfOutline(outl, new PdfDestination(PdfDestination.FITH, 700), "FITH,700");
// new PdfOutline(outl, new PdfDestination(PdfDestination.XYZ, 72, 720, 5), "XYZ,72,720,5");
// new PdfOutline(outl, new PdfDestination(PdfDestination.FITR, 72, 650, 144, 722), "FITR,72, 650, 144, 722");
// new PdfOutline(outl, new PdfDestination(PdfDestination.XYZ, 72, 720, 10), "XYZ,72,720,10");
// new PdfOutline(outl, new PdfDestination(PdfDestination.FITR, 0, 500, _pdfReportDoc.PageSize.Width, 720), "FITR,0, 500,_pdfReportDoc.PageSize.Width , 720");
// new PdfOutline(outl, new PdfDestination(PdfDestination.XYZ, 0, 792, 1), "XYZ,72,720,10");
//}
public void AddErrorBookmarks()
{
if (_MyErrorOutline == null) return;
//if (_MyErrorBookMarks.Count == 0) return;
//PdfOutline outline = null;
//foreach (string key in _MyErrorBookMarks.Keys)
//{
// if (outline == null) outline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, _MyErrorBookMarks[key], "Errors");
// new PdfOutline(outline, _MyErrorBookMarks[key], key);
//}
string emsg = "A Bookmark grouping named \"Errors\" was added to the PDF.\n\n Click on the RO in this grouping to jump to the report page which will contain an error message.\n\nThe error were also recorded in the PROMS error log.";
MessageBox.Show(emsg, "Errors Found Creating Report", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public void Multiple() public void Multiple()
{ {
Int16 typ, i, j, nw = 0; Int16 typ, i, j, nw = 0;
@ -549,16 +646,62 @@ namespace Volian.Print.Library
{ {
PdfOutline parentOutline = null; PdfOutline parentOutline = null;
if (iLoop == 0) if (iLoop == 0)
parentOutline = _MyPDFWriter.DirectContent.RootOutline; parentOutline = MyRootOutline;//_MyPDFWriter.DirectContent.RootOutline;
else else
parentOutline = MyDocOutline[iLoop - 1].MyOutline; parentOutline = MyDocOutline[iLoop - 1].MyOutline;
PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); //pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], pdfDest); AddOutlineLevel(parentOutline, iLoop, Hdrs.strHdrs[iLoop], MyPdfDestPage);
} }
AddText(Hdrs.strHdrs[iLoop], F12Bold); // should be bold and first header is centered AddText(Hdrs.strHdrs[iLoop], F12Bold); // should be bold and first header is centered
} }
} }
static float _Top = 792;
public PdfDestination MyPdfDestTop
{
get
{
// FITH was acting strange and shifting towards bottom of the page as the number of pages increased
//Console.WriteLine("Top = {0}, {1}", _Top, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
//return new PdfDestination(PdfDestination.FITH, _Top);//_MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
return new PdfDestination(PdfDestination.XYZ, 0, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height, 1.5f);
}
}
public PdfDestination MyPdfDestPage
{
get
{
return new PdfDestination(PdfDestination.FITV,0);
}
}
private PdfOutline _MyErrorOutline = null;
public PdfOutline MyErrorOutline
{
get
{
if (_MyErrorOutline == null)
{
_MyErrorOutline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, MyPdfDestPage, "Errors");
}
return _MyErrorOutline;
}
}
private PdfOutline _MyRootOutline = null;
public PdfOutline MyRootOutline
{
get
{
if (_MyRootOutline == null)
{
_MyRootOutline = new PdfOutline(_MyPDFWriter.DirectContent.RootOutline, MyPdfDestTop, "Referenced Objects");
}
return _MyRootOutline;
}
}
private PdfDestination pdfDest = null;
private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest) private void AddOutlineLevel(PdfOutline parentOutline, int iLoop, string hdr, PdfDestination pdfDest)
{ {
if (MyDocOutline.ContainsKey(iLoop)) if (MyDocOutline.ContainsKey(iLoop))
@ -663,12 +806,14 @@ namespace Volian.Print.Library
//Console.WriteLine("----------------------------------------------"); //Console.WriteLine("----------------------------------------------");
} }
public void KeyField() public string KeyField()
{ {
// use the key field as the PDF bookbark // use the key field as the PDF bookbark
string szStr = RO_df.ReadText(); string szStr = RO_df.ReadText();
PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height); //PdfDestination pdfDest = new PdfDestination(PdfDestination.FITH, _MyPDFWriter.DirectContent.PdfDocument.PageSize.Height);
new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, pdfDest, szStr); PdfOutline outl = new PdfOutline(MyDocOutline[Hdrs.HdrCnt - 1].MyOutline, MyPdfDestTop, szStr);
//DestSample(outl);
return szStr;
//Console.WriteLine("Key Field"); //Console.WriteLine("Key Field");
//Console.WriteLine("Key Text: {0}", szStr); //Console.WriteLine("Key Text: {0}", szStr);
//Console.WriteLine("----------------------------------------------"); //Console.WriteLine("----------------------------------------------");

View File

@ -973,7 +973,36 @@ namespace Volian.Print.Library
{ {
ROImageConfig rc = new ROImageConfig(roImage); ROImageConfig rc = new ROImageConfig(roImage);
int size = Convert.ToInt32(rc.Image_Size); int size = Convert.ToInt32(rc.Image_Size);
iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size)); byte[] cnt = roImage.Content;
byte[] dcnt = ROImageInfo.Decompress(cnt, size);
iTextSharp.text.Image it_image=null;
try
{
it_image = iTextSharp.text.Image.GetInstance(dcnt);
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
}
catch
{
MemoryStream ms = new MemoryStream(dcnt);
System.Drawing.Bitmap bm = new System.Drawing.Bitmap(ms);
using (MemoryStream ms2 = new MemoryStream())
{
bm.Save(ms2, System.Drawing.Imaging.ImageFormat.Png);
ms2.Seek(0, SeekOrigin.Begin);
byte[] newdcnt = new byte[ms2.Length];
ms2.Read(newdcnt, 0, (int)ms2.Length);
try
{
it_image = iTextSharp.text.Image.GetInstance(newdcnt);
}
catch (Exception ex)
{
_MyLog.Error(string.Format("{0}",roImage.FileName),ex);
return yLocation;
}
}
}
//iTextSharp.text.Image it_image = iTextSharp.text.Image.GetInstance(ROImageInfo.Decompress(roImage.Content, size));
retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless")); retval = Rtf2Pdf.FigureAt(cb, it_image, XOffset + MyItemInfo.FormatStepData.Font.CharsToTwips, yLocation, Width * MyPageHelper.YMultiplier, Height * MyPageHelper.YMultiplier, DebugInfo, yBottomMargin, !MyItemInfo.FormatStepData.Type.Contains("Borderless"));
} }
} }