自定义页面大小在PDFBox中如何实现?

huangapple go评论64阅读模式
英文:

custom page size in pdfbox?

问题

在pdfbox中是否有一种方法可以设置自定义页面大小,例如6英寸x 8英寸。这是跑步者赛事胸卡的尺寸。目前似乎只有以下几种可用尺寸:

 ReportPageSize pageSize = ReportPageSize.AVERY_5160;
 PdfDocInfo doc = new PdfDocInfo(pageSize)

自定义页面大小在PDFBox中如何实现?

非常感谢任何见解。

英文:

In pdfbox is there a way to set a custom page size for example 6" x 8". This is the size of runner bib card. The only sizes that seem to be available are the following:

 ReportPageSize pageSize = ReportPageSize.AVERY_5160;
 PdfDocInfo doc = new PdfDocInfo(pageSize)

自定义页面大小在PDFBox中如何实现?

I appreciate any insights.

答案1

得分: 2

创建页面时传递一个MediaBox:

private static final float POINTS_PER_INCH = 72;

PDPage page = new PDPage(
    new PDRectangle(6 * POINTS_PER_INCH, 8 * POINTS_PER_INCH));

“PdfDocInfo”不是来自PDFBox。

英文:

pass a mediabox when creating your page:

private static final float POINTS_PER_INCH = 72;

PDPage page = new PDPage(
    new PDRectangle(6 * POINTS_PER_INCH, 8 * POINTS_PER_INCH));

"PdfDocInfo" is not from PDFBox.

huangapple
  • 本文由 发表于 2020年10月1日 12:33:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/64149115.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定