I need advise

View: New views
9 Messages — Rating Filter:   Alert me  

I need advise

by luixv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!
I have a running system written using Itext.
An existing pdf file (a form) will be opened and some information
will be printed. No problem

The small version of the source is like this

ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
PdfReader reader= new PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
PdfStamper stamper = new PdfStamper(reader, byteOut);  // A STAMPER IS USED
PdfContentByte topLayer = stamper.getOverContent(1);

    this.writePhytoTransDocSection2(topLayer, bla, bla);      

stamper.close();
byteOut.close();
return byteOut.toByteArray();


The point now is that depending of the parameters under certain conditions
an attachment must be generated. The original stamped document AND
the attachment shoud remain in ONE File.

How is the best way to do this?

Thanks in advance.

Luis Mandel

--
-----------------------------
Luis Mandel
luismandel@...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by Paulo Soares-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

stamper.AddFileAttachment().

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Thursday, August 27, 2009 4:41 PM
> To: itextsharp-questions@...
> Subject: [itextsharp-questions] I need advise
>
> Hi!
> I have a running system written using Itext.
> An existing pdf file (a form) will be opened and some information
> will be printed. No problem
>
> The small version of the source is like this
>
> ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
> PdfReader reader= new
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
> PdfStamper stamper = new PdfStamper(reader, byteOut);  // A
> STAMPER IS USED
> PdfContentByte topLayer = stamper.getOverContent(1);
>
>     this.writePhytoTransDocSection2(topLayer, bla, bla);      
>
> stamper.close();
> byteOut.close();
> return byteOut.toByteArray();
>
>
> The point now is that depending of the parameters under
> certain conditions
> an attachment must be generated. The original stamped document AND
> the attachment shoud remain in ONE File.
>
> How is the best way to do this?
>
> Thanks in advance.
>
> Luis Mandel
>
> --
> -----------------------------
> Luis Mandel
> luismandel@...
>
>
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by luixv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK, thanks. Bur as far as I know the method AddFileAttachment is for
adding a statixc PDF File. I need to add a dynamic generated PDF.
Is this possible with addFileAttachment?

Muito obrigado,

Luis

On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares <psoares@...> wrote:
stamper.AddFileAttachment().

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Thursday, August 27, 2009 4:41 PM
> To: itextsharp-questions@...
> Subject: [itextsharp-questions] I need advise
>
> Hi!
> I have a running system written using Itext.
> An existing pdf file (a form) will be opened and some information
> will be printed. No problem
>
> The small version of the source is like this
>
> ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
> PdfReader reader= new
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
> PdfStamper stamper = new PdfStamper(reader, byteOut);  // A
> STAMPER IS USED
> PdfContentByte topLayer = stamper.getOverContent(1);
>
>     this.writePhytoTransDocSection2(topLayer, bla, bla);
>
> stamper.close();
> byteOut.close();
> return byteOut.toByteArray();
>
>
> The point now is that depending of the parameters under
> certain conditions
> an attachment must be generated. The original stamped document AND
> the attachment shoud remain in ONE File.
>
> How is the best way to do this?
>
> Thanks in advance.
>
> Luis Mandel
>
> --
> -----------------------------
> Luis Mandel
> luismandel@...
>
>

Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions




--
-----------------------------
Dr. Luis Mandel
luismandel@...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by Paulo Soares-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You'll have to explain better what goes into what.

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Friday, August 28, 2009 11:08 AM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> OK, thanks. Bur as far as I know the method AddFileAttachment is for
> adding a statixc PDF File. I need to add a dynamic generated PDF.
> Is this possible with addFileAttachment?
>
> Muito obrigado,
>
> Luis
>
>
> On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
> <psoares@...> wrote:
>
>
> stamper.AddFileAttachment().
>
> Paulo
>
>
> > -----Original Message-----
> > From: Luis Mandel [mailto:luismandel@...]
> > Sent: Thursday, August 27, 2009 4:41 PM
> > To: itextsharp-questions@...
> > Subject: [itextsharp-questions] I need advise
> >
> > Hi!
> > I have a running system written using Itext.
> > An existing pdf file (a form) will be opened and some
> information
> > will be printed. No problem
> >
> > The small version of the source is like this
> >
> > ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
> > PdfReader reader= new
> >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
> > PdfStamper stamper = new PdfStamper(reader, byteOut);  // A
> > STAMPER IS USED
> > PdfContentByte topLayer = stamper.getOverContent(1);
> >
> >     this.writePhytoTransDocSection2(topLayer, bla, bla);
> >
> > stamper.close();
> > byteOut.close();
> > return byteOut.toByteArray();
> >
> >
> > The point now is that depending of the parameters under
> > certain conditions
> > an attachment must be generated. The original stamped
> document AND
> > the attachment shoud remain in ONE File.
> >
> > How is the best way to do this?
> >
> > Thanks in advance.
> >
> > Luis Mandel
> >
> > --
> > -----------------------------
> > Luis Mandel
> > luismandel@...

Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by luixv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

OK.
Let's try.

I have a form in a PDF file.
Up to now the form has been filled and printed out with data coming from
a database (or user input) without any problem.
This has been done using PDFstamper.
There is ONE field of this  form which might be too long. Let's say
if the content to be printed of the field number 1 is longer than 100 chars
then I have to write  as content of the field 1 the sentence
"see attachment" and in a new page I have to write some headings and the
content of the field 1 (whose length is more than 100 chars).

I suceed generating an attachment doing the following:

if (kennZ.length() > 150) {
           
            ct.setText(new Phrase(getPhytoDocFieldValueText("see Attatchement" ));           
            generateAttachment(dienststelleKuerzel, antrag_id, kennZ, stamper);
        } else {
            ct.setText(new Phrase(getPhytoDocFieldValueText(kennZ)));           
        }

and the  method generateAttachment is as follows


private void generateAttachment( String kennZ, PdfStamper stamper) throws Exception {
        // Base Font
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
       
        int page = 2;
        stamper.insertPage(page, PageSize.A4);
       
        PdfContentByte cb = stamper.getOverContent(page);
       
        cb.beginText();
       
        cb.setFontAndSize(bf ,10);
        cb.setTextMatrix(36, 770);
        cb.newlineShowText("Attatchment to Transport document Nr.: EG/DE/" );
       
        cb.setFontAndSize(bf ,9);
        cb.setTextMatrix(36, 760);
       
        cb.showTextAligned(PdfContentByte.ALIGN_LEFT, kennZ, 36, 750, 0);
       
        cb.endText();   

But this is not exactly what I am looking for, because the
content of the parameter "kennZ" will have \n (carriage return) and it is
potentially long.

I would like to know if there is any way to get the text wrapped .

In fact this should be a very easy job. A title and some text.
I didn't find any method for doing this.
Probably I am using the wrong approach inside Itext.

Thanks a lot for yor valuable help.

Ate logo,

Luis



On Fri, Aug 28, 2009 at 12:39 PM, Paulo Soares <psoares@...> wrote:
You'll have to explain better what goes into what.

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Friday, August 28, 2009 11:08 AM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> OK, thanks. Bur as far as I know the method AddFileAttachment is for
> adding a statixc PDF File. I need to add a dynamic generated PDF.
> Is this possible with addFileAttachment?
>
> Muito obrigado,
>
> Luis
>
>
> On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
> <psoares@...> wrote:
>
>
>       stamper.AddFileAttachment().
>
>       Paulo
>
>
>       > -----Original Message-----
>       > From: Luis Mandel [mailto:luismandel@...]
>       > Sent: Thursday, August 27, 2009 4:41 PM
>       > To: itextsharp-questions@...
>       > Subject: [itextsharp-questions] I need advise
>       >
>       > Hi!
>       > I have a running system written using Itext.
>       > An existing pdf file (a form) will be opened and some
> information
>       > will be printed. No problem
>       >
>       > The small version of the source is like this
>       >
>       > ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
>       > PdfReader reader= new
>       >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
>       > PdfStamper stamper = new PdfStamper(reader, byteOut);  // A
>       > STAMPER IS USED
>       > PdfContentByte topLayer = stamper.getOverContent(1);
>       >
>       >     this.writePhytoTransDocSection2(topLayer, bla, bla);
>       >
>       > stamper.close();
>       > byteOut.close();
>       > return byteOut.toByteArray();
>       >
>       >
>       > The point now is that depending of the parameters under
>       > certain conditions
>       > an attachment must be generated. The original stamped
> document AND
>       > the attachment shoud remain in ONE File.
>       >
>       > How is the best way to do this?
>       >
>       > Thanks in advance.
>       >
>       > Luis Mandel
>       >
>       > --
>       > -----------------------------
>       > Luis Mandel
>       > luismandel@...


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions




--
-----------------------------
Dr. Luis Mandel
luismandel@...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by Paulo Soares-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ah, you don't want an attachment but rather a new page appended to the original document. You are doing it correctly, you'll just have to use a ColumnText to take care of all the layaout (including the \n).

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Friday, August 28, 2009 1:17 PM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> OK.
> Let's try.
>
> I have a form in a PDF file.
> Up to now the form has been filled and printed out with data
> coming from
> a database (or user input) without any problem.
> This has been done using PDFstamper.
> There is ONE field of this  form which might be too long. Let's say
> if the content to be printed of the field number 1 is longer
> than 100 chars
> then I have to write  as content of the field 1 the sentence
> "see attachment" and in a new page I have to write some
> headings and the
> content of the field 1 (whose length is more than 100 chars).
>
> I suceed generating an attachment doing the following:
>
> if (kennZ.length() > 150) {
>            
>             ct.setText(new
> Phrase(getPhytoDocFieldValueText("see Attatchement" ));            
>             generateAttachment(dienststelleKuerzel,
> antrag_id, kennZ, stamper);
>         } else {
>             ct.setText(new
> Phrase(getPhytoDocFieldValueText(kennZ)));            
>         }
>
> and the  method generateAttachment is as follows
>
>
> private void generateAttachment( String kennZ, PdfStamper
> stamper) throws Exception {
>         // Base Font
>         BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
>        
>         int page = 2;
>         stamper.insertPage(page, PageSize.A4);
>        
>         PdfContentByte cb = stamper.getOverContent(page);
>        
>         cb.beginText();
>        
>         cb.setFontAndSize(bf ,10);
>         cb.setTextMatrix(36, 770);
>         cb.newlineShowText("Attatchment to Transport document
> Nr.: EG/DE/" );
>        
>         cb.setFontAndSize(bf ,9);
>         cb.setTextMatrix(36, 760);
>        
>         cb.showTextAligned(PdfContentByte.ALIGN_LEFT, kennZ,
> 36, 750, 0);
>        
>         cb.endText();    
>
> But this is not exactly what I am looking for, because the
> content of the parameter "kennZ" will have \n (carriage
> return) and it is
> potentially long.
>
> I would like to know if there is any way to get the text wrapped .
>
> In fact this should be a very easy job. A title and some text.
> I didn't find any method for doing this.
> Probably I am using the wrong approach inside Itext.
>
> Thanks a lot for yor valuable help.
>
> Ate logo,
>
> Luis
>
>
>
>
> On Fri, Aug 28, 2009 at 12:39 PM, Paulo Soares
> <psoares@...> wrote:
>
>
> You'll have to explain better what goes into what.
>
>
> Paulo
>
> > -----Original Message-----
> > From: Luis Mandel [mailto:luismandel@...]
>
> > Sent: Friday, August 28, 2009 11:08 AM
> > To: Post all your questions about iTextSharp here
> > Subject: Re: [itextsharp-questions] I need advise
> >
> > OK, thanks. Bur as far as I know the method
> AddFileAttachment is for
> > adding a statixc PDF File. I need to add a dynamic
> generated PDF.
> > Is this possible with addFileAttachment?
> >
> > Muito obrigado,
> >
> > Luis
> >
> >
> > On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
> > <psoares@...> wrote:
> >
> >
> >       stamper.AddFileAttachment().
> >
> >       Paulo
> >
> >
> >       > -----Original Message-----
> >       > From: Luis Mandel [mailto:luismandel@...]
> >       > Sent: Thursday, August 27, 2009 4:41 PM
> >       > To: itextsharp-questions@...
> >       > Subject: [itextsharp-questions] I need advise
> >       >
> >       > Hi!
> >       > I have a running system written using Itext.
> >       > An existing pdf file (a form) will be opened and some
> > information
> >       > will be printed. No problem
> >       >
> >       > The small version of the source is like this
> >       >
> >       > ByteArrayOutputStream byteOut = new
> ByteArrayOutputStream();
> >       > PdfReader reader= new
> >       >
> >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
> >       > PdfStamper stamper = new PdfStamper(reader,
> byteOut);  // A
> >       > STAMPER IS USED
> >       > PdfContentByte topLayer = stamper.getOverContent(1);
> >       >
> >       >     this.writePhytoTransDocSection2(topLayer,
> bla, bla);
> >       >
> >       > stamper.close();
> >       > byteOut.close();
> >       > return byteOut.toByteArray();
> >       >
> >       >
> >       > The point now is that depending of the
> parameters under
> >       > certain conditions
> >       > an attachment must be generated. The original stamped
> > document AND
> >       > the attachment shoud remain in ONE File.
> >       >
> >       > How is the best way to do this?
> >       >
> >       > Thanks in advance.
> >       >
> >       > Luis Mandel
> >       >
> >       > --
> >       > -----------------------------
> >       > Luis Mandel
> >       > luismandel@...

Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by luixv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for yor answer.
Sorry, I used the word attachment in a wrong context.

The point is that I have my text in a variable and I would
like to print the content of this variable as it is.
I would like to avoid to parse it, to count the words
and so on.

Is there a way just to send it to the page without taking care
of the format?

Thanks,

Luis

On Fri, Aug 28, 2009 at 3:27 PM, Paulo Soares <psoares@...> wrote:
Ah, you don't want an attachment but rather a new page appended to the original document. You are doing it correctly, you'll just have to use a ColumnText to take care of all the layaout (including the \n).

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Friday, August 28, 2009 1:17 PM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> OK.
> Let's try.
>
> I have a form in a PDF file.
> Up to now the form has been filled and printed out with data
> coming from
> a database (or user input) without any problem.
> This has been done using PDFstamper.
> There is ONE field of this  form which might be too long. Let's say
> if the content to be printed of the field number 1 is longer
> than 100 chars
> then I have to write  as content of the field 1 the sentence
> "see attachment" and in a new page I have to write some
> headings and the
> content of the field 1 (whose length is more than 100 chars).
>
> I suceed generating an attachment doing the following:
>
> if (kennZ.length() > 150) {
>
>             ct.setText(new
> Phrase(getPhytoDocFieldValueText("see Attatchement" ));
>             generateAttachment(dienststelleKuerzel,
> antrag_id, kennZ, stamper);
>         } else {
>             ct.setText(new
> Phrase(getPhytoDocFieldValueText(kennZ)));
>         }
>
> and the  method generateAttachment is as follows
>
>
> private void generateAttachment( String kennZ, PdfStamper
> stamper) throws Exception {
>         // Base Font
>         BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
>
>         int page = 2;
>         stamper.insertPage(page, PageSize.A4);
>
>         PdfContentByte cb = stamper.getOverContent(page);
>
>         cb.beginText();
>
>         cb.setFontAndSize(bf ,10);
>         cb.setTextMatrix(36, 770);
>         cb.newlineShowText("Attatchment to Transport document
> Nr.: EG/DE/" );
>
>         cb.setFontAndSize(bf ,9);
>         cb.setTextMatrix(36, 760);
>
>         cb.showTextAligned(PdfContentByte.ALIGN_LEFT, kennZ,
> 36, 750, 0);
>
>         cb.endText();
>
> But this is not exactly what I am looking for, because the
> content of the parameter "kennZ" will have \n (carriage
> return) and it is
> potentially long.
>
> I would like to know if there is any way to get the text wrapped .
>
> In fact this should be a very easy job. A title and some text.
> I didn't find any method for doing this.
> Probably I am using the wrong approach inside Itext.
>
> Thanks a lot for yor valuable help.
>
> Ate logo,
>
> Luis
>
>
>
>
> On Fri, Aug 28, 2009 at 12:39 PM, Paulo Soares
> <psoares@...> wrote:
>
>
>       You'll have to explain better what goes into what.
>
>
>       Paulo
>
>       > -----Original Message-----
>       > From: Luis Mandel [mailto:luismandel@...]
>
>       > Sent: Friday, August 28, 2009 11:08 AM
>       > To: Post all your questions about iTextSharp here
>       > Subject: Re: [itextsharp-questions] I need advise
>       >
>       > OK, thanks. Bur as far as I know the method
> AddFileAttachment is for
>       > adding a statixc PDF File. I need to add a dynamic
> generated PDF.
>       > Is this possible with addFileAttachment?
>       >
>       > Muito obrigado,
>       >
>       > Luis
>       >
>       >
>       > On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
>       > <psoares@...> wrote:
>       >
>       >
>       >       stamper.AddFileAttachment().
>       >
>       >       Paulo
>       >
>       >
>       >       > -----Original Message-----
>       >       > From: Luis Mandel [mailto:luismandel@...]
>       >       > Sent: Thursday, August 27, 2009 4:41 PM
>       >       > To: itextsharp-questions@...
>       >       > Subject: [itextsharp-questions] I need advise
>       >       >
>       >       > Hi!
>       >       > I have a running system written using Itext.
>       >       > An existing pdf file (a form) will be opened and some
>       > information
>       >       > will be printed. No problem
>       >       >
>       >       > The small version of the source is like this
>       >       >
>       >       > ByteArrayOutputStream byteOut = new
> ByteArrayOutputStream();
>       >       > PdfReader reader= new
>       >       >
>       >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
>       >       > PdfStamper stamper = new PdfStamper(reader,
> byteOut);  // A
>       >       > STAMPER IS USED
>       >       > PdfContentByte topLayer = stamper.getOverContent(1);
>       >       >
>       >       >     this.writePhytoTransDocSection2(topLayer,
> bla, bla);
>       >       >
>       >       > stamper.close();
>       >       > byteOut.close();
>       >       > return byteOut.toByteArray();
>       >       >
>       >       >
>       >       > The point now is that depending of the
> parameters under
>       >       > certain conditions
>       >       > an attachment must be generated. The original stamped
>       > document AND
>       >       > the attachment shoud remain in ONE File.
>       >       >
>       >       > How is the best way to do this?
>       >       >
>       >       > Thanks in advance.
>       >       >
>       >       > Luis Mandel
>       >       >
>       >       > --
>       >       > -----------------------------
>       >       > Luis Mandel
>       >       > luismandel@...


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions




--
-----------------------------
Dr. Luis Mandel
luismandel@...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by Paulo Soares-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Look at the ColumnText examples at http://1t3xt.be/?X0005df. In short you tell ColumnText the rectangle you want the text to be and everything will be done for you including line wrap and /n processing, it can't be simpler. I would advise you to buy the iText book where this and many other things are explained in detail.

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Monday, August 31, 2009 4:44 PM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> Thanks for yor answer.
> Sorry, I used the word attachment in a wrong context.
>
> The point is that I have my text in a variable and I would
> like to print the content of this variable as it is.
> I would like to avoid to parse it, to count the words
> and so on.
>
> Is there a way just to send it to the page without taking care
> of the format?
>
> Thanks,
>
> Luis
>
>
> On Fri, Aug 28, 2009 at 3:27 PM, Paulo Soares
> <psoares@...> wrote:
>
>
> Ah, you don't want an attachment but rather a new page
> appended to the original document. You are doing it
> correctly, you'll just have to use a ColumnText to take care
> of all the layaout (including the \n).
>
>
> Paulo
>
> > -----Original Message-----
> > From: Luis Mandel [mailto:luismandel@...]
>
> > Sent: Friday, August 28, 2009 1:17 PM
> > To: Post all your questions about iTextSharp here
> > Subject: Re: [itextsharp-questions] I need advise
> >
> > OK.
> > Let's try.
> >
> > I have a form in a PDF file.
> > Up to now the form has been filled and printed out with data
> > coming from
> > a database (or user input) without any problem.
> > This has been done using PDFstamper.
> > There is ONE field of this  form which might be too
> long. Let's say
> > if the content to be printed of the field number 1 is longer
> > than 100 chars
> > then I have to write  as content of the field 1 the sentence
> > "see attachment" and in a new page I have to write some
> > headings and the
> > content of the field 1 (whose length is more than 100 chars).
> >
> > I suceed generating an attachment doing the following:
> >
> > if (kennZ.length() > 150) {
> >
> >             ct.setText(new
> > Phrase(getPhytoDocFieldValueText("see Attatchement" ));
> >             generateAttachment(dienststelleKuerzel,
> > antrag_id, kennZ, stamper);
> >         } else {
> >             ct.setText(new
> > Phrase(getPhytoDocFieldValueText(kennZ)));
> >         }
> >
> > and the  method generateAttachment is as follows
> >
> >
> > private void generateAttachment( String kennZ, PdfStamper
> > stamper) throws Exception {
> >         // Base Font
> >         BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
> > BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
> >
> >         int page = 2;
> >         stamper.insertPage(page, PageSize.A4);
> >
> >         PdfContentByte cb = stamper.getOverContent(page);
> >
> >         cb.beginText();
> >
> >         cb.setFontAndSize(bf ,10);
> >         cb.setTextMatrix(36, 770);
> >         cb.newlineShowText("Attatchment to Transport document
> > Nr.: EG/DE/" );
> >
> >         cb.setFontAndSize(bf ,9);
> >         cb.setTextMatrix(36, 760);
> >
> >         cb.showTextAligned(PdfContentByte.ALIGN_LEFT, kennZ,
> > 36, 750, 0);
> >
> >         cb.endText();
> >
> > But this is not exactly what I am looking for, because the
> > content of the parameter "kennZ" will have \n (carriage
> > return) and it is
> > potentially long.
> >
> > I would like to know if there is any way to get the
> text wrapped .
> >
> > In fact this should be a very easy job. A title and some text.
> > I didn't find any method for doing this.
> > Probably I am using the wrong approach inside Itext.
> >
> > Thanks a lot for yor valuable help.
> >
> > Ate logo,
> >
> > Luis
> >
> >
> >
> >
> > On Fri, Aug 28, 2009 at 12:39 PM, Paulo Soares
> > <psoares@...> wrote:
> >
> >
> >       You'll have to explain better what goes into what.
> >
> >
> >       Paulo
> >
> >       > -----Original Message-----
> >       > From: Luis Mandel [mailto:luismandel@...]
> >
> >       > Sent: Friday, August 28, 2009 11:08 AM
> >       > To: Post all your questions about iTextSharp here
> >       > Subject: Re: [itextsharp-questions] I need advise
> >       >
> >       > OK, thanks. Bur as far as I know the method
> > AddFileAttachment is for
> >       > adding a statixc PDF File. I need to add a dynamic
> > generated PDF.
> >       > Is this possible with addFileAttachment?
> >       >
> >       > Muito obrigado,
> >       >
> >       > Luis
> >       >
> >       >
> >       > On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
> >       > <psoares@...> wrote:
> >       >
> >       >
> >       >       stamper.AddFileAttachment().
> >       >
> >       >       Paulo
> >       >
> >       >
> >       >       > -----Original Message-----
> >       >       > From: Luis Mandel
> [mailto:luismandel@...]
> >       >       > Sent: Thursday, August 27, 2009 4:41 PM
> >       >       > To: itextsharp-questions@...
> >       >       > Subject: [itextsharp-questions] I need advise
> >       >       >
> >       >       > Hi!
> >       >       > I have a running system written using Itext.
> >       >       > An existing pdf file (a form) will be
> opened and some
> >       > information
> >       >       > will be printed. No problem
> >       >       >
> >       >       > The small version of the source is like this
> >       >       >
> >       >       > ByteArrayOutputStream byteOut = new
> > ByteArrayOutputStream();
> >       >       > PdfReader reader= new
> >       >       >
> >       >
> >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
> >       >       > PdfStamper stamper = new PdfStamper(reader,
> > byteOut);  // A
> >       >       > STAMPER IS USED
> >       >       > PdfContentByte topLayer =
> stamper.getOverContent(1);
> >       >       >
> >       >       >     this.writePhytoTransDocSection2(topLayer,
> > bla, bla);
> >       >       >
> >       >       > stamper.close();
> >       >       > byteOut.close();
> >       >       > return byteOut.toByteArray();
> >       >       >
> >       >       >
> >       >       > The point now is that depending of the
> > parameters under
> >       >       > certain conditions
> >       >       > an attachment must be generated. The
> original stamped
> >       > document AND
> >       >       > the attachment shoud remain in ONE File.
> >       >       >
> >       >       > How is the best way to do this?
> >       >       >
> >       >       > Thanks in advance.
> >       >       >
> >       >       > Luis Mandel
> >       >       >
> >       >       > --
> >       >       > -----------------------------
> >       >       > Luis Mandel
> >       >       > luismandel@...

Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions

Re: I need advise

by luixv :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Obrigado Paulo. I bought the iText book.
I will try what you said, but I am getting the text in one line.
No line breaks. For sure I am making a mistake.
Unfortunately now I have to work for another project.
Next week I will work on this again.

Muito obrigado e ate logo

On Mon, Aug 31, 2009 at 7:20 PM, Paulo Soares <psoares@...> wrote:
Look at the ColumnText examples at http://1t3xt.be/?X0005df. In short you tell ColumnText the rectangle you want the text to be and everything will be done for you including line wrap and /n processing, it can't be simpler. I would advise you to buy the iText book where this and many other things are explained in detail.

Paulo

> -----Original Message-----
> From: Luis Mandel [mailto:luismandel@...]
> Sent: Monday, August 31, 2009 4:44 PM
> To: Post all your questions about iTextSharp here
> Subject: Re: [itextsharp-questions] I need advise
>
> Thanks for yor answer.
> Sorry, I used the word attachment in a wrong context.
>
> The point is that I have my text in a variable and I would
> like to print the content of this variable as it is.
> I would like to avoid to parse it, to count the words
> and so on.
>
> Is there a way just to send it to the page without taking care
> of the format?
>
> Thanks,
>
> Luis
>
>
> On Fri, Aug 28, 2009 at 3:27 PM, Paulo Soares
> <psoares@...> wrote:
>
>
>       Ah, you don't want an attachment but rather a new page
> appended to the original document. You are doing it
> correctly, you'll just have to use a ColumnText to take care
> of all the layaout (including the \n).
>
>
>       Paulo
>
>       > -----Original Message-----
>       > From: Luis Mandel [mailto:luismandel@...]
>
>       > Sent: Friday, August 28, 2009 1:17 PM
>       > To: Post all your questions about iTextSharp here
>       > Subject: Re: [itextsharp-questions] I need advise
>       >
>       > OK.
>       > Let's try.
>       >
>       > I have a form in a PDF file.
>       > Up to now the form has been filled and printed out with data
>       > coming from
>       > a database (or user input) without any problem.
>       > This has been done using PDFstamper.
>       > There is ONE field of this  form which might be too
> long. Let's say
>       > if the content to be printed of the field number 1 is longer
>       > than 100 chars
>       > then I have to write  as content of the field 1 the sentence
>       > "see attachment" and in a new page I have to write some
>       > headings and the
>       > content of the field 1 (whose length is more than 100 chars).
>       >
>       > I suceed generating an attachment doing the following:
>       >
>       > if (kennZ.length() > 150) {
>       >
>       >             ct.setText(new
>       > Phrase(getPhytoDocFieldValueText("see Attatchement" ));
>       >             generateAttachment(dienststelleKuerzel,
>       > antrag_id, kennZ, stamper);
>       >         } else {
>       >             ct.setText(new
>       > Phrase(getPhytoDocFieldValueText(kennZ)));
>       >         }
>       >
>       > and the  method generateAttachment is as follows
>       >
>       >
>       > private void generateAttachment( String kennZ, PdfStamper
>       > stamper) throws Exception {
>       >         // Base Font
>       >         BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
>       > BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
>       >
>       >         int page = 2;
>       >         stamper.insertPage(page, PageSize.A4);
>       >
>       >         PdfContentByte cb = stamper.getOverContent(page);
>       >
>       >         cb.beginText();
>       >
>       >         cb.setFontAndSize(bf ,10);
>       >         cb.setTextMatrix(36, 770);
>       >         cb.newlineShowText("Attatchment to Transport document
>       > Nr.: EG/DE/" );
>       >
>       >         cb.setFontAndSize(bf ,9);
>       >         cb.setTextMatrix(36, 760);
>       >
>       >         cb.showTextAligned(PdfContentByte.ALIGN_LEFT, kennZ,
>       > 36, 750, 0);
>       >
>       >         cb.endText();
>       >
>       > But this is not exactly what I am looking for, because the
>       > content of the parameter "kennZ" will have \n (carriage
>       > return) and it is
>       > potentially long.
>       >
>       > I would like to know if there is any way to get the
> text wrapped .
>       >
>       > In fact this should be a very easy job. A title and some text.
>       > I didn't find any method for doing this.
>       > Probably I am using the wrong approach inside Itext.
>       >
>       > Thanks a lot for yor valuable help.
>       >
>       > Ate logo,
>       >
>       > Luis
>       >
>       >
>       >
>       >
>       > On Fri, Aug 28, 2009 at 12:39 PM, Paulo Soares
>       > <psoares@...> wrote:
>       >
>       >
>       >       You'll have to explain better what goes into what.
>       >
>       >
>       >       Paulo
>       >
>       >       > -----Original Message-----
>       >       > From: Luis Mandel [mailto:luismandel@...]
>       >
>       >       > Sent: Friday, August 28, 2009 11:08 AM
>       >       > To: Post all your questions about iTextSharp here
>       >       > Subject: Re: [itextsharp-questions] I need advise
>       >       >
>       >       > OK, thanks. Bur as far as I know the method
>       > AddFileAttachment is for
>       >       > adding a statixc PDF File. I need to add a dynamic
>       > generated PDF.
>       >       > Is this possible with addFileAttachment?
>       >       >
>       >       > Muito obrigado,
>       >       >
>       >       > Luis
>       >       >
>       >       >
>       >       > On Thu, Aug 27, 2009 at 7:16 PM, Paulo Soares
>       >       > <psoares@...> wrote:
>       >       >
>       >       >
>       >       >       stamper.AddFileAttachment().
>       >       >
>       >       >       Paulo
>       >       >
>       >       >
>       >       >       > -----Original Message-----
>       >       >       > From: Luis Mandel
> [mailto:luismandel@...]
>       >       >       > Sent: Thursday, August 27, 2009 4:41 PM
>       >       >       > To: itextsharp-questions@...
>       >       >       > Subject: [itextsharp-questions] I need advise
>       >       >       >
>       >       >       > Hi!
>       >       >       > I have a running system written using Itext.
>       >       >       > An existing pdf file (a form) will be
> opened and some
>       >       > information
>       >       >       > will be printed. No problem
>       >       >       >
>       >       >       > The small version of the source is like this
>       >       >       >
>       >       >       > ByteArrayOutputStream byteOut = new
>       > ByteArrayOutputStream();
>       >       >       > PdfReader reader= new
>       >       >       >
>       >       >
>       >
> PdfReader(this.getClass().getResourceAsStream(TEMPLATE_PDF_PATH));
>       >       >       > PdfStamper stamper = new PdfStamper(reader,
>       > byteOut);  // A
>       >       >       > STAMPER IS USED
>       >       >       > PdfContentByte topLayer =
> stamper.getOverContent(1);
>       >       >       >
>       >       >       >     this.writePhytoTransDocSection2(topLayer,
>       > bla, bla);
>       >       >       >
>       >       >       > stamper.close();
>       >       >       > byteOut.close();
>       >       >       > return byteOut.toByteArray();
>       >       >       >
>       >       >       >
>       >       >       > The point now is that depending of the
>       > parameters under
>       >       >       > certain conditions
>       >       >       > an attachment must be generated. The
> original stamped
>       >       > document AND
>       >       >       > the attachment shoud remain in ONE File.
>       >       >       >
>       >       >       > How is the best way to do this?
>       >       >       >
>       >       >       > Thanks in advance.
>       >       >       >
>       >       >       > Luis Mandel
>       >       >       >
>       >       >       > --
>       >       >       > -----------------------------
>       >       >       > Luis Mandel
>       >       >       > luismandel@...


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem.

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions




--
-----------------------------
Dr. Luis Mandel
luismandel@...

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
itextsharp-questions mailing list
itextsharp-questions@...
https://lists.sourceforge.net/lists/listinfo/itextsharp-questions