/// <summary> /// The get image. /// </summary> /// <param name="src">The src.</param> /// <param name="attrs">The attrs.</param> /// <param name="chain">The chain.</param> /// <param name="doc">The doc.</param> /// <returns> /// The <see cref="Image" />. /// </returns> /// <exception cref="System.ArgumentNullException">src</exception> /// <exception cref="ArgumentNullException">src</exception> public Image GetImage(string src, IDictionary<string, string> attrs, ChainedProperties chain, IDocListener doc) { if (string.IsNullOrWhiteSpace(src)) { return null; } if (src.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { return this.GetImage(src); } if (HostingEnvironment.VirtualPathProvider.FileExists(src)) { try { UnifiedFile unifiedFile = HostingEnvironment.VirtualPathProvider.GetFile(src) as UnifiedFile; return unifiedFile == null ? null : this.GetImage(unifiedFile.LocalPath); } catch (Exception exception) { Logger.ErrorFormat(CultureInfo.InvariantCulture, "[OutputFormats] File not found for:'{0}'. \n {1}", src, exception); return null; } } string baseurl = Settings.Instance.SiteUrl.GetLeftPart(UriPartial.Authority); src = string.Format(CultureInfo.InvariantCulture, "{0}{1}", baseurl, src); return this.GetImage(src); }
public Image GetImage(String src, IDictionary<string,string> h, ChainedProperties cprops, IDocListener doc) { return Image.GetInstance(Path.Combine( Utility.ResourcePosters, src.Substring(src.LastIndexOf("/") + 1) )); }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>Stream</CODE> the writer has to write to. * @param listener A <CODE>DocListener</CODE> to pass to the PdfDocument. * @param conformanceLevel PDF/A conformance level of a new PDF document * @return a new <CODE>PdfWriter</CODE> * @throws DocumentException on error */ public static PdfAWriter GetInstance(Document document, Stream os, IDocListener listener, PdfAConformanceLevel conformanceLevel){ PdfDocument pdf = new PdfDocument(); pdf.AddDocListener(listener); document.AddDocListener(pdf); PdfAWriter writer = new PdfAWriter(pdf, os, conformanceLevel); pdf.AddWriter(writer); return writer; }
// alias: using iTextImage = iTextSharp.text.Image; public iTextImage GetImage(string src, IDictionary<string, string> attrs, ChainedProperties chain, IDocListener doc) { Match match; // [1] if ((match = Base64.Match(src)).Length > 0) { return iTextImage.GetInstance( Convert.FromBase64String(match.Groups["data"].Value) ); } // [2] if (!src.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { src = HttpContext.Current.Server.MapPath( new Uri(new Uri(BaseUri), src).AbsolutePath ); } return iTextImage.GetInstance(src); }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> /// <param name="tagmap"></param> public override void Go(IDocListener document, String file, String tagmap) { parser = new ITextmyHtmlHandler(document, new TagMap(tagmap)); parser.Parse(file); }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> /// <param name="tagmap"></param> public override void Go(IDocListener document, XmlDocument xDoc, XmlDocument xTagmap) { parser = new ITextmyHtmlHandler(document, new TagMap(xTagmap)); parser.Parse(xDoc); }
/// <summary> /// Parses a given XmlTextReader. /// </summary> /// <param name="document"></param> /// <param name="reader"></param> /// <param name="tagmap"></param> public override void Go(IDocListener document, XmlTextReader reader, String tagmap) { parser = new ITextmyHtmlHandler(document, new TagMap(tagmap)); parser.Parse(reader); }
/** * @param document * @param myTags * @throws DocumentException * @throws IOException */ public ITextHandler(IDocListener document, Hashtable myTags) : this(document) { this.myTags = myTags; }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> public override void Go(IDocListener document, String file) { parser = new ITextmyHtmlHandler(document); parser.Parse(file); }
/** * Creates a new instance of HTMLWorker * @param document A class that implements <CODE>DocListener</CODE> */ public HTMLWorker(IDocListener document) : this(document, null, null) { }
public Image CreateImage( String src, IDictionary<String, String> attrs, ChainedProperties chain, IDocListener document, IImageProvider img_provider, Dictionary<String, Image> img_store, String img_baseurl) { Image img = null; // getting the image using an image provider if (img_provider != null) img = img_provider.GetImage(src, attrs, chain, document); // getting the image from an image store if (img == null && img_store != null) { Image tim; img_store.TryGetValue(src, out tim); if (tim != null) img = Image.GetInstance(tim); } if (img != null) return img; // introducing a base url // relative src references only if (!src.StartsWith("http") && img_baseurl != null) { src = img_baseurl + src; } else if (img == null && !src.StartsWith("http")) { String path = chain[HtmlTags.IMAGEPATH]; if (path == null) path = ""; src = Path.Combine(path, src); } img = Image.GetInstance(src); if (img == null) return null; float actualFontSize = HtmlUtilities.ParseLength( chain[HtmlTags.SIZE], HtmlUtilities.DEFAULT_FONT_SIZE); if (actualFontSize <= 0f) actualFontSize = HtmlUtilities.DEFAULT_FONT_SIZE; String width; attrs.TryGetValue(HtmlTags.WIDTH, out width); float widthInPoints = HtmlUtilities.ParseLength(width, actualFontSize); String height; attrs.TryGetValue(HtmlTags.HEIGHT, out height); float heightInPoints = HtmlUtilities.ParseLength(height, actualFontSize); if (widthInPoints > 0 && heightInPoints > 0) { img.ScaleAbsolute(widthInPoints, heightInPoints); } else if (widthInPoints > 0) { heightInPoints = img.Height * widthInPoints / img.Width; img.ScaleAbsolute(widthInPoints, heightInPoints); } else if (heightInPoints > 0) { widthInPoints = img.Width * heightInPoints / img.Height; img.ScaleAbsolute(widthInPoints, heightInPoints); } String before = chain[HtmlTags.BEFORE]; if (before != null) img.SpacingBefore = float.Parse(before, CultureInfo.InvariantCulture); String after = chain[HtmlTags.AFTER]; if (after != null) img.SpacingAfter = float.Parse(after, CultureInfo.InvariantCulture); img.WidthPercentage = 0; return img; }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> public static new void Parse(IDocListener document, XmlDocument xDoc) { HtmlParser p = new HtmlParser(); p.Go(document, xDoc); }
// listener methods /// <summary> /// Adds a IDocListener to the Document. /// </summary> /// <param name="listener">the new IDocListener</param> public void AddDocListener(IDocListener listener) { listeners.Add(listener); }
/// <summary> /// Write all data splitted in slices to the specified writer /// </summary> /// <param name="model"> /// The dataset model /// </param> /// <param name="doc"> /// The PDF document /// </param> private void WriteTableModels(IDataSetModel model, IDocListener doc) { IDataReader reader = model.GetReader(false); // DIV containerTable = createContainerTable(); string oldKeySet = null; var s = new RendererState(model); while (reader.Read()) { s.InputRow = reader; string currentKeySet = MakeKey(model.SliceKeys, reader); if (!currentKeySet.Equals(oldKeySet)) { oldKeySet = currentKeySet; CommitTable(s, doc); // containerTable = createContainerTable(); this.CreateSliceHeader(doc, s); // addSliceHeading(containerTable, sTable); s.Table = CreateSliceTable(); // addSliceTable(containerTable, s.table); this.InitTitles(s); } this.ParseDataRow(s); } reader.Close(); s.InputRow = null; CommitTable(s, doc); }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> /// <param name="tagmap"></param> public override void Go(IDocListener document, String file, Hashtable tagmap) { parser = new ITextmyHtmlHandler(document, tagmap); parser.Parse(file); }
/// <summary> /// Commit the current table and reset state /// </summary> /// <param name="state"> /// The state /// </param> /// <param name="doc"> /// The pdf document to commit the current table /// </param> private static void CommitTable(RendererState state, IDocListener doc) { if (state.Table != null) { PopulateTable(state); // containerTable.Write(writer); PdfPTable table = CreatePdf(state.Table); if (table != null) { doc.Add(table); table.DeleteBodyRows(); } doc.NewPage(); state.Reset(); } }
public ITextmyHtmlHandler(IDocListener document, BaseFont bf) : base(document, new HtmlTagMap(), bf) { }
/** * Constructs a new SAXiTextHandler that will translate all the events * triggered by the parser to actions on the <CODE>Document</CODE>-object. * * @param document this is the document on which events must be triggered */ public ITextmyHtmlHandler(IDocListener document) : base(document, new HtmlTagMap()) { }
/** * Constructs a new SAXiTextHandler that will translate all the events * triggered by the parser to actions on the <CODE>Document</CODE>-object. * * @param document this is the document on which events must be triggered * @param htmlTags a tagmap translating HTML tags to iText tags */ public ITextmyHtmlHandler(IDocListener document, Hashtable htmlTags) : base(document, htmlTags) { }
/** Creates a new instance of HTMLWorker */ public HTMLWorker(IDocListener document) { this.document = document; }
/// <summary> /// Parses a given XmlTextReader. /// </summary> /// <param name="document"></param> /// <param name="reader"></param> /// <param name="tagmap"></param> public override void Go(IDocListener document, XmlTextReader reader, Hashtable tagmap) { parser = new ITextmyHtmlHandler(document, tagmap); parser.Parse(reader); }
// listener methods /// <summary> /// Adds a IDocListener to the Document. /// </summary> /// <param name="listener">the new IDocListener</param> virtual public void AddDocListener(IDocListener listener) { listeners.Add(listener); if (listener is IAccessibleElement) { IAccessibleElement ae = (IAccessibleElement)listener; ae.Role = this.role; ae.ID = this.id; if (this.accessibleAttributes != null) { foreach (PdfName key in this.accessibleAttributes.Keys) ae.SetAccessibleAttribute(key, this.accessibleAttributes[key]); } } }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> public static new void Parse(IDocListener document, String file) { HtmlParser p = new HtmlParser(); p.Go(document, file); }
/// <summary> /// Parses a given XmlTextReader. /// </summary> /// <param name="document"></param> /// <param name="reader"></param> public static new void Parse(IDocListener document, XmlTextReader reader) { HtmlParser p = new HtmlParser(); p.Go(document, reader); }
/// <summary> /// Removes a IDocListener from the Document. /// </summary> /// <param name="listener">the IDocListener that has to be removed.</param> public void RemoveIDocListener(IDocListener listener) { listeners.Remove(listener); }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> /// <param name="tagmap"></param> public static new void Parse(IDocListener document, String file, Hashtable tagmap) { HtmlParser p = new HtmlParser(); p.Go(document, file, tagmap); }
/** * Creates a new instance of HTMLWorker * @param document A class that implements <CODE>DocListener</CODE> * @param tags A map containing the supported tags * @param style A StyleSheet * @since 5.0.6 */ public HTMLWorker(IDocListener document, IDictionary<String, IHTMLTagProcessor> tags, StyleSheet style) { this.document = document; SetSupportedTags(tags); SetStyleSheet(style); }
/// <summary> /// Parses a given XmlTextReader. /// </summary> /// <param name="document"></param> /// <param name="reader"></param> /// <param name="tagmap"></param> public static new void Parse(IDocListener document, XmlTextReader reader, Hashtable tagmap) { HtmlParser p = new HtmlParser(); p.Go(document, reader, tagmap); }
/** * Use this method to get an instance of the <CODE>PdfWriter</CODE>. * * @return a new <CODE>PdfWriter</CODE> * @param document The <CODE>Document</CODE> that has to be written * @param os The <CODE>Stream</CODE> the writer has to write to. * @param listener A <CODE>DocListener</CODE> to pass to the PdfDocument. * @throws DocumentException on error */ public static PdfWriter GetInstance(Document document, Stream os, IDocListener listener) { PdfDocument pdf = new PdfDocument(); pdf.AddDocListener(listener); document.AddDocListener(pdf); PdfWriter writer = new PdfWriter(pdf, os); pdf.AddWriter(writer); return writer; }
/// <summary> /// Parses a given file. /// </summary> /// <param name="document"></param> /// <param name="file"></param> public override void Go(IDocListener document, XmlDocument xDoc) { parser = new ITextmyHtmlHandler(document); parser.Parse(xDoc); }