Changes between Version 2 and Version 3 of GritsTutorial_PDFGeneration


Ignore:
Timestamp:
02/06/2015 07:29:48 PM (7 years ago)
Author:
sena
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GritsTutorial_PDFGeneration

    v2 v3  
    3030
    3131PDFGenerator.drawMultilineString must be used for any text field that might contain line breaks or a text that might span several lines in the output document (such as "description" above). Another essential step when using drawMultiLineString is to reinitialize the current page (you have to pass this page to all the methods that adds text to the document) to the last page of the document since while drawing several lines of text, a new page might have been created. This step is shown in the above code.
     32
     33If you need to write text on the same line with another piece of text, you can use PDFGenerator's writeTextOnTheSameLine method. It returns the vertical position of the space after the last letter of the text. You should use this "x" index as the "MARGIN" parameter of writeSimpleText or another text drawing method (drawMultiLineString, writeTextOnTheSameLine) to continue writing on the same line. writeTextOnTheSameLine can also underline the text if the last parameter is set to true.
     34
     35{{{
     36       float x = PDFGenerator.writeTextOnTheSameLine (document, page, "Name:", TEXT_FONT, FONT_SIZE, MARGIN, yIndex, true);
     37       yIndex = PDFGenerator.writeSimpleText(document, page, project.getDisplayName(), TEXT_FONT, FONT_SIZE, x, yIndex);
     38}}}
    3239
    3340=== Table Generation ===