我試圖讓我的pdf文檔從(0,0)開始,但是似乎文檔對象有一個默認的頂部邊距,我不能設置爲0. 有沒有辦法做到這一點?如何使用itextsharp刪除PDF文檔的默認頂部邊距?
我的代碼如下所示
using (MemoryStream memoria = new MemoryStream())
{
Document pdf = new Document(new Rectangle(288, 144));
try
{
PdfWriter writer = PdfWriter.GetInstance(pdf, memoria);
pdf.Open();
pdf.SetMargins(0, 0, 0, 0);
PdfPTable tPrincipal = new PdfPTable(2);
tPrincipal .WidthPercentage = 100;
tPrincipal .DefaultCell.Border = 0;
tPrincipal .TotalWidth = 288f;
tPrincipal .LockedWidth = true;
....
我只是不容到達設置上邊距爲0。只是不約我的設置(0護理, 0,0,0)並留下頂部邊距(大約50f)。
非常感謝傑伊,但是我必須在所有ceros之後加入「f」。文檔pdf =新文檔(新的矩形(288f,144f),0f,0f,0f,0f); – Lilian 2010-10-12 13:55:13
@Lilian,他們期待着漂浮點。 – 2011-03-23 01:24:32
並且在使用0時沒有錯誤,它只是放入默認邊距。 0f一路! – TChadwick 2012-10-18 19:13:58