2013-03-01 103 views
0

我使用itextsharp预定义页面大小填充了下拉列表。
我需要选定的页面尺寸传递到:无法投射'System.String'类型的对象来键入'iTextSharp.text.Rectangle'

pdfDoc = new Document(dropdownlist.selectedvalue, 50, 50, 50, 50); 

我得到错误

无法转换类型 'System.String' 输入 “iTextSharp.text的对象。矩形“

我该如何传递代表最常见纸张大小的矩形对象,并从下拉菜单中选择

如何将字符串投射到iTextSharp.text.Rectangle

在此先感谢

回答

1

不能一个StringiTextSharp.text.Rectangle,因为它们是完全不同的班级,没有隐含的翻译。

但有一个实用工具类PageSize您可能感兴趣的

namespace iTextSharp.text { 
    /// <summary> 
    /// The PageSize-object contains a number of read only rectangles representing the most common paper sizes. 
    /// </summary> 
    /// <seealso cref="T:iTextSharp.text.RectangleReadOnly"/> 
    public class PageSize { 
     [...] 
     /** 
     * This method returns a Rectangle based on a String. 
     * Possible values are the the names of a constant in this class 
     * (for instance "A4", "LETTER",...) or a value like "595 842" 
     */ 
     public static Rectangle GetRectangle(String name) { 
      [...] 
     } 
    } 
} 

您可以尝试使用此方法来检索RectangleString

相关问题