using IronPdf;
// Disable local disk access or cross-origin requests
Installation.EnableWebSecurity = true;
// Instantiate Renderer
var renderer = new ChromePdfRenderer();
// Create a PDF from a HTML string using C#
var pdf = renderer.RenderHtmlAsPdf("<h1>Hello World</h1>");
// Export to a file or Stream
pdf.SaveAs("output.pdf");
// Advanced Example with HTML Assets
// Load external html assets: Images, CSS and JavaScript.
// An optional BasePath 'C:\site\assets\' is set as the file location to load assets from
var myAdvancedPdf = renderer.RenderHtmlAsPdf("<img src='icons/iron.png'>", @"C:\site\assets\");
myAdvancedPdf.SaveAs("html-with-assets.pdf");
PDFsharp'tan IronPDF'e geçmek, PDF oluşturma iş akışınızı manuel koordinat tabanlı çizimden modern HTML/CSS şablonlamasına dönüştürür. Bu rehber, GDI+ stil konumlandırmayı web teknolojileri ile değiştiren adım adım bir geçiş yolu sunar, geliştirme süresini azaltır ve PDF oluşturma işlemini standart HTML/CSS becerileriyle sürdürülebilir hale getirir.
PDFsharp'tan IronPDF'e Neden Geçmeli?
PDFsharp'ı Anlamak
PDFsharp, geliştiricilere programlı olarak PDF belgeleri oluşturma imkanı veren düşük seviyeli bir PDF oluşturma kütüphanesidir. MIT lisansı altında piyasaya sürülen ve PDFsharp-Team (orijinal olarak empira Software GmbH) tarafından sürdürülenPDFsharp6.x, .NET 8/9/10 ve .NET Standard 2.0'ı hedefler ve Core yapısı üzerinden Windows, Linux ve macOS'ta çapraz platformda çalışır. PDFsharp, esas olarak çizim ve sıfırdan PDF derleme için araç olarak işlev görür ve bu, projenin doğasına bağlı olarak hem yararlı hem de kısıtlayıcı olabilir.
PDFsharp bazen yanlışlıkla bir HTML-to-PDF dönüştürücüsü olarak kabul edilir ki bu doğru değildir. Amacı yalnızca programlı PDF doküman oluşturma üzerinedir. ArthurHub tarafından sağlanan HtmlRenderer.PdfSharp adlı bir topluluk eklentisi, HTML işleme yetenekleri sağlamak için tasarlanmıştır ancak yalnızca HTML 4.01 / CSS seviye 2'yi kapsar — modern CSS özellikleri, flexbox, grid veya JavaScript gibi özellikler yoktur.
Koordinat Hesaplama Sorunu
PDFsharp'ın GDI+ yaklaşımı, şunları yapmanız gerektiği anlamına gelir:
Doğru X,Y konumlarını hesaplamanızı gerektirir
Sayfa taşmaları için içerik yüksekliğini manuel olarak takip etmenizi gerektirir
Satır kaydırma ve metin ölçümlemeyi kendiniz yapmalısınız
Hücre hücre kenarlı hesaplamalarla tablolar çizmelisiniz
Manuel sayfa kırılmaları ile çok sayfalı belgeler yönetmelisiniz
PDFsharp'ın mimarisi, genellikle karmaşık yerleşimler oluşturma konusunda zorluklar yaratan koordinatlar kullanarak konumlandırmanın derinlemesine anlaşılmasını gerektirir.
IronPDF, HTML belgelerinin tam aslına uygun olarak PDF'lere dönüştürülmesi gereken senaryolarda öne çıkar. Bu .NET kütüphanesi, modern web standartlarına uyum sağlamak için HTML5 ve CSS3'ü destekler. Yerel HTML'den PDF'ye dönüştürme yetenekleri, geliştiricilerin mevcut web içeriğinden veya çağdaş web araçları ile tasarlanan şablonlardan yararlanmasını sağlar.
Modern .NET kullanan ekipler için, IronPDF, koordinat hesaplamalarını ortadan kaldıranıft-adjacent yapılar için görselleştirme, işleme, ve baskı kapsamlarını ele alarak, görmek, işlemek ve PDF oluşturmanın ötesine geçen kullanım durumlarını kapsayan bir yaklaşımlar sunar.
IronPDF Lisansı: Lisans anahtarınızı ironpdf.com adresinden edinin
NuGet Paket Değişiklikleri
# RemovePDFsharp(official PDFsharp-Team package IDs; case-sensitive on case-sensitive feeds)
dotnet remove package PDFsharp
# dotnet remove package PDFsharp-WPF # if you used the WPF build
# dotnet remove package PDFsharp-GDI # if you used the GDI build
# dotnet remove package PDFsharp-MigraDoc # if you used MigraDoc on top
# dotnet remove package PdfSharpCore # community .NET Standard port
# Add IronPDF
dotnet add package IronPdf
# RemovePDFsharp(official PDFsharp-Team package IDs; case-sensitive on case-sensitive feeds)
dotnet remove package PDFsharp
# dotnet remove package PDFsharp-WPF # if you used the WPF build
# dotnet remove package PDFsharp-GDI # if you used the GDI build
# dotnet remove package PDFsharp-MigraDoc # if you used MigraDoc on top
# dotnet remove package PdfSharpCore # community .NET Standard port
# Add IronPDF
dotnet add package IronPdf
SHELL
Lisans Yapılandırması
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup (Program.cs or Startup.cs)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup (Program.vb or Startup.vb)
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
$vbLabelText $csharpLabel
PDFsharpKullanımını Belirleme
# Find allPDFsharpusages in your codebase
grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" .
# Find allPDFsharpusages in your codebase
grep -r "PdfSharp\|XGraphics\|XFont\|XBrush\|XPen" --include="*.cs" .
SHELL
Tam API Referansı
Ad Alanı Değişiklikleri
// Before: PDFsharp
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;
// After: IronPDF
using IronPdf;
using IronPdf.Editing;
// Before: PDFsharp
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using PdfSharp.Pdf.IO;
// After: IronPDF
using IronPdf;
using IronPdf.Editing;
Imports IronPdf
Imports IronPdf.Editing
$vbLabelText $csharpLabel
Temel API Eşlemeleri
PDFsharp API
IronPDF API
new PdfDocument()
ChromePdfRenderer.RenderHtmlAsPdf()
document.AddPage()
Otomatik
XGraphics.FromPdfPage()
Gerekli değil
XGraphics.DrawString()
HTML , , vb.
XGraphics.DrawImage()
HTML etiketi
XFont
CSS font-family, font-size
XBrush, XPen
CSS renkler/kenarlıklar
document.Save()
pdf.SaveAs()
PdfReader.Open()
PdfDocument.FromFile()
Kod Göç Örnekleri
Örnek 1: HTML'den PDF'ye Dönüştürme
Before (PDFsharp):
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
//PDFsharpdoes NOT support HTML-to-PDF natively. The community add-on
// HtmlRenderer.PdfSharp covers HTML 4.01 / CSS level 2 only (no flexbox, grid, JS).
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
//PDFsharpdoes not have built-in HTML'den PDF'ye conversion
// You need to manually parse HTML and render content
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Arial", 12);
//Yönergetext rendering (no HTML support)
gfx.DrawString("Hello from PDFsharp", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.TopLeft);
document.Save("output.pdf");
}
}
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
//PDFsharpdoes NOT support HTML-to-PDF natively. The community add-on
// HtmlRenderer.PdfSharp covers HTML 4.01 / CSS level 2 only (no flexbox, grid, JS).
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
//PDFsharpdoes not have built-in HTML'den PDF'ye conversion
// You need to manually parse HTML and render content
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Arial", 12);
//Yönergetext rendering (no HTML support)
gfx.DrawString("Hello from PDFsharp", font, XBrushes.Black,
new XRect(0, 0, page.Width, page.Height),
XStringFormats.TopLeft);
document.Save("output.pdf");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports System
Class Program
Shared Sub Main()
' PDFsharp does not have built-in HTML to PDF conversion
' You need to manually parse HTML and render content
Dim document As New PdfDocument()
Dim page As PdfPage = document.AddPage()
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
Dim font As New XFont("Arial", 12)
' Text rendering (no HTML support)
gfx.DrawString("Hello from PDFsharp", font, XBrushes.Black, New XRect(0, 0, page.Width, page.Height), XStringFormats.TopLeft)
document.Save("output.pdf")
End Sub
End Class
$vbLabelText $csharpLabel
Sonrası (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
//IronPDF has native HTML'den PDF'ye rendering
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello from IronPDF</h1><p>Easy HTML'den PDF'ye conversion</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
//IronPDF has native HTML'den PDF'ye rendering
var renderer = new ChromePdfRenderer();
string html = "<h1>Hello from IronPDF</h1><p>Easy HTML'den PDF'ye conversion</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Imports System
Class Program
Shared Sub Main()
' IronPDF has native HTML to PDF rendering
Dim renderer As New ChromePdfRenderer()
Dim html As String = "<h1>Hello from IronPDF</h1><p>Easy HTML to PDF conversion</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
End Sub
End Class
$vbLabelText $csharpLabel
Bu örnek, iki kütüphane arasındaki en büyük farkı vurgular. PDFsharp, yerleşik HTML'den PDF'ye dönüşüm sağlamaz—PdfDocument manuel oluşturmanız, bir PdfPage eklemeniz, bir XGraphics nesnesi almanız, bir XFont oluşturmanız ve DrawString() ile XRect koordinatlarını kullanmanız gerekir.
IronPDF, ChromePdfRenderer aracılığıyla yerel HTML'den PDF'ye dönüştürme sağlar. RenderHtmlAsPdf() metodu, HTML dizgilerini kabul eder ve dahili olarak bir Chromium motoru kullanarak dönüştürür. IronPDF, HTML5 ve CSS3'te tanımlı tüm stilleri koruyarak, HTML dosyalarını kolayca PDF'ye dönüştürür ve koordinat hesaplamalarına gerek kalmaz. Kapsamlı örnekler için HTML'den PDF'e dönüşüm belgelerine bakın.
Örnek 2: Mevcut PDF'ye Metin/Filigran Ekleme
Before (PDFsharp):
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
// Open existing PDF
PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify);
PdfPage page = document.Pages[0];
// Get graphics object
XGraphics gfx = XGraphics.FromPdfPage(page);
// Note: inPDFsharp6.x, XFontStyle was renamed to XFontStyleEx
XFont font = new XFont("Arial", 20, XFontStyleEx.Bold);
// Draw text at specific position
gfx.DrawString("Watermark Text", font, XBrushes.Red,
new XPoint(200, 400));
document.Save("modified.pdf");
}
}
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
using PdfSharp.Pdf;
using PdfSharp.Pdf.IO;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
// Open existing PDF
PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify);
PdfPage page = document.Pages[0];
// Get graphics object
XGraphics gfx = XGraphics.FromPdfPage(page);
// Note: inPDFsharp6.x, XFontStyle was renamed to XFontStyleEx
XFont font = new XFont("Arial", 20, XFontStyleEx.Bold);
// Draw text at specific position
gfx.DrawString("Watermark Text", font, XBrushes.Red,
new XPoint(200, 400));
document.Save("modified.pdf");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO
Imports PdfSharp.Drawing
Imports System
Module Program
Sub Main()
' Open existing PDF
Dim document As PdfDocument = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify)
Dim page As PdfPage = document.Pages(0)
' Get graphics object
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
' Note: in PDFsharp 6.x, XFontStyle was renamed to XFontStyleEx
Dim font As New XFont("Arial", 20, XFontStyleEx.Bold)
' Draw text at specific position
gfx.DrawString("Watermark Text", font, XBrushes.Red, New XPoint(200, 400))
document.Save("modified.pdf")
End Sub
End Module
$vbLabelText $csharpLabel
Sonrası (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Open existing PDF
var pdf = PdfDocument.FromFile("existing.pdf");
// Add text stamp/watermark
var textStamper = new TextStamper()
{
Text = "Watermark Text",
FontSize = 20,
FontFamily = "Arial",
IsBold = true,
FontColor = IronSoftware.Drawing.Color.Red,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};
pdf.ApplyStamp(textStamper);
pdf.SaveAs("modified.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Editing;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Open existing PDF
var pdf = PdfDocument.FromFile("existing.pdf");
// Add text stamp/watermark
var textStamper = new TextStamper()
{
Text = "Watermark Text",
FontSize = 20,
FontFamily = "Arial",
IsBold = true,
FontColor = IronSoftware.Drawing.Color.Red,
VerticalAlignment = VerticalAlignment.Middle,
HorizontalAlignment = HorizontalAlignment.Center
};
pdf.ApplyStamp(textStamper);
pdf.SaveAs("modified.pdf");
}
}
Imports IronPdf
Imports IronPdf.Editing
Imports System
Module Program
Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
' Open existing PDF
Dim pdf = PdfDocument.FromFile("existing.pdf")
' Add text stamp/watermark
Dim textStamper = New TextStamper() With {
.Text = "Watermark Text",
.FontSize = 20,
.FontFamily = "Arial",
.IsBold = True,
.FontColor = IronSoftware.Drawing.Color.Red,
.VerticalAlignment = VerticalAlignment.Middle,
.HorizontalAlignment = HorizontalAlignment.Center
}
pdf.ApplyStamp(textStamper)
pdf.SaveAs("modified.pdf")
End Sub
End Module
$vbLabelText $csharpLabel
PDFsharp, PdfReader.Open() ile belirterek PDF'yi açmayı, bir sayfaya erişimi, bir XGraphics nesnesi oluşturmayı, bir XFont ile stil yaratmayı ve kesin X,Y koordinatlarını (200, 400) belirten bir XPoint ile DrawString() kullanmayı gerektirir.
IronPDF, PdfDocument.FromFile(), TextStamper nesnesi ile beyanî özellikler (Text, FontSize, FontFamily, IsBold, FontColor, VerticalAlignment, HorizontalAlignment) ve ApplyStamp() ile bunu basitleştirir. Koordinat hesaplamalarına gerek yok—sadece hizalamayı belirtin ve IronPDF, konumlandırmayı halleder. Dikkat edin ki, damgalama işlevselliği için IronPdf.Editing ad alanı gereklidir.
Örnek 3: Resimlerle PDF Oluşturma
Before (PDFsharp):
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
// Create new PDF document
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
// Load and draw image
XImage image = XImage.FromFile("image.jpg");
// Calculate size to fit page
double width = 200;
double height = 200;
gfx.DrawImage(image, 50, 50, width, height);
// Add text
XFont font = new XFont("Arial", 16);
gfx.DrawString("Image in PDF", font, XBrushes.Black,
new XPoint(50, 270));
document.Save("output.pdf");
}
}
// NuGet: Install-PackagePDFsharp (official PDFsharp-Team package, MIT)
using PdfSharp.Pdf;
using PdfSharp.Drawing;
using System;
class Program
{
static void Main()
{
// Create new PDF document
PdfDocument document = new PdfDocument();
PdfPage page = document.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
// Load and draw image
XImage image = XImage.FromFile("image.jpg");
// Calculate size to fit page
double width = 200;
double height = 200;
gfx.DrawImage(image, 50, 50, width, height);
// Add text
XFont font = new XFont("Arial", 16);
gfx.DrawString("Image in PDF", font, XBrushes.Black,
new XPoint(50, 270));
document.Save("output.pdf");
}
}
Imports PdfSharp.Pdf
Imports PdfSharp.Drawing
Imports System
Class Program
Shared Sub Main()
' Create new PDF document
Dim document As New PdfDocument()
Dim page As PdfPage = document.AddPage()
Dim gfx As XGraphics = XGraphics.FromPdfPage(page)
' Load and draw image
Dim image As XImage = XImage.FromFile("image.jpg")
' Calculate size to fit page
Dim width As Double = 200
Dim height As Double = 200
gfx.DrawImage(image, 50, 50, width, height)
' Add text
Dim font As New XFont("Arial", 16)
gfx.DrawString("Image in PDF", font, XBrushes.Black, New XPoint(50, 270))
document.Save("output.pdf")
End Sub
End Class
$vbLabelText $csharpLabel
Sonrası (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Create PDF from HTML with image
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Image in PDF</h1>
<img src='image.jpg' style='width:200px; height:200px;' />
<p>Easy image embedding with HTML</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
// Alternative: Add image to existing PDF
var existingPdf = new ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>");
var imageStamper = new IronPdf.Editing.ImageStamper(new Uri("image.jpg"))
{
VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top
};
existingPdf.ApplyStamp(imageStamper);
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class Program
{
static void Main()
{
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Create PDF from HTML with image
var renderer = new ChromePdfRenderer();
string html = @"
<h1>Image in PDF</h1>
<img src='image.jpg' style='width:200px; height:200px;' />
<p>Easy image embedding with HTML</p>";
var pdf = renderer.RenderHtmlAsPdf(html);
pdf.SaveAs("output.pdf");
// Alternative: Add image to existing PDF
var existingPdf = new ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>");
var imageStamper = new IronPdf.Editing.ImageStamper(new Uri("image.jpg"))
{
VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top
};
existingPdf.ApplyStamp(imageStamper);
}
}
Imports IronPdf
Imports System
Module Program
Sub Main()
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
' Create PDF from HTML with image
Dim renderer As New ChromePdfRenderer()
Dim html As String = "
<h1>Image in PDF</h1>
<img src='image.jpg' style='width:200px; height:200px;' />
<p>Easy image embedding with HTML</p>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
pdf.SaveAs("output.pdf")
' Alternative: Add image to existing PDF
Dim existingPdf = New ChromePdfRenderer().RenderHtmlAsPdf("<h1>Document</h1>")
Dim imageStamper = New IronPdf.Editing.ImageStamper(New Uri("image.jpg")) With {
.VerticalAlignment = IronPdf.Editing.VerticalAlignment.Top
}
existingPdf.ApplyStamp(imageStamper)
End Sub
End Module
$vbLabelText $csharpLabel
PDFsharp, yeni bir PdfDocument oluşturarak, bir PdfPage ekleyerek, XGraphics alarak, bir XImage dosyasından yükleyerek, genişliği ve yüksekliği hesaplayarak, kesin koordinat (50, 50, 200, 200) ile DrawImage() kullanmayı ve ardından metni DrawString() ile ayrı olarak eklemeyi gerektirir.
IronPDF, standart HTML ve bir etiketiyle CSS stilini (style='width:200px; height:200px;') kullanır. Koordinat hesaplamalarına gerek yok—CSS düzeni halleder.IronPDF ayrıca, beyanî hizalama özellikleri ile mevcut PDF'lere görüntü eklemek için ImageStamper sağlar. Daha fazla bilgiyi kılavuzlarımızda öğrenin.
Kritik Taşıma Notları
Paradigma Değişimi: Koordinatlardan HTML/CSS'ye
En önemli değişiklik, koordinat tabanlı çizimden HTML/CSS'ye geçmektir:
// PDFsharp: manual positioning
gfx.DrawString("Invoice", titleFont, XBrushes.Black, new XPoint(50, 50));
gfx.DrawString("Customer: John", bodyFont, XBrushes.Black, new XPoint(50, 80));
// IronPDF: let CSS handle layout
var html = @"
<div style='padding: 50px;'>
<h1>Invoice</h1>
<p>Customer: John</p>
</div>";
var pdf = renderer.RenderHtmlAsPdf(html);
// PDFsharp: manual positioning
gfx.DrawString("Invoice", titleFont, XBrushes.Black, new XPoint(50, 50));
gfx.DrawString("Customer: John", bodyFont, XBrushes.Black, new XPoint(50, 80));
// IronPDF: let CSS handle layout
var html = @"
<div style='padding: 50px;'>
<h1>Invoice</h1>
<p>Customer: John</p>
</div>";
var pdf = renderer.RenderHtmlAsPdf(html);
Imports PdfSharp.Drawing
Imports IronPdf
' PDFsharp: manual positioning
gfx.DrawString("Invoice", titleFont, XBrushes.Black, New XPoint(50, 50))
gfx.DrawString("Customer: John", bodyFont, XBrushes.Black, New XPoint(50, 80))
' IronPDF: let CSS handle layout
Dim html As String = "
<div style='padding: 50px;'>
<h1>Invoice</h1>
<p>Customer: John</p>
</div>"
Dim pdf = renderer.RenderHtmlAsPdf(html)
$vbLabelText $csharpLabel
Yazı Tipi Geçişi
// PDFsharp: XFont objects (PDFsharp 6.x renamed XFontStyle to XFontStyleEx)
var titleFont = new XFont("Arial", 24, XFontStyleEx.Bold);
var bodyFont = new XFont("Times New Roman", 12);
// IronPDF: CSS font properties
var html = @"
<style>
h1 { font-family: Arial, sans-serif; font-size: 24px; font-weight: bold; }
p { font-family: 'Times New Roman', serif; font-size: 12px; }
</style>";
// PDFsharp: XFont objects (PDFsharp 6.x renamed XFontStyle to XFontStyleEx)
var titleFont = new XFont("Arial", 24, XFontStyleEx.Bold);
var bodyFont = new XFont("Times New Roman", 12);
// IronPDF: CSS font properties
var html = @"
<style>
h1 { font-family: Arial, sans-serif; font-size: 24px; font-weight: bold; }
p { font-family: 'Times New Roman', serif; font-size: 12px; }
</style>";
' PDFsharp: XFont objects (PDFsharp 6.x renamed XFontStyle to XFontStyleEx)
Dim titleFont As New XFont("Arial", 24, XFontStyleEx.Bold)
Dim bodyFont As New XFont("Times New Roman", 12)
' IronPDF: CSS font properties
Dim html As String = "
<style>
h1 { font-family: Arial, sans-serif; font-size: 24px; font-weight: bold; }
p { font-family: 'Times New Roman', serif; font-size: 12px; }
</style>"
$vbLabelText $csharpLabel
Doküman Yükleme Değişikliği
// PDFsharp: PdfReader.Open()
PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify);
// IronPDF: PdfDocument.FromFile()
var pdf = PdfDocument.FromFile("existing.pdf");
// PDFsharp: PdfReader.Open()
PdfDocument document = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify);
// IronPDF: PdfDocument.FromFile()
var pdf = PdfDocument.FromFile("existing.pdf");
Imports PdfSharp.Pdf
Imports PdfSharp.Pdf.IO
Imports IronPdf
' PDFsharp: PdfReader.Open()
Dim document As PdfDocument = PdfReader.Open("existing.pdf", PdfDocumentOpenMode.Modify)
' IronPDF: PdfDocument.FromFile()
Dim pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")
// PDFsharp: document.Pages[0]
PdfPage page = document.Pages[0];
// IronPDF:Otomatikpage handling or pdf.Pages[0]
// Pages are created automatically from HTML content
// PDFsharp: document.Pages[0]
PdfPage page = document.Pages[0];
// IronPDF:Otomatikpage handling or pdf.Pages[0]
// Pages are created automatically from HTML content
$vbLabelText $csharpLabel
Geçiş Sonrası Yeni Özellikler
IronPDF'e geçiş yaptıktan sonra, PDFsharp'ın sağlayamadığı yetenekler kazanırsınız:
Yerli HTML'den PDF'ye
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>");
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>");
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf("<h1>Modern Web Content</h1>")
$vbLabelText $csharpLabel
URL'den PDF'e
var pdf = renderer.RenderUrlAsPdf("https://example.com");
var pdf = renderer.RenderUrlAsPdf("https://example.com");
Dim pdf = renderer.RenderUrlAsPdf("https://example.com")
$vbLabelText $csharpLabel
PDF Birleştirme
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
var pdf1 = PdfDocument.FromFile("document1.pdf");
var pdf2 = PdfDocument.FromFile("document2.pdf");
var merged = PdfDocument.Merge(pdf1, pdf2);
Dim pdf1 = PdfDocument.FromFile("document1.pdf")
Dim pdf2 = PdfDocument.FromFile("document2.pdf")
Dim merged = PdfDocument.Merge(pdf1, pdf2)
Ad alanı içe aktarımlarını güncelleyin (using PdfSharp.Pdf; → using IronPdf;)
Damgalama işlevselliği için using IronPdf.Editing; ekleyin
Koordinat tabanlı düzenleri HTML/CSS'ye dönüştür
XFont yerine CSS font özelliklerini kullanın
XPen yerine CSS renkleri/kenarlıkları kullanın
XGraphics.DrawString() yerine HTML metin öğelerini kullanın
XGraphics.DrawImage() yerine HTML etiketlerini kullanın
PdfReader.Open() ile PdfDocument.FromFile() değiştirin
document.Save() ile pdf.SaveAs() değiştirin
Tablo çizim kodunu HTML tablolara dönüştür
Geçiş Sonrası
Oluşturulan PDF'lerin görsel karşılaştırması
Çok sayfalı belgeleri test et
Yazı tipi işleme doğrula
Yeni özellikler ekle (HTML'den PDF'ye, birleştirme, filigranlar) gerektiğinde
Lütfen dikkate alınPDFsharp, sahibine ait bir ticari markadır. Bu site, PDFsharp-Team veya empira Software GmbH ile bir bağlantılı değil, onaylanmış veya desteklenmemiştir. Tüm ürün adları, logolar ve markalar kendi sahiplerine aittir. Karşılaştırmalar, yalnızca bilgilendirme amaçlıdır ve yazı sırasında halka açık bilgilerle alakalı olarak yansıtılmaktadır.
Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapı...