如何设置PDF的边距和方向 [英] How can set margin and orientation to PDF

查看:803
本文介绍了如何设置PDF的边距和方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Aspose Word库将DOC文件转换为PDF。如何设置输出pdf文件的边距和方向。



我的代码如下。



 Aspose.Words.Document doc =  new  Aspose.Words.Document(  c:\\test\\test.doc); 
doc.Save( c:\\test\\test.pdf);

解决方案

在下面试试

 Aspose.Words。文档doc =  new  Aspose.Words.Document(  c :\\test\\test.doc); 
foreach (第sec节 doc.Sections)
{
PageSetup ps = sec.PageSetup;
// 1英寸等于72点
ps.TopMargin = 1 4 * 72 ;
ps.RightMargin = 2 5 * 72 ;
ps.BottomMargin = 1 3 * 72 ;
ps.LeftMargin = 3 3 * 72 ;
ps.Orientation = PageOrientationType.Portrait;
}
doc.Save( c:\\test\\ test .PDF);


I try to convert DOC file in to PDF by using Aspose Word library. How can i set margin and orientation to the output pdf file.

My code given below.

Aspose.Words.Document doc = new Aspose.Words.Document("c:\\test\\test.doc");
doc.Save("c:\\test\\test.pdf");

解决方案

try below

Aspose.Words.Document doc = new Aspose.Words.Document("c:\\test\\test.doc");
foreach (Section sec in doc.Sections)
{
    PageSetup ps = sec.PageSetup;
    // 1 inch equals 72 points
    ps.TopMargin = 1.4 * 72;
    ps.RightMargin = 2.5 * 72;
    ps.BottomMargin = 1.3 * 72;
    ps.LeftMargin = 3.3 * 72;
    ps.Orientation = PageOrientationType.Portrait;
}
doc.Save("c:\\test\\test.pdf");


这篇关于如何设置PDF的边距和方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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