Altbilgi içeriğine atla
JAVA IçIN IRONPDF KULLANıMı

Java'da PDF Dosyası Nasıl Yazılır

Bu makale, programatik olarak PDF belgeleri oluşturmak için IronPDF'yi keşfedecek.

IronPDF for Java PDF Kutuphanesi

Java PDF Kütüphanesi by IronPDF, geliştiricilerin Java uygulamalarında PDF belgeleri oluşturmasını, düzenlemesini ve işlemesini sağlar. Uygulamalarının verilerinden PDF dosyaları oluşturması gereken Java geliştiriciler için bu kütüphane, çeşitli işlevsellikler sunduğu için mükemmel bir seçim olacaktır.

IronPDF, yeni HTML içeriği ekleme, HTML başlıklar ve altbilgiler yapıştırma, belgeleri damgalama ve filigranlama, şifre korumalı PDF belgeleri oluşturma, PDF belgelerine dijital imzalar uygulama, belgeleri arka planlar ve ön planlarla geliştirme, XML belgelerinden tam bir PDF dosyası oluşturma, açıklamalar ekleme ve düzenleme, ve daha iyi gezinme için çizelgeler ve yer imleri kullanma gibi özelliklerle birlikte gelir. Daha yakından bakış atalım.

Yeni HTML İçeriği Ekle

IronPDF ile geliştiriciler, PDF belgelerine kolayca yeni HTML içeriği ekleyebilir. Bu, zengin HTML içeriği ile PDF form belgelerini dinamik olarak oluşturmak isteyen geliştiriciler için harika bir özelliktir. Kütüphane, resimler, bağlantılar ve tablolar gibi birçok HTML öğesini destekler. HTML içerikleri de CSS kullanılarak stillendirilebilir, böylece profesyonel görünümlü PDF'ler oluşturmayı kolaylaştırır.

import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;

// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");

// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));

// Render the HTML as a PDF. Stored in myPdf as type PdfDocument.
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1>Hello World</h1> Made with IronPDF!");

// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;

// Apply your license key
License.setLicenseKey("YOUR-LICENSE-KEY");

// Set a log path
Settings.setLogPath(Paths.get("C:/tmp/IronPdfEngine.log"));

// Render the HTML as a PDF. Stored in myPdf as type PdfDocument.
PdfDocument myPdf = PdfDocument.renderHtmlAsPdf("<h1>Hello World</h1> Made with IronPDF!");

// Save the PdfDocument to a file
myPdf.saveAs(Paths.get("html_saved.pdf"));
JAVA

Java'da PDF Dosyasi Yazma, Sekil 1: Cikti PDF Çıktı PDF

HTML Başlıkları ve Altbilgileri Ekle

Başlıklar ve altbilgiler, birçok PDF belgesinin temel bileşenleridir ve IronPDF, belgelere HTML başlıkları ve altbilgileri eklemeyi kolaylaştırır. IronPDF ile geliştiriciler, belgelerine metin, resimler ve sayfa numaralarını içeren özel başlıklar ve altbilgiler ekleyebilir. Bu özellik, belgelere markalama veya telif hakkı bilgisi eklemeleri gereken işletmeler için özellikle kullanışlıdır.

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.headerfooter.HtmlHeaderFooter;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;

// Render a PDF from a URL
PdfDocument pdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com");

// Build a footer using HTML
HtmlHeaderFooter footer = new HtmlHeaderFooter();
footer.setMaxHeight(15); // millimeters
footer.setHtmlFragment("<center><i>{page} of {total-pages}</i></center>");
footer.setDrawDividerLine(true);
pdf.addHtmlFooter(footer);
List<PdfDocument> pdfs = new ArrayList<>();

// Build a header using an image asset
HtmlHeaderFooter header = new HtmlHeaderFooter();
header.setMaxHeight(20); // millimeters
header.setHtmlFragment("<img src=\"logo.png\" />");
header.setBaseUrl("./assets/");
pdf.addHtmlHeader(header);

try {
    pdf.saveAs(Paths.get("assets/html_headers_footers.pdf"));
} catch (IOException e) {
    throw new RuntimeException(e);
}
import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.headerfooter.HtmlHeaderFooter;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;

// Render a PDF from a URL
PdfDocument pdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com");

// Build a footer using HTML
HtmlHeaderFooter footer = new HtmlHeaderFooter();
footer.setMaxHeight(15); // millimeters
footer.setHtmlFragment("<center><i>{page} of {total-pages}</i></center>");
footer.setDrawDividerLine(true);
pdf.addHtmlFooter(footer);
List<PdfDocument> pdfs = new ArrayList<>();

// Build a header using an image asset
HtmlHeaderFooter header = new HtmlHeaderFooter();
header.setMaxHeight(20); // millimeters
header.setHtmlFragment("<img src=\"logo.png\" />");
header.setBaseUrl("./assets/");
pdf.addHtmlHeader(header);

try {
    pdf.saveAs(Paths.get("assets/html_headers_footers.pdf"));
} catch (IOException e) {
    throw new RuntimeException(e);
}
JAVA

Java'da PDF Dosyasi Yazma, Sekil 2: Cikti PDF Çıktı PDF

Damga & Filigran

IronPDF kullanarak geliştiriciler, PDF belgelerine damgalar ve filigranlar ekleyebilir. Filigranlar, belgenin arka planında görünen şeffaf resimler veya metinlerdir, damgalar ise yeni bir belgeye özel bir mesaj veya resim ekler.

Bu özellikler, belgelerini izinsiz kullanımdan korumaları veya belgelerine özel bir mesaj eklemeleri gereken işletmeler için harikadır.

package IronPDF.ironpdf_java;

import java.io.IOException;
import java.nio.file.Paths;
import com.ironsoftware.ironpdf.*;
import com.ironsoftware.ironpdf.stamp.HorizontalAlignment;
import com.ironsoftware.ironpdf.stamp.VerticalAlignment;

public class Test {
    public static void main(String[] args) throws IOException {
        License.setLicenseKey("Your-License");

        // Load an existing PDF from the filesystem
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("C:\\byteToPdf.pdf"));

        // Apply a watermark to the PDF
        pdf.applyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, VerticalAlignment.TOP, HorizontalAlignment.CENTER);

        // Save the watermarked PDF
        pdf.saveAs(Paths.get("assets/watermark.pdf"));
    }
}
package IronPDF.ironpdf_java;

import java.io.IOException;
import java.nio.file.Paths;
import com.ironsoftware.ironpdf.*;
import com.ironsoftware.ironpdf.stamp.HorizontalAlignment;
import com.ironsoftware.ironpdf.stamp.VerticalAlignment;

public class Test {
    public static void main(String[] args) throws IOException {
        License.setLicenseKey("Your-License");

        // Load an existing PDF from the filesystem
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("C:\\byteToPdf.pdf"));

        // Apply a watermark to the PDF
        pdf.applyWatermark("<h2 style='color:red'>SAMPLE</h2>", 30, VerticalAlignment.TOP, HorizontalAlignment.CENTER);

        // Save the watermarked PDF
        pdf.saveAs(Paths.get("assets/watermark.pdf"));
    }
}
JAVA

Java'da PDF Dosyasi Yazma, Sekil 3: Cikti PDF Çıktı PDF

Arka Planlar & Ön Planlar

IronPDF ayrıca geliştiricilerin PDF belgelerine özel arka planlar ve ön planlar uygulamalarına olanak tanır. Ön planlar, bir belgede özelleştirilmiş metin veya resimler eklemek için kullanılırken, arka planlar arka plana özel bir resim veya renk ekler. Belgelerine veya PDF formlarına özel markalama veya grafikler eklemek isteyen iş sahipleri için bu özellik özellikle faydalıdır.

import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;

public class BackgroundForegroundExample {

    public static void main(String[] args) throws IOException {
        // Load background and foreground PDFs from the filesystem
        PdfDocument backgroundPdf = PdfDocument.fromFile(Paths.get("assets/MyBackground.pdf"));
        PdfDocument foregroundPdf = PdfDocument.fromFile(Paths.get("assets/MyForeground.pdf"));

        // Render content (HTML, URL, etc) as a PDF Document
        PdfDocument pdf = PdfDocument.renderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

        // Add the background and foreground PDFs to the newly-rendered document.
        pdf.addBackgroundPdf(backgroundPdf);
        pdf.addForegroundPdf(foregroundPdf);

        // Save the document with background and foreground
        pdf.saveAs(Paths.get("assets/BackgroundForegroundPdf.pdf"));
    }
}
import com.ironsoftware.ironpdf.*;
import java.io.IOException;
import java.nio.file.Paths;

public class BackgroundForegroundExample {

    public static void main(String[] args) throws IOException {
        // Load background and foreground PDFs from the filesystem
        PdfDocument backgroundPdf = PdfDocument.fromFile(Paths.get("assets/MyBackground.pdf"));
        PdfDocument foregroundPdf = PdfDocument.fromFile(Paths.get("assets/MyForeground.pdf"));

        // Render content (HTML, URL, etc) as a PDF Document
        PdfDocument pdf = PdfDocument.renderUrlAsPdf("https://www.nuget.org/packages/IronPdf");

        // Add the background and foreground PDFs to the newly-rendered document.
        pdf.addBackgroundPdf(backgroundPdf);
        pdf.addForegroundPdf(foregroundPdf);

        // Save the document with background and foreground
        pdf.saveAs(Paths.get("assets/BackgroundForegroundPdf.pdf"));
    }
}
JAVA

Ek Açıklamalar Ekle ve Düzenle

Açıklamalar, PDF belgelerine ek bilgi eklemek için harika bir yoldur, örneğin notlar, yorumlar veya vurgular. IronPDF ile geliştiriciler, PDF belgelerindeki açıklamaları kolayca ekleyebilir ve düzenleyerek etkin bir şekilde yönetebilir.

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.annotation.AnnotationIcon;
import com.ironsoftware.ironpdf.annotation.AnnotationManager;
import com.ironsoftware.ironpdf.annotation.AnnotationOptions;
import java.io.IOException;
import java.nio.file.Paths;

public class AnnotationExample {

    public static void main(String[] args) throws IOException {
        // Load an existing PDF from the file system
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/example.pdf"));

        // Create an annotation to be placed at a specific location on a page.
        AnnotationOptions annotation = new AnnotationOptions(
            "This is a major title", // Title of the annotation
            "This is the long 'sticky note' comment content...", // Content of the annotation
            150, // x-axis coordinate location
            250  // y-axis coordinate location
        );
        annotation.setIcon(AnnotationIcon.HELP);
        annotation.setOpacity(0.9);
        annotation.setPrintable(false);
        annotation.setHidden(false);
        annotation.setOpen(true);
        annotation.setReadonly(true);
        annotation.setRotateable(true);

        // Add the annotation to a specific page of the PDF
        AnnotationManager annotationManager = pdf.getAnnotation();
        annotationManager.addTextAnnotation(annotation, 0); // Add to the first page

        // Save the PDF with the modifications
        pdf.saveAs(Paths.get("assets/annotated.pdf"));
    }
}
import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.annotation.AnnotationIcon;
import com.ironsoftware.ironpdf.annotation.AnnotationManager;
import com.ironsoftware.ironpdf.annotation.AnnotationOptions;
import java.io.IOException;
import java.nio.file.Paths;

public class AnnotationExample {

    public static void main(String[] args) throws IOException {
        // Load an existing PDF from the file system
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/example.pdf"));

        // Create an annotation to be placed at a specific location on a page.
        AnnotationOptions annotation = new AnnotationOptions(
            "This is a major title", // Title of the annotation
            "This is the long 'sticky note' comment content...", // Content of the annotation
            150, // x-axis coordinate location
            250  // y-axis coordinate location
        );
        annotation.setIcon(AnnotationIcon.HELP);
        annotation.setOpacity(0.9);
        annotation.setPrintable(false);
        annotation.setHidden(false);
        annotation.setOpen(true);
        annotation.setReadonly(true);
        annotation.setRotateable(true);

        // Add the annotation to a specific page of the PDF
        AnnotationManager annotationManager = pdf.getAnnotation();
        annotationManager.addTextAnnotation(annotation, 0); // Add to the first page

        // Save the PDF with the modifications
        pdf.saveAs(Paths.get("assets/annotated.pdf"));
    }
}
JAVA

Java'da PDF Dosyasi Yazma, Sekil 4: Cikti Dosya Çıktı Dosyası

Çıkıntılar ve Yer İmleri

Geliştiriciler, IronPDF kullanarak PDF belgelerini yer imleri ile geliştirebilir. Bir çizelge, belgenin içeriğinin yüksek seviyede bir özetini sağlarken, yer imleri belirli bölümlere hızlı erişim sağlar. Büyük veya karmaşık belgelerde, bu özellik kullanıcıların istedikleri bölümlere hızlı bir şekilde ulaşmasını sağlar.

import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.bookmark.Bookmark;
import com.ironsoftware.ironpdf.bookmark.BookmarkManager;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;

public class BookmarkExample {

    public static void main(String[] args) throws IOException {
        // Load an existing PDF from the file system
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/book.pdf"));

        // Add top-level bookmarks to pages of the PDF using their page indices
        BookmarkManager bookmarks = pdf.getBookmark();
        bookmarks.addBookMarkAtEnd("Author's Note", 2);
        bookmarks.addBookMarkAtEnd("Table of Contents", 3);
        bookmarks.addBookMarkAtEnd("Summary", 10);
        bookmarks.addBookMarkAtEnd("References", 12);

        List<Bookmark> bookmarkList = bookmarks.getBookmarks();
        Bookmark bookmark = bookmarkList.get(2);

        // Add a child bookmark
        bookmark.addChildBookmark("Conclusion", 11);

        // Save the PDF to the filesystem
        pdf.saveAs(Paths.get("assets/bookmarked.pdf"));
    }
}
import com.ironsoftware.ironpdf.PdfDocument;
import com.ironsoftware.ironpdf.bookmark.Bookmark;
import com.ironsoftware.ironpdf.bookmark.BookmarkManager;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.List;

public class BookmarkExample {

    public static void main(String[] args) throws IOException {
        // Load an existing PDF from the file system
        PdfDocument pdf = PdfDocument.fromFile(Paths.get("assets/book.pdf"));

        // Add top-level bookmarks to pages of the PDF using their page indices
        BookmarkManager bookmarks = pdf.getBookmark();
        bookmarks.addBookMarkAtEnd("Author's Note", 2);
        bookmarks.addBookMarkAtEnd("Table of Contents", 3);
        bookmarks.addBookMarkAtEnd("Summary", 10);
        bookmarks.addBookMarkAtEnd("References", 12);

        List<Bookmark> bookmarkList = bookmarks.getBookmarks();
        Bookmark bookmark = bookmarkList.get(2);

        // Add a child bookmark
        bookmark.addChildBookmark("Conclusion", 11);

        // Save the PDF to the filesystem
        pdf.saveAs(Paths.get("assets/bookmarked.pdf"));
    }
}
JAVA

Özet

Bu makale, PDF belgelerine açıklamalar, yer imleri, HTML içerikleri, arka plan ve ön plan renkleri ve başlıklar ve altbilgiler ekleme yeteneği gibi çeşitli IronPDF özelliklerini keşfeder. Makale, bu özelliklerin IronPDF kullanarak uygulanması için adım adım talimatlar sağlar, böylece geliştiricilerin kendi özel ihtiyaçlarını karşılayan profesyonel görünümlü PDF belgeleri oluşturmalarını kolaylaştırır.

Bir web uygulaması veya masaüstü uygulaması oluşturuyor olun, IronPDF, PDF belgeleri oluşturma sürecini kolaylaştırabilir, zamandan ve çabadan tasarruf etmenizi sağlar ve belgelerinizin harika görünmesini garanti eder.

IronPDF lisanslama bilgisi $799'den başlamaktadir. IronPDF, ayrıca geliştiricilerin kütüphaneyi test etmelerine ve satın alma kararı öncesinde yeteneklerini değerlendirmelerine olanak tanıyan ücretsiz bir deneme sunar. Deneme süresi boyunca, kullanıcılar, kütüphanenin destek ve güncellemeler dahil tüm özelliklerine erişebilir. Deneme süresi sona erdikten sonra, kullanıcılar kütüphaneyi kullanmaya devam etmek için bir lisans satın almayı tercih edebilir. IronPDF'nin fiyatlandırması, kütüphaneyi kullanan geliştirici sayısına ve lisans türüne göre değişir.

Sıkça Sorulan Sorular

Java'da programlama ile PDF belgelerini nasıl oluşturabilirim?

Java'da IronPDF ile programlama ile PDF belgeleri oluşturabilirsiniz. Kütüphane, HTML içeriği, başlıklar, alt bilgiler ve daha fazlasını destekleyerek yüksek kaliteli PDF'ler üretmek için geniş bir özellik yelpazesi sunar.

Bir PDF'ye HTML içeriği eklemek için hangi yöntemler mevcuttur?

IronPDF, geliştiricilerin HTML içeriğini doğrudan bir PDF'ye eklemek için RenderHtmlAsPdf yöntemini kullanmalarına izin verir. Bu yöntem, çeşitli HTML öğelerini ve stil verme için CSS'i destekler.

PDF belgelerime dijital imzalar ekleyebilir miyim?

Evet, IronPDF, PDF belgelerine dijital imzalar eklemeyi destekler, belge otantikliği ve güvenliği sağlar.

PDF belgelerimi şifrelerle nasıl koruyabilirim?

IronPDF, belgelerinizdeki hassas bilgileri güvenli hale getirmenize olanak tanıyan şifre korumalı PDF'ler oluşturma işlevi sunar.

PDF'lere özel arka planlar ve ön planlar eklemek mümkün mü?

IronPDF, geliştiricilerin PDF'lere özel arka planlar ve ön planlar eklemesine olanak tanır, bunlar marka öğelerini veya dekoratif grafikleri içerebilir.

PDF belge gezintisini geliştirmek için dış hatlar ve yer imleri nasıl yardımcı olabilir?

IronPDF, kullanıcıların bir PDF'nin belirli bölümlerine hızlı bir şekilde gitmelerine yardımcı olan, ayrıca belge yapısının düzenli bir genel görünümünü sağlayan dış hatlar ve yer imleri eklemesine imkan tanır.

PDF belgeleri için hangi açıklama seçenekleri mevcut?

IronPDF ile, çeşitli açıklamalar, notlar, yorumlar ve vurgulamalar ekleyerek, PDF belgelerinizin etkileşimini ve kullanılabilirliğini artırabilirsiniz.

Java uygulamalarında IronPDF'yi kullanmanın lisanslama seçenekleri nelerdir?

IronPDF, değerlendirme amaçlı ücretsiz bir deneme de dahil olmak üzere birkaç lisanslama seçeneği sunar. Lisanslar, geliştirici sayısına ve projenizin belirli ihtiyaçlarına göre değişir.

Darrius Serrant
Tam Yığın Yazılım Mühendisi (WebOps)

Darrius Serrant, Miami Üniversitesi'nden Bilgisayar Bilimleri lisans derecesine sahiptir ve Iron Software'de Tam Yığın WebOps Pazarlama Mühendisi olarak çalışmaktadır. Küçük yaşlardan itibaren kodlamaya ilgi duyan Darrius, bilişimi hem gizemli hem de erişilebilir buldu ve onu yaratıcılık ve problem çö...

Daha Fazlasını Oku

Iron Destek Ekibi

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