using IronPdf;using IronPdf.GrpcLayer;// Configure for Docker containervar config = IronPdfConnectionConfiguration.Docker;config.Host = "localhost";IronPdf.Installation.ConnectToIronPdfHost(config);// Use IronPDFChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>");pdf.SaveAs("ironpdf.pdf");
using IronPdf;
using IronPdf.GrpcLayer;
// Configure for Docker container
var config = IronPdfConnectionConfiguration.Docker;
config.Host = "localhost";
IronPdf.Installation.ConnectToIronPdfHost(config);
// Use IronPDF
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>");
pdf.SaveAs("ironpdf.pdf");
ImportsIronPdfImportsIronPdf.GrpcLayer' Configure for Docker containerPrivate config = IronPdfConnectionConfiguration.Dockerconfig.Host = "localhost"IronPdf.Installation.ConnectToIronPdfHost(config)' Use IronPDFDim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>")pdf.SaveAs("ironpdf.pdf")
Imports IronPdf
Imports IronPdf.GrpcLayer
' Configure for Docker container
Private config = IronPdfConnectionConfiguration.Docker
config.Host = "localhost"
IronPdf.Installation.ConnectToIronPdfHost(config)
' Use IronPDF
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>")
pdf.SaveAs("ironpdf.pdf")
连接类型
您可以根据要建立的连接类型分配几个 IronPdfConnectionType。
以下是可供出租的房产列表:
LocalExecutable :要连接到在本地计算机上运行可执行文件的 IronPdfEngine"服务器",我们使用此选项。 一个简单的例子是 WinForm 发票应用程序,它可以在本地生成 PDF 文件,而无需依赖云服务。
using IronPdf;// This code demonstrates how to use IronPdf with gRPC in a .NET Framework application.// 1. Configure connection to use local IronPdfEngine executablevar config = IronPdf.GrpcLayer.IronPdfConnectionConfiguration.Executable;// 2. Connect to the IronPDF host with the executable configurationIronPdf.Installation.ConnectToIronPdfHost(config);// 3. Create a PDF renderer instanceChromePdfRenderer renderer = new ChromePdfRenderer();// 4. Render HTML string as PDF documentPdfDocument pdf = renderer.RenderHtmlAsPdf("Hello world");// 5. Save the PDF to diskpdf.SaveAs("output.pdf");// 6. Clean up , this is needed to workpdf.Dispose();
using IronPdf;
// This code demonstrates how to use IronPdf with gRPC in a .NET Framework application.
// 1. Configure connection to use local IronPdfEngine executable
var config = IronPdf.GrpcLayer.IronPdfConnectionConfiguration.Executable;
// 2. Connect to the IronPDF host with the executable configuration
IronPdf.Installation.ConnectToIronPdfHost(config);
// 3. Create a PDF renderer instance
ChromePdfRenderer renderer = new ChromePdfRenderer();
// 4. Render HTML string as PDF document
PdfDocument pdf = renderer.RenderHtmlAsPdf("Hello world");
// 5. Save the PDF to disk
pdf.SaveAs("output.pdf");
// 6. Clean up , this is needed to work
pdf.Dispose();
ImportsIronPdf' This code demonstrates how to use IronPdf with gRPC in a .NET Framework application.' 1. Configure connection to use local IronPdfEngine executableDim config = IronPdf.GrpcLayer.IronPdfConnectionConfiguration.Executable' 2. Connect to the IronPDF host with the executable configurationIronPdf.Installation.ConnectToIronPdfHost(config)' 3. Create a PDF renderer instanceDim renderer As New ChromePdfRenderer()' 4. Render HTML string as PDF documentDim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("Hello world")' 5. Save the PDF to diskpdf.SaveAs("output.pdf")' 6. Clean up, this is needed to workpdf.Dispose()
Imports IronPdf
' This code demonstrates how to use IronPdf with gRPC in a .NET Framework application.
' 1. Configure connection to use local IronPdfEngine executable
Dim config = IronPdf.GrpcLayer.IronPdfConnectionConfiguration.Executable
' 2. Connect to the IronPDF host with the executable configuration
IronPdf.Installation.ConnectToIronPdfHost(config)
' 3. Create a PDF renderer instance
Dim renderer As New ChromePdfRenderer()
' 4. Render HTML string as PDF document
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("Hello world")
' 5. Save the PDF to disk
pdf.SaveAs("output.pdf")
' 6. Clean up, this is needed to work
pdf.Dispose()
using IronPdf;using IronPdf.GrpcLayer;using Grpc.Core;// 1. Create custom gRPC channel (.NET Framework style)var channel = new Channel("123.456.7.8:80", ChannelCredentials.SecureSsl);// 2. (Optional) Add metadata headers if neededvar metadata = new Metadata{ { "Authorization", "Bearer your_token_here" }};// 3. Configure IronPDF with custom channelvar config = IronPdfConnectionConfiguration.WithCustomChannel(channel, metadata);IronPdf.Installation.ConnectToIronPdfHost(config);// 4. Generate PDFvar renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("Hello world");// 5. Save the PDF to diskpdf.SaveAs("output.pdf");// 6. Clean up , this is needed to workpdf.Dispose();
using IronPdf;
using IronPdf.GrpcLayer;
using Grpc.Core;
// 1. Create custom gRPC channel (.NET Framework style)
var channel = new Channel("123.456.7.8:80", ChannelCredentials.SecureSsl);
// 2. (Optional) Add metadata headers if needed
var metadata = new Metadata
{
{ "Authorization", "Bearer your_token_here" }
};
// 3. Configure IronPDF with custom channel
var config = IronPdfConnectionConfiguration.WithCustomChannel(channel, metadata);
IronPdf.Installation.ConnectToIronPdfHost(config);
// 4. Generate PDF
var renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("Hello world");
// 5. Save the PDF to disk
pdf.SaveAs("output.pdf");
// 6. Clean up , this is needed to work
pdf.Dispose();
ImportsIronPdfImportsIronPdf.GrpcLayerImportsGrpc.Core' 1. Create custom gRPC channel (.NET Framework style)Dim channel As New Channel("123.456.7.8:80", ChannelCredentials.SecureSsl)' 2. (Optional) Add metadata headers if neededDim metadata As New MetadataFrom { {"Authorization", "Bearer your_token_here"}}' 3. Configure IronPDF with custom channelDim config AsIronPdfConnectionConfiguration = IronPdfConnectionConfiguration.WithCustomChannel(channel, metadata)IronPdf.Installation.ConnectToIronPdfHost(config)' 4. Generate PDFDim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("Hello world")' 5. Save the PDF to diskpdf.SaveAs("output.pdf")' 6. Clean up, this is needed to workpdf.Dispose()
Imports IronPdf
Imports IronPdf.GrpcLayer
Imports Grpc.Core
' 1. Create custom gRPC channel (.NET Framework style)
Dim channel As New Channel("123.456.7.8:80", ChannelCredentials.SecureSsl)
' 2. (Optional) Add metadata headers if needed
Dim metadata As New Metadata From {
{"Authorization", "Bearer your_token_here"}
}
' 3. Configure IronPDF with custom channel
Dim config As IronPdfConnectionConfiguration = IronPdfConnectionConfiguration.WithCustomChannel(channel, metadata)
IronPdf.Installation.ConnectToIronPdfHost(config)
' 4. Generate PDF
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("Hello world")
' 5. Save the PDF to disk
pdf.SaveAs("output.pdf")
' 6. Clean up, this is needed to work
pdf.Dispose()
using IronPdf;using IronPdf.GrpcLayer;IronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01";IronPdfConnectionConfiguration configuration = new IronPdfConnectionConfiguration();configuration.ConnectionType = IronPdfConnectionType.RemoteServer;configuration.Host = "http://48.216.143.233";configuration.Port = 80;IronPdf.Installation.ConnectToIronPdfHost(configuration);ChromePdfRenderer renderer = new ChromePdfRenderer();PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");pdf.SaveAs("output.pdf");
using IronPdf;
using IronPdf.GrpcLayer;
IronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01";
IronPdfConnectionConfiguration configuration = new IronPdfConnectionConfiguration();
configuration.ConnectionType = IronPdfConnectionType.RemoteServer;
configuration.Host = "http://48.216.143.233";
configuration.Port = 80;
IronPdf.Installation.ConnectToIronPdfHost(configuration);
ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>testing</h1>");
pdf.SaveAs("output.pdf");
ImportsIronPdfImportsIronPdf.GrpcLayerIronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"Dim configuration As New IronPdfConnectionConfiguration()configuration.ConnectionType = IronPdfConnectionType.RemoteServerconfiguration.Host = "http://48.216.143.233"configuration.Port = 80IronPdf.Installation.ConnectToIronPdfHost(configuration)Dim renderer As New ChromePdfRenderer()Dim pdf AsPdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")pdf.SaveAs("output.pdf")
Imports IronPdf
Imports IronPdf.GrpcLayer
IronPdf.License.LicenseKey = "IRONPDF-MYLICENSE-KEY-1EF01"
Dim configuration As New IronPdfConnectionConfiguration()
configuration.ConnectionType = IronPdfConnectionType.RemoteServer
configuration.Host = "http://48.216.143.233"
configuration.Port = 80
IronPdf.Installation.ConnectToIronPdfHost(configuration)
Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>testing</h1>")
pdf.SaveAs("output.pdf")
Are there specific logging configurations available for IronPdfEngine?
Yes, IronPdfEngine supports various logging configurations, including console, file, and custom modes. This flexibility helps in monitoring and debugging, allowing developers to choose the best method for their needs.