|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
| < Prev | 1 - 2 | Next > |
|
|
Generation of Multiple Page PDF Document is slowHello all,
I am generating a multiple page report using itext. each page of this report is based on a Acroform. My users want this generation to be faster. I am detailing down the steps taken by me. Kindly let me know if the report generation can be faster.
this is done for all students, and then I convert the documents to byte array and write in on the HTTP Response stream.
Can I improve this by following any other way of generating this report?
regards,
Abhishek.
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slowAbhishek Srivastava wrote:
> Can I improve this by following any other way of generating this report? > Yes, you can. I am doing the same thing for Ghent University. We have 27.000 students and the document generation is very fast. Give me some time to distill a code sample from our closed source. One major error you made, was using PdfCopyFields. br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slowAs promised, this is the procedure I use to create a 27.000+ page document
really fast using an existing 1-page PDF document with a form. My class Letter extends PdfPageEventHelper. In the onOpenDocument method 1. I read the existing PDF and retrieve the fields and their coordinates I store these coordinates for later use. 2. I read the page into a PdfImportedPage and store this page in a member variable 'page' In the onStartPage method, I do: writer.getDirectContent().addTemplate(page, 0, 0); In the main method, I go through the 5 steps of document creation: 1. Document document = new Document(); (in your case, it would probably be a good idea to retrieve the page size from the original PDF) 2. PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("new.pdf")); Letter letter = new Letter(); writer.setPageEvent(letter); 3. document.open(); 4. I add content I loop over all the records in my database and I add it to the PDF using ColumnText the coordinates used in the ColumnText objects, are the ones retrieved in the onOpenDocument method. After each record, I do document.newPage(); I don't worry about the 'template', the imported page is added automatically in the page event. 5. document.close(); There are other ways to do it, and the book will give you another example using setField and setFieldCache, but the procedure described above is faster because it cuts a lot of corners. best regards, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slowThanks Bruno,
could you clarify the following lines in your code snipped
Letter letter = new Letter();
writer.setPageEvent(letter); what is letter over here?
regards,
Abhishek.
On 8/4/06, bruno <bruno@...> wrote:
As promised, this is the procedure I use to create a 27.000+ page document ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slowAbhishek Srivastava wrote:
> Thanks Bruno, > > could you clarify the following lines in your code snipped > > Letter letter = new Letter(); > writer.setPageEvent(letter); > > what is letter over here? Letter is the name of my main class. It extends PdfPageEventHelper. That's why it is instantiated and set as PageEvent for the writer. It is used to take one standard letter (an existing PDF) and to create a 27.000 page PDF where each page contains the same letter, but with a different name/address. We ship this PDF to our printing office and they make sure the letter is sent to the students. br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slow
PdfReader reader = new PdfReader
("existing.pdf");
Document doc = new Document();
PdfWriter writer = PdfWriter.getInstance(doc, new
FileOutputStream("target.pdf"));
PdfImportedPage page = writer.getImportedPage(reader, 1);
throws a null pointer exception at me.
here i can see that reader is not null (so existing.pdf was read correctly).
regards,
Abhishek.
is this the correct way of getting a PdfImportedPage?
On 8/4/06, bruno <bruno@...> wrote:
Abhishek Srivastava wrote: ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowWhere's doc.open()?
Paulo ----- Original Message ----- From: "Abhishek Srivastava" <abhishes@...> To: "Post all your questions about iText here" <itext-questions@...> Sent: Friday, August 04, 2006 2:08 PM Subject: Re: [iText-questions] Generation of Multiple Page PDF Document isslow > PdfReader reader = new PdfReader("existing.pdf"); > > Document doc = new Document(); > > PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(" > target.pdf")); > > PdfImportedPage page = writer.getImportedPage(reader, 1); > throws a null pointer exception at me. > > here i can see that reader is not null (so existing.pdf was read > correctly). > > regards, > Abhishek. > > is this the correct way of getting a PdfImportedPage? > > On 8/4/06, bruno <bruno@...> wrote: >> >> Abhishek Srivastava wrote: >> >> > Thanks Bruno, >> > >> > could you clarify the following lines in your code snipped >> > >> > Letter letter = new Letter(); >> > writer.setPageEvent(letter); >> > >> > what is letter over here? >> >> Letter is the name of my main class. >> It extends PdfPageEventHelper. >> That's why it is instantiated and set as PageEvent for the writer. >> >> It is used to take one standard letter (an existing PDF) >> and to create a 27.000 page PDF where each page >> contains the same letter, but with a different name/address. >> We ship this PDF to our printing office and they make sure >> the letter is sent to the students. >> br, >> Bruno >> >> ------------------------------------------------------------------------- >> Take Surveys. Earn Cash. Influence the Future of IT >> Join SourceForge.net's Techsay panel and you'll get the chance to share >> your >> opinions on IT & business topics through brief surveys -- and earn cash >> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >> _______________________________________________ >> iText-questions mailing list >> iText-questions@... >> https://lists.sourceforge.net/lists/listinfo/itext-questions >> > -------------------------------------------------------------------------------- > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV -------------------------------------------------------------------------------- > _______________________________________________ > iText-questions mailing list > iText-questions@... > https://lists.sourceforge.net/lists/listinfo/itext-questions > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Modify ContentHi,
Maybe this is a stupid question. we know we cannot modify the content of an existing PDF file, but using iText we can add more into the PDF file. My question is: if I use iText to add an image or an paragraph into an existing PDF file, can I delete the image or the paragraph later with iText? My thought is: because the image was added into a PDF file by myself, I know exactly where I put there and all the other infomation about the image, so is those enough to enable me to delete the image later with iText? Thanks! Zhi __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Modify ContentAt 01:19 PM 8/4/2006, Zhi Ren wrote:
>Maybe this is a stupid question. we know we cannot >modify the content of an existing PDF file, You can - but not with iText. >My question >is: if I use iText to add an image or an paragraph >into an existing PDF file, can I delete the image or >the paragraph later with iText? Again, not with iText. iText doesn't support READ access to content ONLY WRITE. >My thought is: because >the image was added into a PDF file by myself, I know >exactly where I put there and all the other infomation >about the image, You do?? You know what PDF object ID it is? You know where it is in the content stream? >so is those enough to enable me to delete the image later with iText? Yes, if you want to do some work... Leonard --------------------------------------------------------------------------- Leonard Rosenthol <mailto:leonardr@...> Chief Technical Officer <http://www.pdfsages.com> PDF Sages, Inc. 215-938-7080 (voice) 215-938-0880 (fax) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
|
|
|
Re: Modify Content-----Original Message----- From: itext-questions-bounces@... [mailto:itext-questions-bounces@...] On Behalf Of Mark Storer Sent: Saturday, 5 August 2006 4:36 AM To: Post all your questions about iText here Subject: Re: [iText-questions] Modify Content > because > the image was added into a PDF file by myself, I know > exactly where I put there and all the other infomation > about the image, so is those enough to enable me to > delete the image later with iText? If you're feeling a bit brave, yes... or if your PDF-Fu is Mighty. But if that were the case, you wouldn't need to ask. Read on Brave One. ... Thank you Mark That was a truly informative and invigorating lesson. Can't wait 'til you move on to "Nei PDF Gung" and "PDF Chi". Cheers AlanK ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowThanks Paulo,
I am able to generate my document now.
Just one question.
The document which I use as template is landscape.
When I generate my document I also create it as Landscape. However the template document appears vertical in my page.
I have tried setting the Rectangle of the ImportedPage to the size of a Rotated A4 page but it still has imported the template correctly.
In short both my source and target documents have landscape A4 pages.
regards,
Abhishek.
On 8/4/06, Paulo Soares <psoares@...> wrote:
Where's doc.open()? ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowAbhishek Srivastava wrote:
> The document which I use as template is landscape. > > When I generate my document I also create it as Landscape. However the > template document appears vertical in my page. > > I have tried setting the Rectangle of the ImportedPage to the size of > a Rotated A4 page but it still has imported the template correctly. > > In short both my source and target documents have landscape A4 pages. There are different ways to solve this. There is an addTemplate method that allows you to define the rotation (using a transformation matrix). Or you could wrap the PdfImportedPage inside a com.lowagie.text.Image object, rotate the image and add it with addImage. br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslow> There are different ways to solve this
Which will be the most efficient?
regards,
Abhishek.
On 8/7/06, bruno <bruno@...> wrote:
Abhishek Srivastava wrote: ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowAbhishek Srivastava wrote:
> > There are different ways to solve this > > Which will be the most efficient? "One answer solves all" doesn't apply here. First I thought of answering that the addTemplate with the transformation coordinates would be the best way to go, but then you need to do some extra calculations. That's no problem if the original PDF always has the same dimensions, but if you have to support any template PDF (with any possible page format and orientation), it could be more interesting to use the Image approach (maintenance will be easier) br, Bruno ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowHello Bruno,
I tried the following to rotate the template by 90 degrees.
writer.DirectContent.addTemplate(_page, 0, 1, -1, 0, PageSize.A4.height(), 0); Now I get an inverted Imported page. (upside down). If I try any other permutation combinarion I get a blank pdf. (for example:
Could you please give me what parameters should I use for a, b, c, d, e, f so that my vertical template rotates 90 degrees.
I don't want any scaling. and my source document is always of the same size (A4, landscape).
reagards,
Abhishek Srivastava wrote: ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowThanks Bruno,
The image approach works for me.
However I want to compare it to the addTemplate apporach.
if a co-ordinate is X1, Y1 in portait, then it becomes Y1, PageSize.A4.Width - X1 when the page becomes landscape.
Given the above, what transformation matrix should be applied? so that the template is added correctly?
regards,
------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowAbhishek Srivastava wrote:
> Thanks Bruno, > > The image approach works for me. > > However I want to compare it to the addTemplate apporach. > > if a co-ordinate is X1, Y1 in portait, then it becomes Y1, > PageSize.A4.Width - X1 when the page becomes landscape. > > Given the above, what transformation matrix should be applied? so that > the template is added correctly? The problem you had is that the template is rotated outside the page. I don't have the time to look it up right now, but it is just a matter of applying some high school algebra. You can find the formulas here: http://itextdocs.lowagie.com/tutorial/directcontent/coordinates/index.html#transform br, Bruno ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document isslowI will get the matrix approach to work.
I have made good progress with the image approach, I am able to write data using ColumnText but I am facing a problem in Fonts. my acrofields have fonts, and font style specified on them.
when I write text using ColumnText I should use the same Font and style. I am not able to extract the Font information from the Acrofield. Here is what I have done so far
foreach (PdfDictionary dict in item.merged) Console.WriteLine(stream.GetType().Name); foreach (PdfName o in stream.Keys) but the above code does not work and it throws a null pointer exception.
regards,
Abhishek.
On 8/8/06, bruno <bruno@...> wrote:
Abhishek Srivastava wrote: ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ iText-questions mailing list iText-questions@... https://lists.sourceforge.net/lists/listinfo/itext-questions |
|
|
Re: Generation of Multiple Page PDF Document is slowHi Bruno,
As you said in the previous thread (Abhishek's): "There are other ways to do it, and the book will give you another example using setField and setFieldCache, but the procedure described above is faster because it cuts a lot of corners. best regards, Bruno" I am exactly doing the same, I followed all your steps. Can you suggest me how to use setField and setFieldCache for setting AcroForm fields over multiple pages. If you can give me an example code, that will be great for me. Thanks in advance, Ganesh.
|
| < Prev | 1 - 2 | Next > |
| Free embeddable forum powered by Nabble | Forum Help |