Julien T wrote:
> the number of page is not constant (so i use reader.getNumberOfPages() )
OK, I didn't expect the number of pages to be a constant.
> I read my XML file getting info of the first page, then I want to insert OMR
> and read info about page two ... ect ...
> (only open one time my XML and my PDF files to gain time)
OK.
So on one side you are fed data from an XML file on
a page per page basis; on the other side you have a
PdfReader instance. So far so good.
> each OMR as some properties : (OMR is are little lines you can see on the
> right of some of your mails)
> Coordinates ( X and Y )
> Height , Width, Thick, Interline
> and finally Orientation ... (the position in the page it just modify X
> and/or Y)
Aha, I know that OMR stood for "Optical Mark Recoginition,"
but I didn't know what these marks were like in your context.
If I understand well, we are talking about lines from coordinate
(x1, y1) to (x2, y2) (coordinates that are known to you).
The height of the line can be calculated from these coordinates,
so that's redundant information. The thickness is important.
I don't know what is meant with "interline", do you mean line
styles such as single line, double line, dash patterns (dots,
intervals,...)? Orientation seems to be irrelevant too, as
you have the coordinates; or maybe you have 1 coordinate (x1, y1)
and a height + orientation that allows you to calculate (x2, y2).
> I already made a method to modify the coordinates for the orientations,
> calculate the next insertion...
OK, I don't if we're talking about the same thing, but
let's suppose we are.
> PDF Files i have to open are ... big ... (1000 pages)
That doesn't matter. Use PdfReader with a RandomAccessFileOrArray
and "free" the reader once in a while if memory is a problem.
Normally iText doesn't have problems with large files.
> so i'm looking for a quick method ...
>
> I don't know what is the faster ... Inserting image ? drawing a vector ?
The quickest way is to use PdfStamper and getDirectContent;
then draw the lines with moveTo and lineTo.
PdfStamper stamp =
new PdfStamper(reader, new FileOutputStream("new.pdf"));
PdfContentByte content;
// SOME FOR LOOP DEPENDING ON YOUR XML FILE
while (morePagesDefinedInXml) {
content = stamp.getOverContent(xml.getPagenumber());
content.saveState();
// define thickness, color, dash pattern,... for instance:
content.setLineWidth(xml.getThickness());
// now construct the path for the line:
content.moveTo(xml.getX1(), xml.getY1());
content.lineTo(xml.getX2(), xml.getY2());
// you may want to repeat this if you have to paint
// more lines on the same page.
// now stroke all the paths you constructed
content.stroke();
content.restoreState();
}
stamp.close()
> sorry for my english,
> it's not really easy to explain my problem, 'cause i see my code
Shouldn't it be easier to explain if you see your code?
Are you sure you already have iText code?
It's not easy to explain what you should do because your
"needs" seem so trivial at first sight. You say "I already
have some difficulties" but you don't tell us anything about
the nature of the problems: is it a memory problem?
You talk about a big file, but... a document with 1000 pages
isn't big; I've made a document with 28,000 pages a few weeks ago.
Documents with 100000 pages are no exception in the iText world.
Maybe your problem is that you don't know which iText methods
to use, in that case don't look at us, look at the book or
the tutorial, for instance:
http://itextdocs.lowagie.com/tutorial/directcontent/graphics/
Note that I have no idea why you are mentioning images.
Do you need to add images to the file? Because that was
your original question, but from your more recent mails
I don't understand why you'd need images.
br,
Bruno
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar