英文:
Setting bleed and slug for pdf document using itext
问题
我正在使用Java中的iText版本2.0.3,并且我尝试为我输出的PDF文档设置出血(Bleed)和裁剪标记(Slug)设置。我想要做的是从用户那里获取8个输入(4个用于出血,4个用于裁剪),即上、下、左和右(对于出血和裁剪都是如此),然后一旦我将所有内容从pdfWriter写入pdfDocument,就在文档周围设置这个出血框和裁剪框。但是我在iText 2.0.3甚至最新版本的文档中都找不到相关内容。
以下是您请求的代码部分:
doc是我从用户那里获取的结构,其中包含了所有相关信息,包括以毫米为单位的出血和修剪(trim)值。对于修剪,也将有四个值,就像出血一样。
pdfDocument = new com.lowagie.text.Document();
pdfWriter = PdfWriter.getInstance(pdfDocument, new FileOutputStream(outputFile));
pdfWriter.setPDFXConformance(pdfXConformance);
pdfDocument.addTitle(doc.getTitle() == null ? "" : doc.getTitle());
pdfDocument.addSubject(doc.getSubject() == null ? "" : doc.getSubject());
pdfDocument.addKeywords(doc.getKeywords() == null ? "" : doc.getKeywords());
pdfDocument.addAuthor(doc.getAuthor() == null ? "" : doc.getAuthor());
pdfDocument.addCreator("some name");
pdfDocument.addProducer();
pdfDocument.addCreationDate();
setPageViewAndStartPageProperty(doc);
pdfWriter.setLinearPageMode();
double bleedTop = doc.getIsBleedAndSlug() ? doc.getBleedTop() : 0;
double bleedBottom = doc.getIsBleedAndSlug() ? doc.getBleedBottom() : 0;
double bleedLeft = doc.getIsBleedAndSlug() ? doc.getBleedLeft() : 0;
double bleedRight = doc.getIsBleedAndSlug() ? doc.getBleedRight() : 0;
//关于下面这些行,我不确定结构应该是什么样的
pdfWriter.setBoxSize("bleed", new Rectangle(x, w, y, z));
pdfWriter.setBoxSize("trim", new Rectangle(x1, w1, y1, z1));
所以我想要从出血的上、下、左和右获取x、w、y和z坐标,以便我可以正确应用它们。
英文:
i am using itext version 2.0.3 in java, and I am trying to set Bleed and Slug settings for the pdf document that I output. so what I want to do is, take 8 inputs from user(4 for bleed and 4 for slug), namely top,bottom,left and right(both for bleed and slug), and then once I write everything from the pdfWriter to the pdfDocument, set this bleed box and and slug box around the document. but i could not find any documentation for such in itext 2.0.3 and also in the recent version.
here is the below code as requested.
doc is the structure that i get from user that contains all the relavent information including bleed and trim values in mm. for trim also there will be four values just like bleed
`pdfDocument = new com.lowagie.text.Document();
pdfWriter = PdfWriter.getInstance(pdfDocument, new
FileOutputStream(outputFile));
pdfWriter.setPDFXConformance(pdfXConformance);
pdfDocument.addTitle(doc.getTitle() == null ? "" : doc.getTitle());
pdfDocument.addSubject(doc.getSubject() == null ? "" :
doc.getSubject());
pdfDocument.addKeywords(doc.getKeywords() == null ? "" :
doc.getKeywords());
pdfDocument.addAuthor(doc.getAuthor() == null ? "" : doc.getAuthor());
pdfDocument.addCreator("some name");
pdfDocument.addProducer();
pdfDocument.addCreationDate();
setPageViewAndStartPageProperty(doc);
pdfWriter.setLinearPageMode();
double bleedTop = doc.getIsBleedAndSlug() ? doc.getBleedTop() : 0;
double bleedBottom = doc.getIsBleedAndSlug() ? doc.getBleedBottom() : 0;
double bleedLeft = doc.getIsBleedAndSlug() ? doc.getBleedLeft() : 0;
double bleedRight = doc.getIsBleedAndSlug() ? doc.getBleedRight() : 0;
//not sure about the below lines like what the structure should be
pdfWriter.setBoxSize("bleed",new Rectangle(x,w,y,z));
pdfWriter.setBoxSize("trim",new Rectangle(x1,w1,y1,z1));`
so i want the x,w,y, and z coordinates from the bleedTop,left,bottom and right so as i can apply it properly.
专注分享java语言的经验与见解,让所有开发者获益!
评论