0

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. 
  • The PDF standard does not know a slug box, only media, crop, bleed, trim, and art, see [this answer](https://stackoverflow.com/a/13240546/1729265). – mkl Jul 27 '20 at 20:46
  • yes. in that case, i am looking for bleedbox and trimbox settings. yet i still dont know how to achieve this in itext 2.0.3 – Durgaram Borkar Jul 28 '20 at 04:29
  • Both iText 5 and OpenPdf have a `PdfWriter.setBoxSize` method, so chances are that there already was this method in iText 2.1.7. You may want to check whether it's already in 2.0.3. – mkl Jul 28 '20 at 11:13
  • hello @mkl thank you for your answer, I have checked, and yes, 2.0.3 supports `PdfWriter.setBoxSize`. but one thing i did not understand though is, are those bleed marks applied throughout the page, like i can only see the marks at the bottom left in acrobat print view. as i want to apply those on the top,bottom,left and right too. – Durgaram Borkar Jul 29 '20 at 04:35
  • Setting XXX box coordinates merely stores coordinates for those boxes in the PDF, it does not add any content. If you want to have some marks drawn at those coordinates, you have to draw them. – mkl Jul 29 '20 at 08:40
  • hello @mkl thank you for your answer. merely storing those coordinates as in,if I set the bleedbox and trimbox, then will it print the document accordinly with those settings? or drawing the content is requierd? if yes then what are the functions that i can use to do so? – Durgaram Borkar Jul 30 '20 at 15:21
  • It essentially is the job of the printer to properly use the box information for the task at hand. – mkl Jul 30 '20 at 18:01
  • yes @mkl thank you for the answer. now i am able to add bleed and trims to the document. but i also want to draw these boxes onto the document so that i an see the outlines. how do i do that? – Durgaram Borkar Aug 04 '20 at 14:41
  • **a** Please update your question accordingly, there is an [edit] link underneath. **b** I could show how to draw boxes with iText 5.5.x, and I'm pretty sure the code (with different `imports`) will also work with iText 2.1.7. I cannot tell, though, how different the situation is with iText 2.0.3. – mkl Aug 05 '20 at 08:38
  • hello @mkl thank you for your answer. i have added the code above. so i get this 4 bleed values in mm(millimeters)(bleedtop,left,right and bottom), and i would wish to apply those to the whole document. thank you – Durgaram Borkar Aug 05 '20 at 19:56

0 Answers0