创建PDF时,旋转到第一页的横向 [英] Rotate to landscape for first page when creating PDF

查看:166
本文介绍了创建PDF时,旋转到第一页的横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将文档中的所有页面轮播到横向

I want to rotate all pages in my document to landscape

我试过:

PdfWriter.GetInstance(mydoc, New FileStream(filename, FileMode.Create))
mydoc.Open()
mydoc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate())
... add rest of document and close ...

但只有我的第二个页面是横向的,第一个是肖像。

but only my 2nd page is landscape, the first is portrait.

推荐答案

您需要在之前更改页面大小打开文件。当你调用 mydoc.Open()时,第一页被初始化,你不能再改变它的旋转,大小...... ...

You need to change the page size before you open the document. The moment you invoke mydoc.Open() the first page is initialized and you can no longer change its rotation, size,...

另外:如果需要旋转所有页面,为什么不从头开始使用正确的尺寸和方向创建文档实例?

Also: if all pages need to be rotated, why not create the document instance using the correct size and orientation from the start?

Document document = new Document(PageSize.A4.Rotate());

这样你就不必改变大小了。

That way you don't have to change the size.

这篇关于创建PDF时,旋转到第一页的横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆