Posts by marcioteixeira

    I need do conver a RTF file to PDF.

    Its works fine til I update the wPDF component to version 5.

    My RTF was created with WPTool6 from another application that we cant to update to WPTool9...

    But the result PDF generated - with RTF by WPTool6 e converted to PDF with wPDF5 - have font encode problems.

    Then I tried develeper a DLL with Delphi 12 - with WPTool9 and wPDF5 - where I get another problem: beffore the convertion, I need to put a image at the top of document, but the image dont appears in a PDF file. If I compile a test .exe app and try to execute the same code, it works fine, the image appears.

    Use the component in a DLL is a problem? I neep only the PDF convertion then I set visible = False;

    Example 1 (no access violation):

    procedure TConvertToPDF.Convert(pFileNameIn, pFileNameOut, pParams: PAnsiChar);
    var
     WPRichText : TWPRichText;
     WPPDFExport: TWPPDFExport;
    begin
    WPDF_Start(wPDFName, WPDFCode);

    WPRichText  := TWPRichText.Create(nil);
    try
     WPRichText.Visible            := False;
     WPRichText.LoadFromFile(pFileNameIn);
     WPRichText.ReformatAll();

     WPRichText.MovePosition(wpmHome, False);
     WPRichText.FastInsertParagraph;

     WPRichText.MovePosition(wpmHome, False);
     WPRichText.FastInsertParagraph;

     WPRichText.InsertGraphic('D:\Desenv\VilaRica\Docs\Logotipo\logo.bmp', False, []); // access violation here

     WPRichText.Refresh;

     // Export to PDF
     WPPDFExport := TWPPDFExport.Create(nil);
     try
       WPPDFExport.Source   := WPRichText;
       WPPDFExport.FileName := pFileNameOut;
       WPPDFExport.Print;
     finally
       FreeAndNil(WPPDFExport);
     end;
    finally
      FreeAndNil(WPRichText);
    end;
    end;

    Example 2 (no access violation, but no add the image):

    procedure TConvertToPDF.Convert(pFileNameIn, pFileNameOut, pParams: PAnsiChar);
    var
     WPRichText : TWPRichText;
     WPPDFExport: TWPPDFExport;
    begin
    WPDF_Start(wPDFName, WPDFCode);

    WPRichText  := TWPRichText.Create(nil);
    try
     WPRichText.Visible            := False;
     WPRichText.OnRequestHTTPImage := RequestHTTPImage;
     WPRichText.LoadFromFile(pFileNameIn);
     WPRichText.ReformatAll();

     WPRichText.MovePosition(wpmHome, False);
     WPRichText.FastInsertParagraph;

     WPRichText.MovePosition(wpmHome, False);
     WPRichText.FastInsertParagraph;

     WPRichText.InsertGraphic('D:\Desenv\VilaRica\Docs\Logotipo\logo.bmp', True, []);

     WPRichText.Refresh;

     // Export to PDF
     WPPDFExport := TWPPDFExport.Create(nil);
     try
       WPPDFExport.Source   := WPRichText;
       WPPDFExport.FileName := pFileNameOut;
       WPPDFExport.Print;
     finally
       FreeAndNil(WPPDFExport);
     end;
    finally
      FreeAndNil(WPRichText);
    end;
    end;

    procedure TConvertToPDF.RequestHTTPImage(RTFData: TWPRTFDataCollectionBase; Reader: TWPCustomTextReader; const LoadPath, url: string; TextObject: TWPTextObj; var Ok: Boolean);
    begin
    TextObject.LoadObjFromFile(url);

    Ok := True;
    end;

    Hi

    I want to update the last version avaiable of WPViewPDF on my Delphi 7 but appears an error: [Fatal Error] WPViewPDF_reg.pas(24): File not found: 'WinAPI.Windows.dcu';

    The error occurs at this point:

    uses  WPViewPDF3
     {$IFDEF WPVIEW4}
     , WinAPI.Windows

    I try to install the same version of WPViewPDF on Delphi 12 Athens and it works fine. But all of my applications are compiled with Delphi 7, I can't migrate at the moment.

    Is the current version compatible?