Dikey ve Yatay Yönlendirme

import com.ironsoftware.ironpdf.PdfDocument;  
import com.ironsoftware.ironpdf.edit.PageSelection;  
import com.ironsoftware.ironpdf.page.PageRotation;  
import com.ironsoftware.ironpdf.render.*;  
import java.io.IOException;  
import java.nio.file.Paths;

// Use the setPaperOrientation method to set rendered PDFs in portrait or landscape orientation.  
// Note: This will only work for newly-created PDFs!  
ChromePdfRenderOptions renderOptions = new ChromePdfRenderOptions();  
renderOptions.setPaperOrientation(PaperOrientation.LANDSCAPE);  
PdfDocument newPdf = PdfDocument.renderUrlAsPdf("https://ironpdf.com", renderOptions);  
newPdf.saveAs(Paths.get("assets/LandscapePdf.pdf"));  
  
// Use the rotatePage/rotateAllPages methods to adjust the page orientation for existing PDFs  
PdfDocument existingPdf = PdfDocument.fromFile(Paths.get("assets/example.pdf"));  
  
// Get the orientation of the first page of the existing PDF document.  
PageRotation firstPageRotation = existingPdf.getPagesInfo().get(0).getPageRotation();  
System.out.println(firstPageRotation);  
  
// Rotate the first page of the document only 90 degrees clockwise.  
existingPdf.rotatePage(PageRotation.CLOCKWISE_90, PageSelection.firstPage());  
  
// Rotate all pages of the document clockwise.  
existingPdf.rotateAllPages(PageRotation.CLOCKWISE_270);  
  
existingPdf.saveAs(Paths.get("assets/ExistingPdfRotated.pdf"));
mvn install
Dikey ve Yatay Yönlendirme

Dikey ve Yatay Yönlendirme

IronPDF for Java, yeni ve mevcut PDF belgelerinin sayfa yönünü değiştirebilir.

IronPDF ile yenide render edilen yeni PDF belgeleri varsayılan olarak portre yönünde kullanılır. Geliştiriciler, içerik (HTML, RTF'ler, URL'ler, vb.) PDF'e dönüştürülürken bu davranışı ChromePdfRenderOptions örneği ile geçersiz kılabilir. setPaperOrientation yöntemi bir PaperOrientation değeri kabul eder ve geliştiricilerin ortaya çıkan PDF'in kağıt yönünü istedikleri gibi değiştirmelerine olanak tanır. Öne çıkan kod örneğinin 21 - 23. satırları, yatay yönlendirmede ayarlanmış bir PDF belgesi oluşturur. Satır 21'deki setPaperOrientation çağrısı, PaperOrientation.LANDSCAPE ile yönlendirme davranışını tetikler. Enum değerini PaperOrientation.PORTRAIT lehine değiştirmek, sonraki PdfDocument.renderUrlAsPdf çağrısının IronPDF anasayfasını dikey yönde oluşturmasını sağlar.

ChromePdfRenderOptions nesneleri, mevcut PDF'lerin sayfa yönünü değiştirmek için kullanılamaz (bunlar, herhangi bir PDF işleme yöntemine yapılan önceki çağrılardan üretilmiş veya PdfDocument.fromFile yöntemi kullanılarak IronPDF'ye yüklenmiş PdfDocumentlar olabilir). Bu PDF belgeleri için, döndürme tabanlı dönüşümlerle sayfa yönlendirmesi ayarlanabilir. Bu amaçla, IronPDF rotateAllPages yöntemini kullanıma sunar.

rotateAllPages, kabul edilen bir dizi döndürme değeri belirten bir PageRotation enum türü kabul eder. Öne çıkan kod örneğinin 40. satırı, PDF belgesinde çalışan her sayfayı saat yönünde 270 derece döndürür. Sadece bir sayfayı (veya sayfaların bir alt kümesini) döndürmek için rotateAllPages yerine rotatePage yöntemini tercih edin.

IronPDF for Java'da PaperOrientation hakkında daha fazla bilgi edinin.
GitHub üzerinde görüntüle

Başlamaya Hazır mısınız?

Sürüm:2026.10yeni çıktı