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
Connexion au site web et au système TLS
La plupart des applications ASP.NET prennent en charge l'authentification réseau, qui est plus fiable que l'affichage de formulaires html. Pour plus d'exemples sur IronPDF et les formulaires d'authentification, veuillez consulter : Rendre les PDF derrière les logins du système article.
Liens vers des documents connexes
Prêt à commencer ? Version : 2024.9 vient de paraître