#1 2020-11-28 14:41:02

Zink
Member
Registered: 2020-11-28
Posts: 10

why some text is missing when export report into a pdf file?

Hi!

I use quickreport to build the report  and use treachedit to build a report wid 14 pages.
So far so good!!  i use win7 but some my client use win10 and, not all, some are tolde me that some text info is missing in that pdf files!
When i make a preview from quickreport all info still there 100% perfect but when export into pdf some info text missing!!
my clients have to try several tryes and with the 4ird attemt the report in pdf rises perfect!

i use this  code:

procedure ExportToPDF1();
var
  // variáveis necessárias para a geração do PDF
  oPDF: TPDFDocument;
  oMetaDados: TMetafile;
  oPosicionamento: TPDFCanvasRenderMetaFileTextPositioning;
  nPagina: integer;
  ano,programpath,filetosave:string;
  SearchRec : TSearchRec;
begin
  // cria uma instância do documento PDF
  oPDF := TPDFDocument.Create(True, 0, False, nil);

  // inicializa a variável de metadados
  oMetaDados := nil;
  try
    // configura o tipo do papel
    oPDF.DefaultPaperSize := psA4;

    // configura o posicionamento dos caracteres
    //oPosicionamento := tpKerningFromAveragePosition;
      oPosicionamento :=tpExactTextCharacterPositining;
    // configura o layout de visualização do documento
    oPDF.Root.PageLayout := plOneColumn;

    // ajusta a orientação do documento, caso o relatório esteja em paisagem
    if printc.QuickRep1.Page.Orientation = poLandscape then
    begin
      oPDF.DefaultPageLandscape := True;
    end;

    // prepara o relatório
    printc.QuickRep1.Prepare;

    // carrega os metadados de cada página do relatório
    for nPagina := 1 to printc.QuickRep1.QRPrinter.PageCount do
    begin
      // adiciona uma nova página no documento
      oPDF.AddPage;

      // carrega os metadados da página
      oMetaDados := printc.QuickRep1.QRPrinter.GetPage(nPagina);

      // renderiza os metadados
      oPDF.Canvas.RenderMetaFile(oMetaDados, 1, 0, 0, 1, oPosicionamento);

      // limpa a variável de metadados
      oMetaDados := nil;
    end;


    // salva o arquivo
     programpath := ExtractFilePath( Application.ExeName );



try
   FindFirst(programpath+'\tempdf*.*', faAnyFile, SearchRec);
   repeat
    DeleteFile(programpath+'\' + SearchRec.name);
   until FindNext(SearchRec) <> 0;
finally
   FindClose(SearchRec);
end;


  try
   if FindFirst(programpath+'\tempdf*.*', faAnyFile, SearchRec)=0 then
   begin
    repeat


    until FindNext(SearchRec) <> 0;
   filetosave:=copy(searchrec.Name,pos('_',searchrec.Name)+1,(pos('.',searchrec.Name)-(pos('_',searchrec.Name)+1)));
   filetosave:='tempdf_'+floattostr(strtofloat(filetosave)+1);
   end
    else
     begin
      filetosave:='tempdf_0';
     end;
finally
   FindClose(SearchRec);
end;

     
    oPDF.SaveToFile(programpath+'\'+filetosave+'.pdf');
    programpath:=programpath+'\'+filetosave+'.pdf' ;
    ShellExecute(Handle, 'open',Pchar(programpath),nil,nil,SW_SHOWNORMAL) ;

  finally

    // libera as variáveis
    oMetaDados.Free;
    oPDF.Free;

  end;
end;

Offline

#2 2020-11-28 21:13:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,736
Website

Re: why some text is missing when export report into a pdf file?

Hello and Welcome

Please follow the forum rules and don't post directly the code in the posts, but linked in a web site like Gist.
https://synopse.info/forum/misc.php?action=rules

Offline

#3 2020-11-28 23:03:19

Zink
Member
Registered: 2020-11-28
Posts: 10

Re: why some text is missing when export report into a pdf file?

Hi! i didnt know that i was not follow rules!!

can you help me?

Offline

Board footer

Powered by FluxBB