我使用itextsharp生成pdf。生成的pdf默认为垂直。 (a4 - 垂直)。? [英] I am using itextsharp for generating a pdf . the pdf that is generated is by default vertical. (a4 - vertical).?

查看:383
本文介绍了我使用itextsharp生成pdf。生成的pdf默认为垂直。 (a4 - 垂直)。?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望它生成为水平。我需要做哪些更改?

代码如下:



  using (FileStream fs =  new  FileStream(appRootDir + fileName,FileMode.Create,FileAccess.Write,FileShare.None))
// 第2步:创建iTextSharp.text.Document对象


使用(文档doc = new 文档(PageSize.A4))
< span class =code-comment> // 步骤3:创建iTextSharp.text.pdf.PdfWriter对象
// 将文档写入指定的FileStream

使用(PdfWriter writer = PdfWriter.GetInstance(doc,fs))
{
doc.AddTitle( 示例);
doc.AddSubject( 这是Book'iText in Action'第1章的示例4 /跨度>);
doc.AddKeywords( 元数据,iTextSharp 5.4.4,第1章,教程) ;
doc.AddCreator( iTextSharp 5.4.4);
doc.AddAuthor( RGU);
doc.AddHeader( Nothing No Header);


doc.Open();











请帮帮我

提前致谢



我尝试过的事情:



我希望它生成为水平。我需要做哪些更改?

解决方案

我认为正确的术语是纵向(不是垂直)和横向(不是水平) - 如果你有更好的运气搜索,你使用了正确的条款



你需要走这条线: -



 使用(文档doc =  new 文档(PageSize.A4))





并将其设为: -



 < span class =code-keyword>使用(文档doc =  new 文档(PageSize.A4.Rotate()))


I want it to be generated as Horizontal. What changes do I need to do?
the code is given below

using (FileStream fs = new FileStream(appRootDir + fileName, FileMode.Create, FileAccess.Write, FileShare.None))
               // Step 2: Creating iTextSharp.text.Document object


               using (Document doc = new Document(PageSize.A4))
               // Step 3: Creating iTextSharp.text.pdf.PdfWriter object
               // It helps to write the Document to the Specified FileStream

               using (PdfWriter writer = PdfWriter.GetInstance(doc, fs))
               {
                   doc.AddTitle("Example");
                   doc.AddSubject("This is an Example 4 of Chapter 1 of Book 'iText in Action'");
                   doc.AddKeywords("Metadata, iTextSharp 5.4.4, Chapter 1, Tutorial");
                   doc.AddCreator("iTextSharp 5.4.4");
                   doc.AddAuthor("RGU");
                   doc.AddHeader("Nothing", "No Header");


                   doc.Open();






pls help me
Thanks in advance

What I have tried:

I want it to be generated as Horizontal. What changes do I need to do?

解决方案

I believe the correct terminology is portrait (not vertical) and landscape (not horizontal) - you would have better luck searching if you'd used the correct terms

you need to take this line :-

using (Document doc = new Document(PageSize.A4))



and make it this :-

using (Document doc = new Document(PageSize.A4.Rotate()))


这篇关于我使用itextsharp生成pdf。生成的pdf默认为垂直。 (a4 - 垂直)。?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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