【发布时间】:2018-03-14 09:18:44
【问题描述】:
下面的代码创建一个横向的新 PDF。它使用 ABCPdf 组件。
static void Main(string[] args)
{
var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "da.pdf");
var theDoc = new Doc();
//theDoc.Read(filePath);
// apply a rotation transform
theDoc.MediaBox.String = "Legal";
double w = theDoc.MediaBox.Width;
double h = theDoc.MediaBox.Height;
double l = theDoc.MediaBox.Left;
double b = theDoc.MediaBox.Bottom;
theDoc.Transform.Rotate(90, l, b);
theDoc.Transform.Translate(w, 0);
// rotate our rectangle
theDoc.Rect.Width = h;
theDoc.Rect.Height = w;
// add some text
theDoc.Rect.Inset(50, 50);
theDoc.FontSize = 96;
theDoc.AddText("Landscape Orientation");
theDoc.AddPage();
theDoc.PageNumber = theDoc.PageCount;
theDoc.AddText("Page 2");
// adjust the default rotation and save
int theID = theDoc.GetInfoInt(theDoc.Root, "Pages");
theDoc.SetInfo(theID, "/Rotate", "90");
theDoc.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "out.pdf"));
theDoc.Clear();
}
我想打开一个现有的 PDF 并使用 ABCPdf 将特定页面的方向更改为横向,而不是创建新的 pdf。比如第一页是纵向的,第二页是横向的。
谢谢
【问题讨论】: