WPCubed Product Support

PDFExport generating messy pdf file!

support

Hi,

I see you are using

wpAuxiliar := TWPRichText.Create(wpAuxiliar);

That is not ideal. It won't work in a thread.

my usual suggestion is

wpAuxiliar := TWPCustomRTFEdit.CreateDynamic;

and don't forget

wpAuxiliar.ReformatAll; // 1.
wpAuxiliar.ReformatAll; // 2.

before any print or PDFing.

Julian

#4 ♥ 0
7.8k Views 2 users read 3 min

@wpsupport:
Hi,

I never came accross such a problem, esspecially not when exporting from WPTools. Did I understand correctly that the PDF looks different when you open it in on the desctop or download from the server?

Maybe the component uses CanvasReference set to Printer but the server does not have any?

Julian

Hi! Julian, the problem is not that. I'll try to explain better, but my english isn't so good.

This is the code I'm using to generate the pdf file:

wp_internet.Clear;         wp_internet.CheckHasBody;         GeraResultado(wp_resultado, CodPedido, CodExame);         SetaConfigPaginaNet(wp_internet);         wp_internet.AsString  := wp_resultado.AsString;         CabecalhoRodapeNet(wp_internet, CodPedido, CodExame);         wp_internet.Refresh;         WPPDFExport1.Source   := wp_internet;         WPPDFExport1.Filename := NetParametros.DiretorioTemp+'\result.pdf';         WPPDFExport1.Print;

The procedures I'm using:

procedure CabecalhoRodapeNet(var wpEditor: TWPRichText; CodigoPedido, CodigoExame: String);
var wpAuxiliar: TWPRichText;
    i: Integer;
    Lista: TStringList;
begin
   CarregaCabRod(CodigoPedido, CodigoExame);
   Lista      := TStringList.Create;
   wpAuxiliar := TWPRichText.Create(wpAuxiliar);

   {Cabeçalho}
   wpAuxiliar.AsString := NetParametros.TextoCabecalho;
   GetTagList(wpAuxiliar, Lista);
   for i := 0 to Lista.Count-1 do
      ReplaceTags(wpAuxiliar, Lista[i], dmsis.t_cabrod.FieldByName(Lista[i]).AsString);
   wpEditor.HeaderFooter.Get(wpIsHeader, wpraOnAllPages,'').RTFText.AsString  := wpAuxiliar.AsANSIString('WPTOOLS');

   {Rodapé}
   wpAuxiliar.Clear;
   wpAuxiliar.AsString := NetParametros.TextoRodape;
   GetTagList(wpAuxiliar, Lista);
   for i := 0 to Lista.Count-1 do
      ReplaceTags(wpAuxiliar, Lista[i], dmsis.t_cabrod.FieldByName(Lista[i]).AsString);
   wpEditor.HeaderFooter.Get(wpIsFooter, wpraOnAllPages,'').RTFText.AsString  := wpAuxiliar.AsANSIString('WPTOOLS');

   Lista.Free;
   wpAuxiliar.Free;
end;

The wp_internet has the final formated text. When I preview it, all lokks good! But the pdf file generated from wp_internet not. It looks all messeu up. One thing I forget to mention: my header have a logo (bitmap). The final pdf file show only the logo, but incomplete and with very bigger height!!

Can yopu help me?

Thanks

#3 ♥ 0
support

Hi,

I never came accross such a problem, esspecially not when exporting from WPTools. Did I understand correctly that the PDF looks different when you open it in on the desctop or download from the server?

Maybe the component uses CanvasReference set to Printer but the server does not have any?

Julian

#2 ♥ 0

Hi! I'm using wPDFExport do generate a pdf file from WPRichText. Here is the code I'm using to do that:

wp_internet.AsString := wp_result.AsString; 
 wp_internet.Refresh;
 WPPDFExport1.Source   := wp_internet;
 WPPDFExport1.Filename := NetParams.TempDir+'\result.pdf';
 WPPDFExport1.Print;

When a preview the wp_internet, it looks ok. But, the pdf file generated it's all messed, with larger fonts, and very big spaces between lines, as it was in other resolution. I've tried many changes in the code, but none seems to work. What I'm doing wrong??

Thanks

#1 ♥ 0