我正在使用ABC.PDF从我现有的系统生成pdf。它具有表单认证机制。当我生成pdf时,它始终生成登录页面。 这是我的功能。请帮助我,先谢谢。
私人Doc GeneratePDFPage() {
var theDoc = new Doc();
theDoc.HtmlOptions.Engine = EngineType.MSHtml;
theDoc.HtmlOptions.AddLinks = true;
var uri = Context.Request.Url.ToString();
theDoc.HtmlOptions.LogonName = Context.User.Identity.Name;
theDoc.HtmlOptions.LogonPassword = "7126c198-5aee-47b2-8e6a-09c558892703";
var html = Response.Filter;
int theId = theDoc.AddImageUrl(uri);
//We now chain subsequent pages together. We stop when we reach a page which wasn't truncated
while (true)
{
theDoc.FrameRect();
if (!theDoc.Chainable(theId))
break;
theDoc.Page = theDoc.AddPage();
theId = theDoc.AddImageToChain(theId);
}
////////////////////////////////////////////////////
// Set pagenumber
////////////////////////////////////////////////////
theDoc.HtmlOptions.LinkPages();
//Set the position for the page number
////theDoc.Rect.String = "35 30 580 50";
////theDoc.Font = theDoc.AddFont("Trebuchet");
////theDoc.FontSize = 11;
////theDoc.HtmlOptions.UseScript = true;
int pagenumber = 1;
//flatten the pages. We can't do this until after the pages have been added because flattening will invalidate our previous ID and break the chain.
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
//Add page number
//========================================
string txt = pagenumber.ToString(CultureInfo.InvariantCulture);
////theDoc.Color.String = "169 169 169"; //Dark grey text
//Positioning depends on if the page is even or odd
theDoc.VPos = 1.0;
theDoc.HPos = (i % 2) == 0 ? 0.01 : 0.99;
//Add the page number
theDoc.AddText(txt);
//Add a line above page number
theDoc.AddLine(21, 55, 590, 55);
//Flatten page
theDoc.Flatten();
//Increase the page number count
pagenumber++;
}
return theDoc;
}
答案 0 :(得分:0)
将网页的位置添加到webconfig,并将其从授权中排除,如下所示;
<location path="pdfgenpage.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>