Jay Blanton wrote:
I have read a few responses about using PDFStamper to modify a pre-existing PDF.

I have a few questions. We currently funnel pdfs to a printer that uses tick marks to determine when a document ends and needs to be folded for mailing, therefore notifying the printer of when the next document begins. Can iText read a pre-existing pdf and be able to inform me how many pages exist in the document, what is the current page, and when it's on the last page? Also, is it possible to put a tick mark in the margin of a page from a pre-existing pdf?

Tick marks,
are those the little lines that mark where you can fold a letter?

I don't know if this answers your question, but here is some code:

// PdfReader reads an existing PDF
PdfReader reader = new PdfReader("HelloWorld.pdf");
// PdfStamper writes a new PDF based on the existing one
PdfStamper stamper = new PdfStamper(reader,
  new FileOutputStream("HelloWorldStamped.pdf"));
// PdfContentByte is a canvas we can paint on
PdfContentByte canvas;
// reader.getNumberOfPages() tells you the number of pages
int total = reader.getNumberOfPages();
for (int i = 1; i <= total; i++) {
  // getOverContent grabs the canvas of a page
  canvas = stamper.getOverContent(i);
  canvas.setLineWidth(2f);
  // with moveTo and lineTo you can add tick marks
  canvas.moveTo(0f, 500f);
  canvas.lineTo(30f, 50f);
  // don't forget this line or nothing will be added
  canvas.stroke();              
}

Remark: getOverContent allows you to add content on top
of the existing content; getUnderContent draws stuff under
the existing content (for instance a watermark)

br,
Bruno.


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to