Altbilgi içeriğine atla
GEçIş KıLAVUZLARı

Gotenberg'den IronPDF'e C# ile Nasıl Geçilir

Gotenberg'den IronPDF'ye geçiş, .NET PDF iş akışınızı HTTP API çağrıları ile Docker tabanlı mikro hizmet mimarisinden yerel bir C# kütüphanesine dönüştürür. Bu kılavuz, altyapı yükünü, ağ gecikmelerini ve konteyner yönetimi karmaşıklığını ortadan kaldıran kapsamlı, adım adım bir geçiş yolu sağlar ve profesyonel .NET geliştiricilerine yöneliktir.

Neden Gotenberg'den IronPDF'ye Geçmeli

GotenbergMimari Sorunu

Gotenberg, PDF üretimi için Docker tabanlı bir mikroservis mimarisidir. Güçlü ve esnek olmasına rağmen, C# uygulamaları için önemli bir karmaşıklık getirir:

  1. Altyapı Yükü: Docker, konteyner orkestrasyonu (Kubernetes/Docker Compose), servis keşfi ve yük dengelemesi gerektirir. Her dağıtım daha karmaşık hale gelir.

  2. Ağ Gecikmesi: Her PDF işlemi, ayrı bir servise yapılan bir HTTP çağrısını gerektirir—bu da isteğe 10-100 ms+ ekler. Bu gecikme, yüksek hacimli senaryolarda hızla artar.

  3. Soğuk Başlangıç Sorunları: Konteyner başlatmaları, ilk istekler için 2-5 saniye ekleyebilir. Her pod yeniden başlatma, her ölçek artışı ve her dağıtım soğuk başlangıçları tetikler.

  4. Operasyonel Karmaşıklık: Konteyner sağlığını, ölçeklemeyi, loglamayı ve izlemeyi ana uygulamanızdan ayrı konular olarak yönetmeniz gerekir.

  5. Multipart Form Data: Her istek, multipart/form-data yükleri oluşturmayı gerektirir—söz fazla, hata yapmaya yatkın ve sürdürülmesi zahmetli.

  6. Hata Noktaları: Ağ zaman aşımı, servis kullanılamazlığı ve konteyner çöküşleri tümüyle ele alınması gereken sorumluluğunuz olur.

  7. Sürüm Yönetimi:Gotenberggörüntüleri uygulamanızdan ayrı güncellenir; API değişiklikleri entegrasyonları beklenmedik şekilde bozabilir.

Gotenberg veIronPDFKarşılaştırması

Bağlam Gotenberg IronPDF
Dağıtım Docker konteyner + orkestrasyon Tekar NuGet paketi
Mimari Mikroservis (REST API) In-process kütüphane
İstek başına gecikme 10-100ms+ (ağ yuvarlak sefer) <1ms yük
Soğuk başlatma 2-5 saniye (konteyner başlangıcı) 1-2 saniye (sadece ilk render)
Altyapı Docker, Kubernetes, yük dengeleyiciler Gerekli değil
Hata Modları Ağ, konteyner, hizmet hataları Standart .NET istisnaları
API Stili REST mp4uralteri/form:data Yerel C# metod çağrıları
Ölçekleme Yatay (daha fazla konteyner) Dikey (in-process)
Hata ayıklama Dağıtılmış izleme gerekli Standart hata ayıklayıcı
Sürüm Kontrolü Kapsayıcı görsel etiketleri NuGet paket sürümleri

2025 ve 2026'ya kadar .NET 10 ve C# 14 benimsemeyi planlayan ekipler için IronPDF, altyapı bağımlılığı olmadan, modern .NET kalıplarıyla yerel olarak entegre olan gelecek sağlam bir temel sağlar.


Göç Karmaşıklık Değerlendirmesi

Özelliklere Göre Tahmini Çaba

Özellik Göç Karmaşıklığı
HTML'den PDF'ye Çok Düşük
URL'den PDF'ye Çok Düşük
Özel Kağıt Boyutu Low
Kenar Boşlukları Low
PDF Merging Low
Üstbilgi/Altbilgi Medium
Bekleme Gecikmeleri Low
PDF/A Dönüştürme Low

Paradigma Değişikliği

BuGotenberggeçişindeki temel değişiklik, multipart form data ile HTTP API çağrılarından yerel C# metot çağrılarına:'dir

Gotenberg: Docker konteynerine HTTP POST multipart/form-data
IronPDF: C# nesnelerinde doğrudan metot çağrıları

Başlamadan Önce

Önkoşullar

  1. .NET Sürümü: IronPDF, .NET Framework 4.6.2+ ve .NET Core 3.1+ / .NET 5/6/7/8/9+ destekler
  2. Lisans Anahtarı:IronPDFlisans anahtarınızı ironpdf.com'dan alın
  3. Altyapı Kaldırma Planı:Gotenbergkonteynerlarını göç sonrası devre dışı bırakmak için belgeleyin

TümGotenbergKullanımını Tanımlayın

# Find direct HTTP calls to Gotenberg
grep -r "gotenberg\|/forms/chromium\|/forms/libreoffice\|/forms/pdfengines" --include="*.cs" .

# Find GotenbergSharpApiClient usage
grep -r "GotenbergSharpClient\|Gotenberg.Sharp\|ChromiumRequest" --include="*.cs" .

# Find Docker/KubernetesGotenbergconfiguration
grep -r "gotenberg/gotenberg\|gotenberg:" --include="*.yml" --include="*.yaml" .
# Find direct HTTP calls to Gotenberg
grep -r "gotenberg\|/forms/chromium\|/forms/libreoffice\|/forms/pdfengines" --include="*.cs" .

# Find GotenbergSharpApiClient usage
grep -r "GotenbergSharpClient\|Gotenberg.Sharp\|ChromiumRequest" --include="*.cs" .

# Find Docker/KubernetesGotenbergconfiguration
grep -r "gotenberg/gotenberg\|gotenberg:" --include="*.yml" --include="*.yaml" .
SHELL

NuGet Paket Değişiklikleri

# RemoveGotenbergclient (if using)
dotnet remove package Gotenberg.Sharp.API.Client

# Install IronPDF
dotnet add package IronPdf
# RemoveGotenbergclient (if using)
dotnet remove package Gotenberg.Sharp.API.Client

# Install IronPDF
dotnet add package IronPdf
SHELL

Hızlı Başlangıç Göçü

Adım 1: Lisans Yapılandırmasını Güncelleyin

Önce (Gotenberg):

Gotenberg bir lisans gerektirmez ancak Docker altyapısı ile konteyner URL'leri gerektirir.

private readonly string _gotenbergUrl = "http://localhost:3000";
private readonly string _gotenbergUrl = "http://localhost:3000";
Private ReadOnly _gotenbergUrl As String = "http://localhost:3000"
$vbLabelText   $csharpLabel

Sonra (IronPDF):

// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
// Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY";
' Set once at application startup
IronPdf.License.LicenseKey = "YOUR-IRONPDF-LICENSE-KEY"
$vbLabelText   $csharpLabel

Adım 2: Ad Alanı Dışarı Aktarımlarını Güncelleyin

// Before (Gotenberg)
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

// After (IronPDF)
using IronPdf;
using IronPdf.Rendering;
// Before (Gotenberg)
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

// After (IronPDF)
using IronPdf;
using IronPdf.Rendering;
Imports System.Net.Http
Imports System.Threading.Tasks
Imports System.IO

Imports IronPdf
Imports IronPdf.Rendering
$vbLabelText   $csharpLabel

API Referansının Tamamı

Gotenberg Uç Noktası ileIronPDFEşlemesi

Gotenberg Yolu IronPDF Eşdeğeri
POST /forms/chromium/convert/html ChromePdfRenderer.RenderHtmlAsPdf()
POST /forms/chromium/convert/url ChromePdfRenderer.RenderUrlAsPdf()
POST /forms/pdfengines/merge PdfDocument.Merge()
POST /forms/pdfengines/convert pdf.SaveAs() ayarlarla
GET /health N/A

Form Parametresinden RenderingOptions Eşlemesi

Gotenberg Parametresi IronPDF Özelliği Dönüşüm Notları
paperWidth (inç) RenderingOptions.PaperSize Enum veya özel boyut kullanın
paperHeight (inç) RenderingOptions.PaperSize Enum veya özel boyut kullanın
marginTop (inç) RenderingOptions.MarginTop mm için 25.4 ile çarp
marginBottom (inç) RenderingOptions.MarginBottom mm için 25.4 ile çarp
printBackground RenderingOptions.PrintHtmlBackgrounds Mantıksal
landscape RenderingOptions.PaperOrientation Landscape enum
waitDelay RenderingOptions.RenderDelay Milisaniyeye dönüştür

Kod Geçiş Örnekleri

Örnek 1: Temel HTML'den PDF'ye

Önce (Gotenberg):

using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergExample
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        var html = "<html><body><h1>Hello from Gotenberg</h1></body></html>";
        content.Add(new StringContent(html), "files", "index.html");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("output.pdf", pdfBytes);
        Console.WriteLine("PDF generated successfully");
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergExample
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        var html = "<html><body><h1>Hello from Gotenberg</h1></body></html>";
        content.Add(new StringContent(html), "files", "index.html");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("output.pdf", pdfBytes);
        Console.WriteLine("PDF generated successfully");
    }
}
Imports System
Imports System.Net.Http
Imports System.Threading.Tasks
Imports System.IO

Module GotenbergExample
    Async Function Main() As Task
        Dim gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html"

        Using client As New HttpClient()
            Using content As New MultipartFormDataContent()
                Dim html = "<html><body><h1>Hello from Gotenberg</h1></body></html>"
                content.Add(New StringContent(html), "files", "index.html")

                Dim response = Await client.PostAsync(gotenbergUrl, content)
                Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()

                Await File.WriteAllBytesAsync("output.pdf", pdfBytes)
                Console.WriteLine("PDF generated successfully")
            End Using
        End Using
    End Function
End Module
$vbLabelText   $csharpLabel

Sonra (IronPDF):

// NuGet: Install-Package IronPdf
using System;
using IronPdf;

class IronPdfExample
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        var html = "<html><body><h1>Hello from IronPDF</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("output.pdf");
        Console.WriteLine("PDF generated successfully");
    }
}
// NuGet: Install-Package IronPdf
using System;
using IronPdf;

class IronPdfExample
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        var html = "<html><body><h1>Hello from IronPDF</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("output.pdf");
        Console.WriteLine("PDF generated successfully");
    }
}
Imports System
Imports IronPdf

Class IronPdfExample
    Shared Sub Main()
        Dim renderer = New ChromePdfRenderer()

        Dim html = "<html><body><h1>Hello from IronPDF</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        pdf.SaveAs("output.pdf")
        Console.WriteLine("PDF generated successfully")
    End Sub
End Class
$vbLabelText   $csharpLabel

Fark önemli: Gotenberg, bir HttpClient oluşturmayı, MultipartFormDataContent inşa etmeyi, çalıştırılan bir Docker konteynerine async bir HTTP POST yapmayı ve byte dizisi yanıtını yönetmeyi gerektirir.IronPDFbunu üç satıra indirir ve ChromePdfRenderer metot çağrısı yapar—ağ yükü yok, konteyner bağımlılığı yok, async karmaşıklığı yok. Daha fazla işleme seçeneği için HTML'den PDF'ye dokümantasyonuna bakın.

Örnek 2: URL'den PDF'e Dönüştürme

Önce (Gotenberg):

using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergUrlToPdf
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/url";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        content.Add(new StringContent("https://example.com"), "url");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("webpage.pdf", pdfBytes);
        Console.WriteLine("PDF from URL generated successfully");
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergUrlToPdf
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/url";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        content.Add(new StringContent("https://example.com"), "url");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("webpage.pdf", pdfBytes);
        Console.WriteLine("PDF from URL generated successfully");
    }
}
Imports System
Imports System.Net.Http
Imports System.Threading.Tasks
Imports System.IO

Module GotenbergUrlToPdf
    Async Function Main() As Task
        Dim gotenbergUrl As String = "http://localhost:3000/forms/chromium/convert/url"

        Using client As New HttpClient()
            Using content As New MultipartFormDataContent()
                content.Add(New StringContent("https://example.com"), "url")

                Dim response As HttpResponseMessage = Await client.PostAsync(gotenbergUrl, content)
                Dim pdfBytes As Byte() = Await response.Content.ReadAsByteArrayAsync()

                Await File.WriteAllBytesAsync("webpage.pdf", pdfBytes)
                Console.WriteLine("PDF from URL generated successfully")
            End Using
        End Using
    End Function
End Module
$vbLabelText   $csharpLabel

Sonra (IronPDF):

// NuGet: Install-Package IronPdf
using System;
using IronPdf;

class IronPdfUrlToPdf
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        var pdf = renderer.RenderUrlAsPdf("https://example.com");

        pdf.SaveAs("webpage.pdf");
        Console.WriteLine("PDF from URL generated successfully");
    }
}
// NuGet: Install-Package IronPdf
using System;
using IronPdf;

class IronPdfUrlToPdf
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        var pdf = renderer.RenderUrlAsPdf("https://example.com");

        pdf.SaveAs("webpage.pdf");
        Console.WriteLine("PDF from URL generated successfully");
    }
}
Imports System
Imports IronPdf

Class IronPdfUrlToPdf
    Shared Sub Main()
        Dim renderer As New ChromePdfRenderer()

        Dim pdf = renderer.RenderUrlAsPdf("https://example.com")

        pdf.SaveAs("webpage.pdf")
        Console.WriteLine("PDF from URL generated successfully")
    End Sub
End Class
$vbLabelText   $csharpLabel

Gotenberg yaklaşımı, farklı bir uç nokta (/forms/chromium/convert/url), URL'yi form alanı olarak içeren birkaç parçalı içerik oluşturmayı ve async HTTP yanıtlarını yönetmeyi gerektirir. IronPDF'nin RenderUrlAsPdf() metodu URL'yi doğrudan kabul eder ve eşzamanlı olarak bir PdfDocument nesnesi döndürür. URL'den PDF'ye dönüşüm hakkında daha fazla bilgi edinin.

Örnek 3: Özel Kağıt Boyutu ve Kenar Boşlukları

Önce (Gotenberg):

using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergCustomSize
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        var html = "<html><body><h1>Custom Size PDF</h1></body></html>";
        content.Add(new StringContent(html), "files", "index.html");
        content.Add(new StringContent("8.5"), "paperWidth");
        content.Add(new StringContent("11"), "paperHeight");
        content.Add(new StringContent("0.5"), "marginTop");
        content.Add(new StringContent("0.5"), "marginBottom");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("custom-size.pdf", pdfBytes);
        Console.WriteLine("Custom size PDF generated successfully");
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.IO;

class GotenbergCustomSize
{
    static async Task Main()
    {
        var gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html";

        using var client = new HttpClient();
        using var content = new MultipartFormDataContent();

        var html = "<html><body><h1>Custom Size PDF</h1></body></html>";
        content.Add(new StringContent(html), "files", "index.html");
        content.Add(new StringContent("8.5"), "paperWidth");
        content.Add(new StringContent("11"), "paperHeight");
        content.Add(new StringContent("0.5"), "marginTop");
        content.Add(new StringContent("0.5"), "marginBottom");

        var response = await client.PostAsync(gotenbergUrl, content);
        var pdfBytes = await response.Content.ReadAsByteArrayAsync();

        await File.WriteAllBytesAsync("custom-size.pdf", pdfBytes);
        Console.WriteLine("Custom size PDF generated successfully");
    }
}
Imports System
Imports System.Net.Http
Imports System.Threading.Tasks
Imports System.IO

Class GotenbergCustomSize
    Shared Async Function Main() As Task
        Dim gotenbergUrl = "http://localhost:3000/forms/chromium/convert/html"

        Using client As New HttpClient()
            Using content As New MultipartFormDataContent()
                Dim html = "<html><body><h1>Custom Size PDF</h1></body></html>"
                content.Add(New StringContent(html), "files", "index.html")
                content.Add(New StringContent("8.5"), "paperWidth")
                content.Add(New StringContent("11"), "paperHeight")
                content.Add(New StringContent("0.5"), "marginTop")
                content.Add(New StringContent("0.5"), "marginBottom")

                Dim response = Await client.PostAsync(gotenbergUrl, content)
                Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()

                Await File.WriteAllBytesAsync("custom-size.pdf", pdfBytes)
                Console.WriteLine("Custom size PDF generated successfully")
            End Using
        End Using
    End Function
End Class
$vbLabelText   $csharpLabel

Sonra (IronPDF):

// NuGet: Install-Package IronPdf
using System;
using IronPdf;
using IronPdf.Rendering;

class IronPdfCustomSize
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
        renderer.RenderingOptions.MarginTop = 50;
        renderer.RenderingOptions.MarginBottom = 50;

        var html = "<html><body><h1>Custom Size PDF</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("custom-size.pdf");
        Console.WriteLine("Custom size PDF generated successfully");
    }
}
// NuGet: Install-Package IronPdf
using System;
using IronPdf;
using IronPdf.Rendering;

class IronPdfCustomSize
{
    static void Main()
    {
        var renderer = new ChromePdfRenderer();

        renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter;
        renderer.RenderingOptions.MarginTop = 50;
        renderer.RenderingOptions.MarginBottom = 50;

        var html = "<html><body><h1>Custom Size PDF</h1></body></html>";
        var pdf = renderer.RenderHtmlAsPdf(html);

        pdf.SaveAs("custom-size.pdf");
        Console.WriteLine("Custom size PDF generated successfully");
    }
}
Imports System
Imports IronPdf
Imports IronPdf.Rendering

Module IronPdfCustomSize

    Sub Main()
        Dim renderer As New ChromePdfRenderer()

        renderer.RenderingOptions.PaperSize = PdfPaperSize.Letter
        renderer.RenderingOptions.MarginTop = 50
        renderer.RenderingOptions.MarginBottom = 50

        Dim html As String = "<html><body><h1>Custom Size PDF</h1></body></html>"
        Dim pdf = renderer.RenderHtmlAsPdf(html)

        pdf.SaveAs("custom-size.pdf")
        Console.WriteLine("Custom size PDF generated successfully")
    End Sub

End Module
$vbLabelText   $csharpLabel

Gotenberg, birkaç parçalı form verilerine eklenen string tabanlı parametreler ("8.5", "11", "0.5") gerektirir—tip güvenliği yok, IntelliSense yok, yazmaktan kolay hata olabilir. IronPDF, PdfPaperSize enum ve sayısal marjin değerleri ile güçlü bir şekilde yazılan özellikler sağlar. Unutmayın kiIronPDFkenar boşlukları milimetre cinsindendir (50mm ≈ 2 inç), oysaGotenberginç kullanır.


Kritik Geçiş Notları

Birim Dönüştürmeleri

BuGotenberggeçişindeki en önemli dönüşüm, kenar boşluklarının birimleridir:

// Gotenberg: margins in inches
content.Add(new StringContent("0.5"), "marginTop");    // 0.5 inches
content.Add(new StringContent("1"), "marginBottom");   // 1 inch

// IronPDF: margins in millimeters
renderer.RenderingOptions.MarginTop = 12.7;    // 0.5 inches × 25.4 = 12.7mm
renderer.RenderingOptions.MarginBottom = 25.4; // 1 inch × 25.4 = 25.4mm
// Gotenberg: margins in inches
content.Add(new StringContent("0.5"), "marginTop");    // 0.5 inches
content.Add(new StringContent("1"), "marginBottom");   // 1 inch

// IronPDF: margins in millimeters
renderer.RenderingOptions.MarginTop = 12.7;    // 0.5 inches × 25.4 = 12.7mm
renderer.RenderingOptions.MarginBottom = 25.4; // 1 inch × 25.4 = 25.4mm
' Gotenberg: margins in inches
content.Add(New StringContent("0.5"), "marginTop")    ' 0.5 inches
content.Add(New StringContent("1"), "marginBottom")   ' 1 inch

' IronPDF: margins in millimeters
renderer.RenderingOptions.MarginTop = 12.7    ' 0.5 inches × 25.4 = 12.7mm
renderer.RenderingOptions.MarginBottom = 25.4 ' 1 inch × 25.4 = 25.4mm
$vbLabelText   $csharpLabel

Dönüşüm formülü: millimeters = inches × 25.4

Eşzamanlı vs Asenkron

Gotenberg, HTTP iletişimi nedeniyle asenkron işlemler gerektirir:

// Gotenberg: Forced async due to network calls
var response = await client.PostAsync(gotenbergUrl, content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();

// IronPDF: Synchronous in-process execution
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");

// IronPDF: Async wrapper if needed
var pdf = await Task.Run(() => renderer.RenderHtmlAsPdf(html));
// Gotenberg: Forced async due to network calls
var response = await client.PostAsync(gotenbergUrl, content);
var pdfBytes = await response.Content.ReadAsByteArrayAsync();

// IronPDF: Synchronous in-process execution
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");

// IronPDF: Async wrapper if needed
var pdf = await Task.Run(() => renderer.RenderHtmlAsPdf(html));
Imports System.Net.Http

' Gotenberg: Forced async due to network calls
Dim response = Await client.PostAsync(gotenbergUrl, content)
Dim pdfBytes = Await response.Content.ReadAsByteArrayAsync()

' IronPDF: Synchronous in-process execution
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")

' IronPDF: Async wrapper if needed
Dim pdf = Await Task.Run(Function() renderer.RenderHtmlAsPdf(html))
$vbLabelText   $csharpLabel

Hata Yönetimi

// Gotenberg: HTTP error handling
try
{
    var response = await client.PostAsync(gotenbergUrl, content);
    response.EnsureSuccessStatusCode();  // What if 500? 503? Timeout?
}
catch (HttpRequestException ex) { /* Network error */ }
catch (TaskCanceledException ex) { /* Timeout */ }

// IronPDF: Standard .NET exceptions
try
{
    var pdf = renderer.RenderHtmlAsPdf(html);
}
catch (Exception ex)
{
    Console.WriteLine($"PDF generation failed: {ex.Message}");
}
// Gotenberg: HTTP error handling
try
{
    var response = await client.PostAsync(gotenbergUrl, content);
    response.EnsureSuccessStatusCode();  // What if 500? 503? Timeout?
}
catch (HttpRequestException ex) { /* Network error */ }
catch (TaskCanceledException ex) { /* Timeout */ }

// IronPDF: Standard .NET exceptions
try
{
    var pdf = renderer.RenderHtmlAsPdf(html);
}
catch (Exception ex)
{
    Console.WriteLine($"PDF generation failed: {ex.Message}");
}
Imports System
Imports System.Net.Http
Imports System.Threading.Tasks

' Gotenberg: HTTP error handling
Try
    Dim response = Await client.PostAsync(gotenbergUrl, content)
    response.EnsureSuccessStatusCode()  ' What if 500? 503? Timeout?
Catch ex As HttpRequestException
    ' Network error
Catch ex As TaskCanceledException
    ' Timeout
End Try

' IronPDF: Standard .NET exceptions
Try
    Dim pdf = renderer.RenderHtmlAsPdf(html)
Catch ex As Exception
    Console.WriteLine($"PDF generation failed: {ex.Message}")
End Try
$vbLabelText   $csharpLabel

Altyapının Kaldırılması

Geçişten sonra Gotenberg'i altyapınızdan kaldırın:

# REMOVE from docker-compose.yml:
# services:
#   gotenberg:
#     image: gotenberg/gotenberg:8
#     ports:
#       - "3000:3000"
#     deploy:
#       resources:
#         limits:
#           memory: 2G
# REMOVE from docker-compose.yml:
# services:
#   gotenberg:
#     image: gotenberg/gotenberg:8
#     ports:
#       - "3000:3000"
#     deploy:
#       resources:
#         limits:
#           memory: 2G
YAML

Performans Dikkat Edilecek Noktalar

Gecikme Karşılaştırması

İşlem Gotenberg(Sıcak) Gotenberg (Soğuk Başlat) IronPDF (İlk Rendering) IronPDF (Sonraki)
Basit HTML 150-300ms 2-5 saniye 1-2 saniye 50-150ms
Karmaşık HTML 500-1500ms 3-7 saniye 1.5-3 saniye 200-800ms
URL Rendering 1-5 saniye 3-10 saniye 1-5 saniye 500ms-3s

Altyapı Maliyetinin Ortadan Kaldırılması

Kaynak Gotenberg IronPDF
Gerekli Kapsüller 1-N (ölçeklenebilirlik) 0
Kapsül başına bellek 512MB-2GB N/A
İstek başına ağ yükü 10-100ms 0ms
Sağlık kontrolü uç noktaları Gerekli Gerekli değil
Yük dengeleyici Genellikle gerekli Gerekli değil

Ariza Giderme

Sorun 1: HttpClient Desenleri Gerekli Değil

Problem: Kod hala HttpClient ve MultipartFormDataContent kullanıyor.

Cozum: Tamamen ChromePdfRenderer ile değiştirin:

// Remove all of this:
// using var client = new HttpClient();
// using var content = new MultipartFormDataContent();
// content.Add(new StringContent(html), "files", "index.html");
// var response = await client.PostAsync(url, content);

// Replace with:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
// Remove all of this:
// using var client = new HttpClient();
// using var content = new MultipartFormDataContent();
// content.Add(new StringContent(html), "files", "index.html");
// var response = await client.PostAsync(url, content);

// Replace with:
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(html);
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText   $csharpLabel

Sorun 2: Kenar Boşluğu Birimleri Yanlış

Problem: Geçişten sonra PDF'lerdeki kenar boşlukları yanlış.

Çözüm: İnç'leri milimetre'ye dönüştürün:

//Gotenbergused inches: "0.5"
//IronPDFuses millimeters: 0.5 × 25.4 = 12.7
renderer.RenderingOptions.MarginTop = 12.7;
//Gotenbergused inches: "0.5"
//IronPDFuses millimeters: 0.5 × 25.4 = 12.7
renderer.RenderingOptions.MarginTop = 12.7;
$vbLabelText   $csharpLabel

Sorun 3: Kapsül URL Referansları

Problem: Kod http://gotenberg:3000 veya benzeri URL'ler içeriyor.

Çözüm: Tüm kapsül URL referanslarını kaldırın—IronPDF, işlem sürecinde çalışır:

// Remove:
// private readonly string _gotenbergUrl = "http://gotenberg:3000";

//IronPDFneeds no URL - it's in-process
var renderer = new ChromePdfRenderer();
// Remove:
// private readonly string _gotenbergUrl = "http://gotenberg:3000";

//IronPDFneeds no URL - it's in-process
var renderer = new ChromePdfRenderer();
$vbLabelText   $csharpLabel

Goc Kontrol Listesi

Geçiş Öncesi

  • Kod tabanındaki tümGotenbergHTTP çağrılarını envanterine alın
  • MevcutGotenbergyapılandırmasını (zaman aşımı, kenar boşlukları, kağıt boyutları) dökümantasyon yapın
  • Tüm Docker/KubernetesGotenbergyapılandırmalarını tespit edin -IronPDFlisans anahtarını edinin
  • Altyapı hizmet dışı bırakma planı yapın

Kod Göçü

  • IronPdf NuGet paketini kurun: dotnet add package IronPdf -Gotenbergistemci paketlerini kaldırın
  • Gotenberg'e yapılan tüm HTTP çağrılarınıIronPDFyöntem çağrılarıyla değiştirin
  • Kenar boşluğu birimlerini inç'ten milimetre'ye dönüştürün
  • Hata işleme yöntemlerini güncelleyin (HTTP hataları → .NET istisnaları)
  • Başlangıçta lisans anahtarı başlangıcı ekleyin

Altyapı Geçişi

  • Gotenberg'i Docker Compose / Kubernetes'ten kaldırın
  • CI/CD hatlarını güncelleyin (Gotenberg görüntü çekimlerini çıkarın) -Gotenbergsağlık kontrollerini kaldırın -GotenbergURL'sini yapılandırmadan kaldırın

Test Etme

  • HTML'den PDF'ye donusumu test edin
  • URL'den PDF'ye donusumu test edin
  • Kenar boşlukları ve boyutlandırma doğruluğunu doğrulayın
  • Yuk altinda performans testi yapin
  • İlk oluşturma ısınma süresini test edin

Geçişten Sonra

-Gotenbergkapsül dağıtımlarını kaldırın -Gotenbergyapılandırma dosyalarını arşivleyin

  • Belgeleri güncelleyin
  • Uygulama bellek kullanımını izleyin
  • Hiçbir yetim ağ bağlantısının kalmadığını doğrulayın

Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında lisans derecesine sahiptir (Carleton Üniversitesi) ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirme üzerine uzmanlaşmıştır. Kullanıcı dostu ve estetik açıdan hoş arayüzler tasarlamaya tutkuyla bağlı olan Curtis, modern çerç...

Daha Fazlasını Oku

Iron Destek Ekibi

Haftanın 5 günü, 24 saat çevrimiçiyiz.
Sohbet
E-posta
Beni Ara