/// <summary> /// Converts the specified graphic. /// </summary> /// <param name="graphic">The graphic.</param> /// <returns></returns> public iTextSharp.text.Image Convert(Graphic graphic) { try { iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(graphic.GraphicRealPath); img.SetDpi(graphic.Frame.DPI_X, graphic.Frame.DPI_X); img = this.ScaleIfNessarry(img, graphic.Frame); img = this.SetImageProperties(img, graphic.Frame); //img.Alignment = iTextSharp.text.Image.TEXTWRAP; // img.ScalePercent(50.0f); // img.RotationDegrees = -45.0f; //img.ScaleAbsolute(100, 100); return img; } catch(Exception) { throw; } }
private void LoadFrameGraphic(Frame frame, Graphic content) { try { string graphicRealPath = Path.GetFullPath(content.GraphicRealPath); frame.LoadImageFromFile(graphicRealPath); } catch (AODLGraphicException e) { this.OnWarning( new AODLWarning("A couldn't create any content from an an first level node!.", content.Node, e)); } }
/// <summary> /// Creates the graphic. /// </summary> /// <param name="graphicnode">The graphicnode.</param> /// <returns>The Graphic object</returns> private Graphic CreateGraphic(XmlNode graphicnode) { try { Graphic graphic = new Graphic(this._document, null, null); graphic.Node = graphicnode; graphic.GraphicRealPath = Path.Combine(_document.DirInfo.Dir, graphic.HRef); return graphic; } catch(Exception ex) { throw new AODLException("Exception while trying to create a Graphic.", ex); } }
/// <summary> /// Gets the graphic as HTML. /// </summary> /// <param name="graphic">The graphic.</param> /// <returns></returns> public string GetGraphicAsHtml(Graphic graphic) { //standard space around 12px string html = "<img hspace=\"12\" vspace=\"12\" "; try { if (graphic != null) { if (graphic.HRef != null) html += "src=\""+this.GraphicTargetFolder+"/"+graphic.HRef+"\" "; string graphStyle = ""; if (graphic.Frame != null) graphStyle = this.HTMLStyleBuilder.GetFrameStyleAsHtml(graphic.Frame); if (graphStyle.Length > 0) html += graphStyle+" "; //Image map? if (this._nextImageMapName != null) html += "usemap=\"#"+this._nextImageMapName+"\""; html += ">\n"; } } catch(Exception ex) { throw new AODLException("Exception while trying to build a HTML string from a Graphic object.", ex); } if (!html.Equals("<img ")) html += "</img>\n"; else html = ""; return html; }
/// <summary> /// Creates the graphic. /// </summary> /// <param name="graphicnode">The graphicnode.</param> /// <returns>The Graphic object</returns> private Graphic CreateGraphic(XmlNode graphicnode) { try { Graphic graphic = new Graphic(this._document, null, null); graphic.Node = graphicnode; graphic.GraphicRealPath = Path.Combine(OpenDocumentImporter.dir,graphic.HRef); return graphic; } catch(Exception ex) { AODLException exception = new AODLException("Exception while trying to create a Graphic."); exception.InMethod = AODLException.GetExceptionSourceInfo(new StackFrame(1, true)); exception.Node = graphicnode; exception.OriginalException = ex; throw exception; } }
/// <summary> /// Initializes a new instance of the <see cref="Frame"/> class. /// </summary> /// <param name="document">The textdocument.</param> /// <param name="stylename">The stylename.</param> /// <param name="drawName">The draw name.</param> /// <param name="graphicfile">The graphicfile.</param> public Frame(IDocument document, string stylename, string drawName, string graphicfile) { this.Document = document; this.NewXmlNode(); this.InitStandards(); this.StyleName = stylename; // this.AnchorType = "paragraph"; this.DrawName = drawName; this.GraphicSourcePath = graphicfile; this._graphicIdentifier = Guid.NewGuid(); this._realgraphicname = this._graphicIdentifier.ToString() + this.LoadImageFromFile(graphicfile); Graphic graphic = new Graphic(this.Document, this, this._realgraphicname); graphic.GraphicRealPath = this.GraphicSourcePath; this.Content.Add(graphic); this.Style = (IStyle)new FrameStyle(this.Document, stylename); this.Document.Styles.Add(this.Style); if( Document is TextDocument) { ((TextDocument) Document).DocumentManifest.AddFrame(GraphicSourcePath, RealGraphicName); } }