C# 如何设置特殊页面的页面大小,我只想旋转这些页面!
我有一份文件在里面。我想将默认的“pagesize”设置为“A4”,但这里有一些特殊的页面需要使用C# 如何设置特殊页面的页面大小,我只想旋转这些页面!,c#,itextsharp,rotation,C#,Itextsharp,Rotation,我有一份文件在里面。我想将默认的“pagesize”设置为“A4”,但这里有一些特殊的页面需要使用A4.Rotate()进行旋转(仅这些页面) document.setpagesize(A4.Rotate())用于要旋转的页面 很抱歉我的英语不好。这里有一个例子。它创建了一个包含4页的PDF文件。第1、2和4页使用A4纵向模式,而第3页使用A4横向模式: class Program { static void Main(string[] args) { Docum
A4.Rotate()
进行旋转(仅这些页面)
document.setpagesize(A4.Rotate())
用于要旋转的页面
很抱歉我的英语不好。这里有一个例子。它创建了一个包含4页的PDF文件。第1、2和4页使用A4纵向模式,而第3页使用A4横向模式:
class Program
{
static void Main(string[] args)
{
Document doc = new Document(PageSize.A4);
using (var stream = new FileStream("test.pdf", FileMode.Create, FileAccess.Write, FileShare.None))
{
var writer = PdfWriter.GetInstance(doc, stream);
doc.Open();
doc.NewPage();
doc.Add(new Paragraph("Page1 (portrait A4)"));
doc.NewPage();
doc.Add(new Paragraph("Page2 (portrait A4)"));
// Set page size before calling NewPage
doc.SetPageSize(PageSize.A4.Rotate());
doc.NewPage();
doc.Add(new Paragraph("Page3 (landscape A4)"));
// Revert to the original page size before adding new pages
doc.SetPageSize(PageSize.A4);
doc.NewPage();
doc.Add(new Paragraph("Page4 (portrait A4)"));
doc.Close();
}
}
还不错,哈米德,至少我能理解你的意思,帮你整理一下。