private void ParseLoadedContent(HTMLLinkType type, string content, string path, PDFContextBase context) { switch (type) { case (HTMLLinkType.CSS): StyleCollection col = this.CreateInnerStyles(content, context); this._content = new LinkContentCSS(col, path); break; case (HTMLLinkType.Html): Dictionary <string, string> ns = new Dictionary <string, string>(); foreach (var map in this.Document.NamespaceDeclarations) { ns.Add(map.Prefix, map.NamespaceURI); } Scryber.Data.ParsableTemplateGenerator gen = new Data.ParsableTemplateGenerator(content, ns); this._content = new LinkContentHtml(gen, path); break; default: if (context.Conformance == ParserConformanceMode.Strict) { throw new System.IO.FileLoadException("The link with href " + this.Href + " could not be loaded from path '" + path + "' as it does not have a known rel type - stylesheet or include"); } else { context.TraceLog.Add(TraceLevel.Error, "HTML", "The link with href " + this.Href + " could not be loaded from path '" + path + "' as it does not have a known rel type - stylesheet or include"); } break; } }
private bool ShouldAddContent(OutputFormat format, out HTMLLinkType type) { type = HTMLLinkType.Other; //If we have a media value and it's not for this format, then we don't add them if (null != Media && this.Media.IsMatchedTo(format) == false) { return(false); } if (this.Visible == false) { return(false); } if (this.Relationship.Equals("stylesheet", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(this.Relationship)) { type = HTMLLinkType.CSS; return(true); } else if (this.Relationship.Equals("import")) { type = HTMLLinkType.Html; return(true); } else { return(false); } }
private bool ShouldAddContent(OutputFormat format, PDFContextBase context, out HTMLLinkType type) { type = HTMLLinkType.Other; //If we have a media value and it's not for this format, then we don't add them if (null != Media && this.Media.IsMatchedTo(format) == false) { return(false); } if (this.Visible == false) { return(false); } if (string.IsNullOrEmpty(this.Relationship)) { if (context.Conformance == ParserConformanceMode.Lax) { context.TraceLog.Add(TraceLevel.Error, "HTML", "The 'rel'ationship attribute is required on a html 'link' tag."); return(false); } else { throw new PDFParserException("The 'rel'ationship attribute is required on a html 'link' tag."); } } if (this.Relationship.Equals("stylesheet", StringComparison.OrdinalIgnoreCase) || string.IsNullOrEmpty(this.Relationship)) { type = HTMLLinkType.CSS; return(true); } else if (this.Relationship.Equals("import")) { type = HTMLLinkType.Html; return(true); } else { return(false); } }
public LinkContentBase(HTMLLinkType type, string source) { this.LinkType = type; this.LoadedSource = source; }