ajuda com quebra de texto em relatório auguem poderia me ajudar com quebra de linha em um relatório tabular?? tenho a seguinte informação. rua xxxxxxx completo xxxxxx cidade xxxxxx cep ( xxxxxx ) destinatário xxxxxxxxxxxxxxxxxx preciso que fique assim no banco já esta gravando desta forma mais na hora de gerar o pdf sai tudo em uma linha só rua xxxxxxx completo xxxxxx cidade xxxxxx cep ( xxxxxx ) destinatário xxx...
VC
ajuda com quebra de texto em relatório  
auguem poderia me ajudar com quebra de linha em um relatório tabular??

tenho a seguinte informação.

rua xxxxxxx
completo xxxxxx
cidade xxxxxx cep ( xxxxxx )
destinatário xxxxxxxxxxxxxxxxxx

preciso que fique assim no banco já esta gravando desta forma mais na hora de gerar o pdf sai tudo em uma linha só

rua xxxxxxx completo xxxxxx cidade xxxxxx cep ( xxxxxx ) destinatário xxxxxxxxxxxxxxxxxx

poderiam me ajudar por favor

Curso Dominando o Adianti Framework

O material mais completo de treinamento do Framework.
Curso em vídeo aulas + Livro completo + Códigos fontes do projeto ERPHouse.
Conteúdo Atualizado!


Dominando o Adianti Framework Quero me inscrever agora!

Comentários (16)


FC

Poste seu código.
VC

SEGUE O MEU CÓDIGO

 
  1. <?php
  2. /**
  3. * MaxTrocasReport Report
  4. * @author <your name here>
  5. */
  6. class MaxTrocasReport extends TPage
  7. {
  8. protected $form; // form
  9. protected $notebook;
  10. /**
  11. * Class constructor
  12. * Creates the page and the registration form
  13. */
  14. function __construct()
  15. {
  16. parent::__construct();
  17. // creates the form
  18. $this->form = new TQuickForm('form_MaxTrocas_report');
  19. $this->form->class = 'tform'; // change CSS class
  20. $this->form->style = 'display: table;width:90%'; // change style
  21. // define the form title
  22. $this->form->setFormTitle('MaxTrocas Report');
  23. // create the form fields
  24. $data_post = new TDate('data_post');
  25. $output_type = new TRadioGroup('output_type');
  26. // add the fields
  27. $this->form->addQuickField('Data Post', $data_post, 50 );
  28. $this->form->addQuickField('Output', $output_type, 90 , new TRequiredValidator);
  29. $output_type->addItems(array('html'=>'HTML', 'pdf'=>'PDF', 'rtf'=>'RTF'));;
  30. $output_type->setValue('pdf');
  31. $output_type->setLayout('horizontal');
  32. // add the action button
  33. $this->form->addQuickAction(_t('Generate'), new TAction(array($this, 'onGenerate')), 'fa:cog blue');
  34. // vertical box container
  35. $container = new TVBox;
  36. $container->style = 'width: 90%';
  37. // $container->add(new TXMLBreadCrumb('menu.xml', __CLASS__));
  38. $container->add($this->form);
  39. parent::add($container);
  40. }
  41. /**
  42. * Generate the report
  43. */
  44. function onGenerate()
  45. {
  46. try
  47. {
  48. // open a transaction with database 'maxseller'
  49. TTransaction::open('maxseller');
  50. // get the form data into an active record
  51. $formdata = $this->form->getData();
  52. $repository = new TRepository('MaxTrocas');
  53. $criteria = new TCriteria;
  54. if ($formdata->data_post)
  55. {
  56. $criteria->add(new TFilter('data_post', 'like', "%{$formdata->data_post}%"));
  57. }
  58. $objects = $repository->load($criteria, FALSE);
  59. $format = $formdata->output_type;
  60. if ($objects)
  61. {
  62. $widths = array(100,100,100,100,50,100,100);
  63. switch ($format)
  64. {
  65. case 'html':
  66. $tr = new TTableWriterHTML($widths);
  67. break;
  68. case 'pdf':
  69. $tr = new TTableWriterPDF($widths);
  70. $designer = new TPDFDesigner;
  71. break;
  72. case 'rtf':
  73. if (!class_exists('PHPRtfLite_Autoloader'))
  74. {
  75. PHPRtfLite::registerAutoloader();
  76. }
  77. $tr = new TTableWriterRTF($widths);
  78. break;
  79. }
  80. // create the document styles
  81. $tr->addStyle('title', 'Arial', '10', 'B', '#ffffff', '#9898EA');
  82. $tr->addStyle('datap', 'Arial', '10', '', '#000000', '#EEEEEE');
  83. $tr->addStyle('datai', 'Arial', '10', '', '#000000', '#ffffff');
  84. $tr->addStyle('header', 'Arial', '16', '', '#ffffff', '#494D90');
  85. $tr->addStyle('footer', 'Times', '10', 'I', '#000000', '#B1B1EA');
  86. // add a header row
  87. $tr->addRow();
  88. $tr->addCell('MaxTrocas', 'center', 'header', 7);
  89. // add titles row
  90. $tr->addRow();
  91. // controls the background filling
  92. $colour= FALSE;
  93. // data rows
  94. foreach ($objects as $object)
  95. {
  96. $style = $colour ? 'datap' : 'datai';
  97. $tr->addRow('', 'left', $style);
  98. $tr->addCell('Venda', 'left', 'title');
  99. $tr->addCell($object->venda, 'left', $style);
  100. $tr->addRow();
  101. $tr->addCell('Conta', 'left', 'title');
  102. $tr->addCell($object->conta, 'left', $style);
  103. $tr->addRow();
  104. $tr->addCell('Produto', 'left', 'title');
  105. $tr->addCell($object->produto, 'left', $style);
  106. $tr->addRow();
  107. $tr->addCell('Motivo', 'left', 'title');
  108. $tr->addCell($object->motivo, 'left', $style);
  109. $tr->addRow();
  110. $tr->addCell('Data', 'left', 'title');
  111. $tr->addCell($object->data_post, 'left', $style);
  112. $tr->addRow();
  113. $tr->addCell('Endereço', 'left', 'title');
  114. $tr->addCell($object->campo_end, 'left', $style);
  115. $tr->addRow();
  116. $tr->addCell('Rastreio', 'left', 'title');
  117. $tr->addCell($object->rastreio, 'left', $style);
  118. $tr->addRow();
  119. $tr->addRow('', 'left', $style);
  120. $colour = !$colour;
  121. }
  122. // footer row
  123. $tr->addRow();
  124. $tr->addCell(date('Y-m-d h:i:s'), 'center', 'footer', 7);
  125. // stores the file
  126. if (!file_exists("app/output/MaxTrocas.{$format}") OR is_writable("app/output/MaxTrocas.{$format}"))
  127. {
  128. $tr->save("app/output/MaxTrocas.{$format}");
  129. }
  130. else
  131. {
  132. throw new Exception(_t('Permission denied') . ': ' . "app/output/MaxTrocas.{$format}");
  133. }
  134. // open the report file
  135. parent::openFile("app/output/MaxTrocas.{$format}");
  136. // shows the success message
  137. new TMessage('info', 'Report generated. Please, enable popups.');
  138. }
  139. else
  140. {
  141. new TMessage('error', 'No records found');
  142. }
  143. // fill the form with the active record data
  144. $this->form->setData($formdata);
  145. // close the transaction
  146. TTransaction::close();
  147. }
  148. catch (Exception $e) // in case of exception
  149. {
  150. // shows the exception error message
  151. new TMessage('error', '<b>Error</b> ' . $e->getMessage());
  152. // undo all pending operations
  153. TTransaction::rollback();
  154. }
  155. }
  156. }
  157. </code>


</your>
FC

Seu campo endereço, é um único campo? $object->campo_end vai precisar separar isso.
VC

o campo que eu preciso formatar é o campo_ end

$tr->addRow(); $tr->addCell('Endereço', 'left', 'title'); $tr->addCell($object->campo_end, 'left', $style);


eu jogo os dados da seguinte forma


rua xxxxxxx
completo xxxxxx
cidade xxxxxx cep ( xxxxxx )
destinatário xxxxxxxxxxxxxxxxxx

no bando e nas grid normais ele fica da forma certa mais quando gero um relatório sai tudo em uma linha só
FC

troque o cell por MultiCell
VC

JÁ TENTEI MAIS DA ESTE ERRO

Fatal error: Call to undefined method TTableWriterPDF::addMultiCell() in C:wampwwwmaxsellerappcontrolmaxsellerMaxTrocasReport.class.php on line 146
FC

Tire o add a classe extende de FPDF então pode usar todos os recursos.
FC

Tire o add a classe extende de FPDF então pode usar todos os recursos.
VC

TIRO O ADD E DA O ERRO

Call to undefined method TTableWriterPDF::MultiCell() in C:wampwwwmaxsellerappcontrolmaxsellerMaxTrocasReport.class.php on line 146
FC

Desculpe não havia percebido que estava usando o tabular gerado pelo studio, para mim estava usando somente o FPDF, andei pesquisando e acredito que terá que usar somente o PDF para atingir esse resultado.
VC

E COMO FAÇO ISSO ESTOU COMEÇANDO AGORA E AINDA SOU MUITO LEIGO
NR

https://www.adianti.com.br/forum/pt/view_3772?quebrar-ttext-em-ttablewriterpdf
VC

NÃO ENTENDI MUITO BEM ONDE EU COLOCO ESTE CÓDIGO.
VC

NÃO ENTENDI MUITO BEM ONDE EU COLOCO ESTE CÓDIGO.
AC

Não existe algo tipo:

 
  1. <?php
  2. $tr->ln('15');
  3. ?>


????
NR

A função getNativeWriter vai retornar a instância da FPDF e aí você vai poder chamar a função multicell:
www.fpdf.org/en/doc/multicell.htm
 
  1. <?php
  2. $fpdf = $tr->getNativeWriter();
  3. $fpdf->multicell(....);
  4. ?>