using IronPdf;
using System;
using System.IO;
var uri = new Uri("http://localhost:51169/Invoice");
var urlToPdf = new ChromePdfRenderer
{
RenderingOptions = new ChromePdfRenderOptions()
{
MarginTop = 50,
MarginBottom = 50,
TextHeader = new TextHeaderFooter()
{
CenterText = "{pdf-title}",
DrawDividerLine = true,
FontSize = 16
},
TextFooter = new TextHeaderFooter()
{
LeftText = "{date} {time}",
RightText = "Page {page} of {total-pages}",
DrawDividerLine = true,
FontSize = 14
},
CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
},
// setting login credentials to bypass basic authentication
LoginCredentials = new IronPdf.ChromeHttpLoginCredentials
{
NetworkUsername = "testUser",
NetworkPassword = "testPassword"
}
};
var pdf = urlToPdf.RenderUrlAsPdf(uri);
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdfExample2.Pdf"));
Imports IronPdf
Imports System
Imports System.IO
Private uri = New Uri("http://localhost:51169/Invoice")
Private urlToPdf = New ChromePdfRenderer With {
.RenderingOptions = New ChromePdfRenderOptions() With {
.MarginTop = 50,
.MarginBottom = 50,
.TextHeader = New TextHeaderFooter() With {
.CenterText = "{pdf-title}",
.DrawDividerLine = True,
.FontSize = 16
},
.TextFooter = New TextHeaderFooter() With {
.LeftText = "{date} {time}",
.RightText = "Page {page} of {total-pages}",
.DrawDividerLine = True,
.FontSize = 14
},
.CssMediaType = IronPdf.Rendering.PdfCssMediaType.Print
},
.LoginCredentials = New IronPdf.ChromeHttpLoginCredentials With {
.NetworkUsername = "testUser",
.NetworkPassword = "testPassword"
}
}
Private pdf = urlToPdf.RenderUrlAsPdf(uri)
pdf.SaveAs(Path.Combine(Directory.GetCurrentDirectory(), "UrlToPdfExample2.Pdf"))
Install-Package IronPdf
TLS-Website und Systemanmeldungen
Die meisten ASP.NET-Anwendungen unterstützen die Netzwerkauthentifizierung, die zuverlässiger ist als das Senden von HTML-Formularen. Weitere Beispiele zu IronPDF und Authentication Forms finden Sie in derPDFs hinter Systemanmeldungen rendern artikel.
Links zu verwandten Dokumenten
Sind Sie bereit, loszulegen? Version: 2024.12 gerade veröffentlicht