Re: [iText-questions] Section/Chapters and memory

2007-12-02 Thread Bruno Lowagie

Kris Raney wrote:

I still think it's a good idea to
make memory-friendly Section and Chapter helpers available


I've thought about this problem, and I decided not
to look at the extensions you've written. Instead
I introduced a new Interface:

LargeElement extends Element

Currently three classes are implementing the LargeElement
interface: Section (and Chapter), PdfPTable and Table.

I have done some simple tests with PDF files that look OK,
but this functionality should be tested more thoroughly.

In pseudocode this is what you can do:

LargeElement e = new LargeElementImp();
e.setCompleted(false);
e.add(a lot of content);
do while there's still content {
document.add(e);
e.add(a lot of content);
}
e.setCompleted(true);
document.add(e);

After a large object has been added to all the listeners
of the Document, the Document will check if the large object
was completed. If not, it will flush all the content that
was already added.
There are some caveats: with tables, you risk deleting
partially filled rows, so be careful!
With Chapter/Section: if you have a Section of a Chapter
that hasn't been completed yet, you have to mark it with
setCompleted(false); otherwise it will be removed from
the Chapter object, and an IllegalStateException will be
thrown if you try to add more content to that Section.

Now that I think of it: I might change the methods
setCompleted and isCompleted into setComplete and
isComplete.
br,
Bruno


smime.p7s
Description: S/MIME Cryptographic Signature
-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Problem with dot after chapter / section numbers

2007-12-02 Thread Friedhelm




Hi Bruno,

thank you very much. I will have a look at it asap.

- Friedhelm -

Bruno Lowagie schrieb:
Friedhelm
wrote:
  
  Is there a way to avoid the last dot behind
the number?

  
  
In the SVN repository, I've introduced the concept 'numberStyle'.
  
Currently two styles are supported:
  
NUMBERSTYLE_DOTTED (the default): 1.2.3.
  
NUMBERSTYPE_DOTTED_WITHOUT_FINAL_DOT: 1.2.3
  
Maybe other people can think of other styles ;-)
  
The change will be in iText 2.0.8
  
br,
  
Bruno
  
  

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
  

___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/
  





-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Section/Chapters and memory

2007-12-02 Thread Bruno Lowagie

Hello all,
in attachment you can find a standalone example with a series
of tests. This code will only work with the iText version in
the SVN repository.
Six PDF files are generated:
2 with Chapters/Sections
2 with a PdfPTable
2 with a Tabe
Of each pair, one was generated 'the traditional way';
the other using the new memory management functionality
introduced with the LargeElement interface.
The output of both methods should be indentical, but
the difference in memory usage is huge!
Note that this functionality probably needs more testing.
br,
Bruno
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;

import com.lowagie.text.Chapter;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Font;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Section;
import com.lowagie.text.Table;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;

public class MemoryTests {

private boolean test;
private long memory_use;
private long initial_memory_use = 0l;
private long maximum_memory_use = 0l;
OutputStreamWriter writer = new OutputStreamWriter(System.out);

public static void main(String[] args) {
MemoryTests tests = new MemoryTests();
tests.createPdfs();
}

public void createPdfs() {
try {
resetMaximum();
test = false;

writer.write(test_chapters_without_memory_management.pdf);

createPdfWithChapters(test_chapters_without_memory_management.pdf);
resetMaximum();
test = true;

writer.write(test_chapters_with_memory_management.pdf);

createPdfWithChapters(test_chapters_with_memory_management.pdf);
resetMaximum();
test = false;

writer.write(test_pdfptable_without_memory_management.pdf);

createPdfWithPdfPTable(test_pdfptable_without_memory_management.pdf);
resetMaximum();
test = true;

writer.write(test_pdfptable_with_memory_management.pdf);

createPdfWithPdfPTable(test_pdfptable_with_memory_management.pdf);
resetMaximum();
test = false;

writer.write(test_table_without_memory_management.pdf);

createPdfWithTable(test_table_without_memory_management.pdf);
resetMaximum();
test = true;
writer.write(test_table_with_memory_management.pdf);

createPdfWithTable(test_table_with_memory_management.pdf);
resetMaximum();
writer.flush();
writer.close();
}
catch(Exception e) {
e.printStackTrace();
}
}

private void createPdfWithChapters(String filename) throws 
FileNotFoundException, DocumentException {
// step 1: creation of a document-object
Document document = new Document();
// step 2: we create a writer
PdfWriter.getInstance(
document,
new FileOutputStream(filename));
// step 3: we open the document
document.open();
// step 4: we add content to the document
Chapter chapter;
Section section;
Section subsection;
chapter = new Chapter(new Paragraph(chapter, new 
Font(Font.HELVETICA, 14, Font.BOLD)), 1);
if(test) chapter.setComplete(false);
addContent(chapter, 0);
if (test) document.add(chapter);
checkpoint();
section = chapter.addSection(section 1, 1);
if(test) section.setComplete(false);
addContent(section, 1);
if (test) document.add(chapter);
checkpoint();
subsection = section.addSection(subsection 1, 2);
addContent(subsection, 2);
if (test) document.add(chapter);
checkpoint();
subsection = section.addSection(subsection 2, 2);
addContent(subsection, 3);
if (test) document.add(chapter);
checkpoint();
subsection = section.addSection(subsection 3, 2);
addContent(subsection, 4);
if (test) document.add(chapter);
checkpoint();
section = 

[iText-questions] Adding an empty signature-field and signing

2007-12-02 Thread Luca Tomat
Hello,
I need to add two signature-fields and add a signature inside the first one.

This is how i do it:

..
..
//Lets create the two fields
PdfFormField sign1 = PdfFormField.createSignature(
pdfStamper.getWriter());
sign1.setWidget(new Rectangle(100, 600, 180, 640), null);
sign1.setFlags(PdfAnnotation.FLAGS_PRINT);
sign1.setFieldName(sign1);
sign1.setPage(1);
pdfStamper.addAnnotation(sign1, 1);
PdfFormField sign2 = PdfFormField.createSignature(
pdfStamper.getWriter());
sign2.setWidget(new Rectangle(200, 600, 280, 640), null);
sign2.setFlags(PdfAnnotation.FLAGS_PRINT);
sign2.setFieldName(sign2);
sign2.setPage(1);
pdfStamper.addAnnotation(sign2, 1);
..
..
//Creating the signature for the first field
PdfSignatureAppearanceOSP signApp;
signApp = pdfStamper.getSignatureAppearance();
signApp.setCrypto(null, certChain, null,
PdfSignatureAppearance.WINCER_SIGNED);
signApp.setReason(Author);
signApp.setCertified(2);
signApp.setVisibleSignature(sign1);
..
..

Unfortunately on the last line (signApp.setVisibleSignature(sign1);) i get
the error: The field sign1 does not exist.

Why? What am i doing wrong?

Thank you,
Luca
-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


[iText-questions] How to change a PDF but preserve the rights

2007-12-02 Thread Samuel B. Quiring
I have a PDF containing an XFA form; isXfaPresent() == true.  The PDF was 
authored so that it can be opened in Adobe Reader, fields in the form can be 
filled, and the form can be saved by Reader to the file system.

Using iText I have read in the PDF, obtained the XfaForm, changed values in the 
XML Document, and written a new PDF to the file system.

The PDF I write out contains the values I put into the XML, but the rights to 
save the PDF from Reader have been lost.  Is this expected?  Other features of 
the original PDF are also lost in the newly-written PDF.

I wrote the changed PDF to a new file.  If this is the reason the save rights 
were lost, is there a way I can modify the existing PDF in place so that the 
rights to save the file from Adobe Reader are maintained?

-Sam-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] Adding the constructor com.lowagie.text.List(float)

2007-12-02 Thread Alexis Pigeon
Hi Bruno,

On 11/30/07, Bruno Lowagie [EMAIL PROTECTED] wrote:
 Alexis Pigeon wrote:
  Hi Bruno, Paulo, *
 
  Is there any reason for not having the following constructor in
  com.lowagie.text.List?

 Are you sure it isn't there?
 Have a closer look, it's there! (*)

 (*) It's in the SVN repository because I have just
 added it ;-) Thank you for the suggestion!

Thanks for adding it!

alexis

-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/


Re: [iText-questions] How to change a PDF but preserve the rights

2007-12-02 Thread Bruno Lowagie

Samuel B. Quiring wrote:
is there a way I can modify the existing PDF in 
place so that the rights to save the file from Adobe Reader are maintained?


This is only possible with software form Adobe.
It's one of the many sources of revenue for the company.
You won't find any other product that allows you to do what you want.
br,
Bruno


smime.p7s
Description: S/MIME Cryptographic Signature
-
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/