我有一個模板PDF文件,內嵌了一個PDF表單域。我使用PdfStamper填充這些域。另外,我希望能夠更改生成PDF的邊距。有什麼方法可以修改加蓋的PDF頁面頁邊距嗎?使用iTextSharp設置頁邊距
12
A
回答
13
我知道的唯一方法就是這樣。
iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(pageWidth, pageHeight);
Document doc = new Document(rec);
doc.SetMargins(0f, 0f, 0f, 0f);
然而,這將限制利潤率也
+2
非常感謝!這是一個令人討厭的問題。也可能要注意pageWidth和pageHeight是以像素爲單位的。我使用了612 x 792(72dpi)來獲得常規頁面大小。 – James 2013-01-07 22:57:06
16
你可以做到這一切在同一行。
Document doc = new Document(PageSize.LETTER, 0f, 0f, 0f, 0f);
-1
setMaring Impelemented作爲
public override bool SetMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
{
if ((this.writer != null) && this.writer.IsPaused())
{
return false;
}
this.nextMarginLeft = marginLeft;
this.nextMarginRight = marginRight;
this.nextMarginTop = marginTop;
this.nextMarginBottom = marginBottom;
return true;
}
申請下頁邊距爲此。 解決這個問題打開pdfDocument後調用newPage() 這個解決方案爲空pdf文檔工作。
using (FileStream msReport = new FileStream(pdfPath, FileMode.Create))
{
using (Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 10f))
{
try
{
//open the stream
pdfDoc.Open();
pdfDoc.setMargin(20f, 20f, 20f, 20f);
pdfDoc.NewPage();
pdfDoc.Close();
}
catch (Exception ex)
{
//handle exception
}
finally
{
}
}
}
相關問題
- 1. 如何使用NReco.PdfGenerator設置頁邊距?
- 2. 設置打印頁邊距
- 3. 如何使用iTextsharp更改PDF中第二頁的頁邊距?
- 4. itextsharp添加頁眉和頁腳,顯示在頁邊距內頁邊距之外。
- 5. 用於設置頁邊距的TCPDF
- 6. 頁面特定頁邊距設置AR3
- 7. 設置文章標籤內頁邊距影響版塊邊距
- 8. CSS無法設置頁邊距底部
- 9. matplotlib - 全局設置頁邊距
- 10. 在Rave Reports中設置頁邊距
- 11. 打印多頁邊距未設置
- 12. 如何設置PDF頁邊距?
- 13. 設置iTextSharp中圖像網格之間的邊距或單元格間距PdfPTable
- 14. 如何使用apache poi爲word文檔設置頁邊距?
- 15. 如何使用EPPlus設置Excel頁邊距
- 16. 無法使用var設置頁邊距:JavaScript,CSS和jQuery
- 17. 在ImageView上設置邊距
- 18. 邊距設置爲TextView的
- 19. Typo3記錄間距/邊距設置
- 20. 添加頁腳以打印網頁並設置頁邊距
- 21. 使用邊距設置跨度間的距離
- 22. 顏色和邊框設置在itextsharp
- 23. 爲TextView設置邊距使其消失
- 24. 如何在TabLayout的每一邊設置頁邊距
- 25. 如何設置統一邊框邊距?
- 26. Java Swing - 使用線邊框在TextArea上設置邊距
- 27. 如何在pdf中使用itextsharp設置邊框顏色
- 28. 使用腳本或Automator在文本編輯文件上自動設置頁面設置,頁邊距和換頁
- 29. iTextSharp忽略新創建的PDF中的頁邊距
- 30. wkhtmltopdf - 如何設置頁眉的頁邊距?
您是否需要保留與您的PDF模板**相同的**現有頁面尺寸,或者是否可以創建頁面尺寸稍大/更小的新文檔? – kuujinbo 2012-02-19 08:49:52