Change of font/size

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

Change of font/size

by Pierre G :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Hi ,
 
I generated a letter using data from database. In some circumstance (that I don't understand), some static text (not from DB) change their sizes,
I attached to picture to make it clearer.
The change starts at the sentence : "Service de Pharmacologie et Toxicologie cliniques".
 
 
Thanks in advance for any idea or way to debug the problem.
 
Pierre
NB : The code, jar (iText-2.0.8.jar) and machine are the same.
 
 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

pdfok.PNG (70K) Download Attachment
pdfNotok.PNG (80K) Download Attachment

Re: Change of font/size

by Bruno Lowagie (iText) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pierre Gilquin wrote:
> Hi ,
>  
> I generated a letter using data from database. In some circumstance
> (that I don't understand), some static text (not from DB) change their
> sizes,
> I attached to picture to make it clearer.

That doesn't clarify the problem. Are you embedding the font?
What about sending two PDFs so that we can compare? (It would be
interesting to see what font is used and what the content stream
looks like internally.) What about sending us a code sample so
that we can reproduce the problem?

> Thanks in advance for any idea or way to debug the problem.

He who has the code, can debug; he who doesn't have the code,
can only guess.
br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

Re: Change of font/size

by Pierre G :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Bruno,

This is the code. The problem start in the paragraph "paragraphDocteurs", the font used is  stFont and is set in the
constructor.

Pierre

public class LettreGenerateur {
    private static LettreGenerateur instance;
    private static Font stFont = FontFactory.getFont(FontFactory.HELVETICA, 6, Font.NORMAL, new Color(0, 0, 0));
    private static Font grasFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, new Color(0, 0, 0));
    private static Font fontTable = FontFactory.getFont(FontFactory.HELVETICA, 4, Font.NORMAL, new Color(0, 0, 0));
    private static SimpleDateFormat dateFormat = new SimpleDateFormat ("dd.MM.yyyy");
    private  Consultation consultation;

    private LettreGenerateur() {
    }


    public static LettreGenerateur getInstance() {
      if (instance == null) {
        instance = new LettreGenerateur();
      }

      return instance;
    }
    public void generateLettre(Consultation consultation) throws Exception
    {
      this.consultation = consultation;
      Document document = null;
      try {
        document = new Document(PageSize.A4,
                    50.0f, 50.0f, 50.0f, 50.0f);
        PdfWriter.getInstance(document,
                              new FileOutputStream("consultation\\L" + consultation.numeroDeConsultation().toString()
+".pdf"));
        document.addAuthor("Pierre Gilquin");
        document.addCreator("Pierre Gilquin");
        document.addSubject("Consultation");
        document.addTitle("Consultation");

        Phrase phraseEn = new Phrase(32/* 47*/,
            new Chunk("Département d'anesthésiologie, pharmacologie et soins intensifs",
                      FontFactory.getFont(FontFactory.HELVETICA, 6, Font.BOLD,
                                          new Color(0, 0, 0))));
        Image image2 = Image.getInstance(Resources.class.getResource("logo_hug.gif"));
        image2.setAlignment(Image.ALIGN_RIGHT);
        image2.scaleAbsolute(107.5f, 37.5f);
        phraseEn.add(new Chunk(image2, 140, -8));

        HeaderFooter footer = new HeaderFooter(new Phrase(10, "Service de Pharmacologie et Toxicologie cliniques -
Hôpitaux Universitaires Genève - Rue Micheli-du-Crest 24 CH - 1211 Genève 14 \n "
            + "Téléphone 022 382 99 36 - Téléfax 022 382 99 45",
            stFont), false);

        footer.setAlignment(footer.ALIGN_CENTER);
        document.setHeader(new HeaderFooter(phraseEn, false));
        document.setFooter(footer);
        document.open();

        Paragraph paragraphDocteurs = new Paragraph(
            "Service de Pharmacologie et Toxicologie cliniques\n",
            stFont);
        Phrase el1 = new Phrase("Prof. P. Dayer, médecin chef de service\n");
        Phrase el2 = new Phrase(
            "Centre d'informations thérapeutiques et de pharmacovigilance\n",
            grasFont);
        Phrase el3 = new Phrase(
            "Dr J. Desmeules, CC, médecin adjoint agrégé responsable du centre\n");
        Phrase el4 = new Phrase("Dr V. Piguet, médecin adjointe\n");
        Phrase el5 = new Phrase("Dr M. Escher-Imhof, médecin adjointe\n");
        Phrase el6 = new Phrase("Dr M. Besson, cheffe de clinique\n");
        Phrase el7 = new Phrase("Dr V. Rollason, cheffe de projet\n");
        paragraphDocteurs.add(el2);
        paragraphDocteurs.add(el1);
        paragraphDocteurs.add(el3);
        paragraphDocteurs.add(el4);
        paragraphDocteurs.add(el5);
        paragraphDocteurs.add(el6);
        paragraphDocteurs.add(el7);

        document.add(paragraphDocteurs);

.......

----- Original Message -----
From: "Bruno Lowagie" <bruno@...>
To: "Post all your questions about iText here" <itext-questions@...>
Sent: Friday, May 16, 2008 11:15 AM
Subject: Re: [iText-questions] Change of font/size


> Pierre Gilquin wrote:
>> Hi ,
>>
>> I generated a letter using data from database. In some circumstance
>> (that I don't understand), some static text (not from DB) change their
>> sizes,
>> I attached to picture to make it clearer.
>
> That doesn't clarify the problem. Are you embedding the font?
> What about sending two PDFs so that we can compare? (It would be
> interesting to see what font is used and what the content stream
> looks like internally.) What about sending us a code sample so
> that we can reproduce the problem?
>
>> Thanks in advance for any idea or way to debug the problem.
>
> He who has the code, can debug; he who doesn't have the code,
> can only guess.
> br,
> Bruno
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> iText-questions mailing list
> iText-questions@...
> 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 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

Re: Change of font/size

by Pierre G :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bruno,


Here are 2 pdf.
The only difference is that I add junk text (from db) in the "RÉSUMÉ CLINIQUE" part.
This make difference at the beginning of the document ....

Thanks.

Pierre


----- Original Message -----
From: "Bruno Lowagie" <bruno@...>
To: "Post all your questions about iText here" <itext-questions@...>
Sent: Friday, May 16, 2008 11:15 AM
Subject: Re: [iText-questions] Change of font/size


> Pierre Gilquin wrote:
>> Hi ,
>>
>> I generated a letter using data from database. In some circumstance
>> (that I don't understand), some static text (not from DB) change their
>> sizes,
>> I attached to picture to make it clearer.
>
> That doesn't clarify the problem. Are you embedding the font?
> What about sending two PDFs so that we can compare? (It would be
> interesting to see what font is used and what the content stream
> looks like internally.) What about sending us a code sample so
> that we can reproduce the problem?
>
>> Thanks in advance for any idea or way to debug the problem.
>
> He who has the code, can debug; he who doesn't have the code,
> can only guess.
> br,
> Bruno
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> iText-questions mailing list
> iText-questions@...
> 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 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

200800016.pdf (84K) Download Attachment
200800016Wrong.pdf (85K) Download Attachment

Re: Change of font/size

by Bruno Lowagie (iText) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Looking at your code, there are still many possible causes:

Pierre Gilquin wrote:
>     private static Font grasFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, new Color(0, 0, 0));

This is a private static variable; can you make it a constant?
How to make sure it's not changed somewhere else in that (incomplete)
class file you've sent us.

This part could be written in a cleaner way:
>         Paragraph paragraphDocteurs = new Paragraph(
>             "Service de Pharmacologie et Toxicologie cliniques\n",
>             stFont);
>         Phrase el2 = new Phrase(
>             "Centre d'informations thérapeutiques et de pharmacovigilance\n",
>             grasFont);
>         paragraphDocteurs.add(el2);
>         document.add(paragraphDocteurs);

Why are you working with \n and adding separate Phrases,
you risk less errors if you create Paragraphs instead of Phrases,
and add them to the document one by one. That's more efficient.
However, if this is the cause of the problem, you must be using
different iText versions and experience some font propagation
problem. Without the PDFs, we can't check the document properties
to find out if you're really using the same iText version.

But most of all, I'd like to see the content stream, more specifically
the operand used with the operator that sets the font and size.

br,
Bruno


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

Re: Change of font/size

by Pierre G :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You are right, I made a stupid mistake and the font is changed somewhere else !
Thanks for your help and advices.

Pierre

----- Original Message -----
From: "Bruno Lowagie" <bruno@...>
To: "Post all your questions about iText here" <itext-questions@...>
Sent: Friday, May 16, 2008 11:50 AM
Subject: Re: [iText-questions] Change of font/size


Looking at your code, there are still many possible causes:

Pierre Gilquin wrote:
>     private static Font grasFont = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD, new Color(0, 0, 0));

This is a private static variable; can you make it a constant?
How to make sure it's not changed somewhere else in that (incomplete)
class file you've sent us.

This part could be written in a cleaner way:
>         Paragraph paragraphDocteurs = new Paragraph(
>             "Service de Pharmacologie et Toxicologie cliniques\n",
>             stFont);
>         Phrase el2 = new Phrase(
>             "Centre d'informations thérapeutiques et de pharmacovigilance\n",
>             grasFont);
>         paragraphDocteurs.add(el2);
>         document.add(paragraphDocteurs);

Why are you working with \n and adding separate Phrases,
you risk less errors if you create Paragraphs instead of Phrases,
and add them to the document one by one. That's more efficient.
However, if this is the cause of the problem, you must be using
different iText versions and experience some font propagation
problem. Without the PDFs, we can't check the document properties
to find out if you're really using the same iText version.

But most of all, I'd like to see the content stream, more specifically
the operand used with the operator that sets the font and size.

br,
Bruno


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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

Re: Change of font/size

by Bruno Lowagie (iText) :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Pierre Gilquin wrote:
> Thanks for your help and advices.

You're welcome, thanks for the feedback.
Coming up next: the CellHeight examples sent by Glen Hamel.
I had scheduled a release for today, but if the problem
reported by Glen is a bug, I'll postpone the release till
it's fixed.
br,
Bruno

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
iText-questions mailing list
iText-questions@...
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