本文整理汇总了C#中Doc.GetText方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.GetText方法的具体用法?C# Doc.GetText怎么用?C# Doc.GetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc.GetText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ItemAnalysisToPdfDoc
protected Doc ItemAnalysisToPdfDoc(PdfRenderSettings settings = null)
{
if (settings == null) settings = new PdfRenderSettings();
StringWriter sw = new StringWriter();
HtmlTextWriter w = new HtmlTextWriter(sw);
reportHeaderDiv.Controls.Add(LoadPDFHeaderInfo());
barGraphLevelsContainerDiv.Controls.Add(LoadBarGraphLevels());
barGraphPDFContainerDiv.Controls.Add(LoadBarGraphs());
contentDiv.RenderControl(w);
string result_html = sw.GetStringBuilder().ToString();
int topOffset = settings.HeaderHeight > 0 ? settings.HeaderHeight : 0;
int bottomOffset = settings.FooterHeight > 0 ? settings.FooterHeight : 0;
Doc doc = new Doc();
doc.HtmlOptions.HideBackground = true;
doc.HtmlOptions.PageCacheEnabled = false;
doc.HtmlOptions.UseScript = true;
doc.HtmlOptions.Timeout = 36000;
doc.HtmlOptions.BreakZoneSize = 100; // I experiemented with this being 99% instead of 100%, but you end up with passages getting cut off in unflattering ways. This may lead to more blank space... but I think it's the lessor of evils
doc.HtmlOptions.ImageQuality = 70;
doc.MediaBox.String = "0 0 " + settings.PageWidth + " " + settings.PageHeight;
doc.Rect.String = settings.LeftMargin + " " + (0 + bottomOffset).ToString() + " " + (settings.PageWidth - settings.RightMargin).ToString() + " " + (settings.PageHeight - topOffset).ToString();
doc.HtmlOptions.AddTags = true;
doc.SetInfo(0, "ApplyOnLoadScriptOnceOnly", "1");
List<int> forms = new List<int>();
int theID = doc.AddImageHtml(result_html);
while (true)
{
if (!doc.Chainable(theID))
break;
doc.Page = doc.AddPage();
theID = doc.AddImageToChain(theID);
string[] tagIds = doc.HtmlOptions.GetTagIDs(theID);
if (tagIds.Length > 0 && tagIds[0] == "test_header")
forms.Add(doc.PageNumber); // By using GetTagIDs to find if a test header ended up on this page, we can determine whether the page needs a header
if (settings.PossibleForcedBreaks)
{ // only want to take the performance hit if there's a change we're forcing breaks
if (String.IsNullOrEmpty(doc.GetText("Text")))
{ // WSH Found situation where after I added page break always for multi-form, one test that was already breaking properly, added an extra page that was blank between forms. Almost like some amount of HTML had been put there, even though it wasn't any real text. By checking to make sure there is some actual text on page, we can avoid that problem
doc.Delete(doc.Page);
}
}
}
if (settings.HeaderHeight > 0 && !String.IsNullOrEmpty(settings.HeaderText))
{
/*HttpServerUtility Server = HttpContext.Current.Server;
headerText = Server.HtmlDecode(headerText);*/
Doc headerDoc = new Doc();
headerDoc.MediaBox.String = settings.LeftMargin + " " + (settings.PageHeight - settings.HeaderHeight).ToString() + " " + (settings.PageWidth - settings.RightMargin).ToString() + " " + settings.PageHeight; //LEFT, BOTTOM,WIDTH, HEIGHT
headerDoc.Rect.String = settings.LeftMargin + " " + (settings.PageHeight - settings.HeaderHeight).ToString() + " " + (settings.PageWidth - settings.RightMargin).ToString() + " " + settings.PageHeight; //LEFT, BOTTOM,WIDTH, HEIGHT
headerDoc.VPos = 0.5;
int headerID = headerDoc.AddImageHtml(settings.HeaderText);
if (!String.IsNullOrEmpty(settings.HeaderText))
{
int form_ref = 0;
for (int i = 1; i <= doc.PageCount; i++)
{
if (form_ref < forms.Count && forms[form_ref] == i)
{
form_ref++;
}
else
{
if (i > 1 || settings.ShowHeaderOnFirstPage)
{
doc.PageNumber = i;
doc.Rect.String = settings.LeftMargin + " " + (settings.PageHeight - settings.HeaderHeight).ToString() + " " + (settings.PageWidth - settings.RightMargin).ToString() + " " + settings.PageHeight; //LEFT, BOTTOM,WIDTH, HEIGHT
doc.VPos = 0.5;
theID = doc.AddImageDoc(headerDoc, 1, null);
theID = doc.AddImageToChain(theID);
}
}
}
}
}
for (int i = 1; i <= doc.PageCount; i++)
{
doc.PageNumber = i;
doc.Flatten();
}
return doc;
}
示例2: RemoveBlankPages
//Method to remove blank pages from the pdf
protected void RemoveBlankPages(Doc pdf)
{
for (int i = pdf.PageCount; i > 0; i--)
{
pdf.PageNumber = i;
//get the pdf content
string textContent = pdf.GetText("Text");
//delete the page if it is blank
if (string.IsNullOrEmpty(textContent))
{ pdf.Delete(pdf.Page); }
}
}