Rpreview issues - PDF

User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Rpreview issues - PDF

Post by TimStone »

Normally, I have been using IMG2PDF(.dll) from rPreview and it works well.

I only have this issue with one type of report = the Invoices where I added color. To make them work properly, I use the SayText( ) command rather than the Say( ) command.

This is the only place I've made this modification and all other reports work fine.

I'm wondering if anyone has ideas on wherein the problem may lay. Img2PDF works much better than the FWH method for creating PDF's.

Your suggestions / ideas / thoughts on what I should investigate on this will be greatly appreciated.
Last edited by TimStone on Mon Apr 22, 2019 6:54 pm, edited 1 time in total.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Rpreview issues - 19.03

Post by Antonio Linares »

Dear Tim,

Does this error occurs always or only from time to time ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Rpreview issues - PDF

Post by TimStone »

Antonio,

The error occurs when the Img2PDF .dll function IPMakePDF( ) is called. It happens every time. Please see my modified statement of the problem above.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Rpreview issues - PDF

Post by karinha »

João Santos - São Paulo - Brasil
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Rpreview issues - PDF

Post by nageswaragunupudi »

The incompatibility issue with img2pdf is observed only in one module
a) which uses SayText() and
b) uses color.

We need to find out if this compatibility problem is because of usage or color or usage of the method SayText(). We are unable to test this at our end because we are not in possession of img2pdf.

I would request Mr. Tim to kindly make a small program printing just two or three lines of text with color using normal Say() method only (without using SayText() ).
If img2pdf works fine with this, then the suspect is the method SayText() and we need to look into it.

We shall be grateful if Mr. Tim can help by doing this small test and inform the results.
Regards

G. N. Rao.
Hyderabad, India
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Rpreview issues - PDF

Post by vilian »

Hi Guys,

I also use img2pdf and have tried with :Say() AND :SayText() using colors different of CLR_BLACK and the pdf was generated right. I use this function to generate the pdf:

Code: Select all

FUNCTION BuildPDF( aFiles,pdfFilename )
LOCAL imageFilename := "   ",ix,iErr := 0,errorText := "  ",cArqTmp

   DEFAULT pdfFilename := RetArqTmp("PDF")+".pdf"

   hLib := LoadLib32( "Image2PDF StdCall.dll" )

   iErr := I2PDF_License( "xxx-xxxx-xxxxx-xxxxxx-xxxxxxx" )

   // Flag that his is a meta file
   iErr := I2PDF_MetaToNativePDF( )

   iErr := I2PDF_MetaTextFitBoundingRect()

   // Reset the size
   iErr := I2PDF_UseEMFDeviceSize( )

   // Build the pages using the array of temp files
   FOR ix := 1 TO LEN( aFiles )
      imageFilename := aFiles[ix]
      IF (iErr := I2PDF_AddImage(imageFilename)) # 0
         EXIT
      ENDIF
   NEXT

   // Set DPI to the default for PDF's.  It works better.
   iErr := I2PDF_SetDPI(0)

   // Create the PDF.
   iErr := I2PDF_MakePDF(Rtrim(pdfFilename), 0, errorText, 40 )

   FreeLib32( hLib )

RETURN( pdfFilename )

 
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Rpreview issues - PDF

Post by TimStone »

I use a similar script, but I tried yours. It won't recognize the .dll functions ... I would need how you redefined them to test the same code.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Rpreview issues - PDF

Post by vilian »

Hi TimStone,
Here is it:

Code: Select all

DLL32 STATIC FUNCTION I2PDF_License( cLicCode AS LPSTR) AS LONG;
   PASCAL FROM "I2PDF_License" LIB hLib

DLL32 STATIC FUNCTION I2PDF_MetaToNativePDF( ) AS LONG;
   PASCAL FROM "I2PDF_MetaToNativePDF" LIB hLib

DLL32 STATIC FUNCTION I2PDF_UseEMFDeviceSize( ) AS LONG;
   PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB hLib

DLL32 STATIC FUNCTION I2PDF_MetaTextFitBoundingRect( ) AS LONG;
   PASCAL FROM "I2PDF_MetaTextFitBoundingRect" LIB hLib

//  static unsigned int I2PDF_AddImage(char *image);
DLL32 STATIC FUNCTION I2PDF_AddImage( cImage AS LPSTR ) AS LONG;
   PASCAL FROM "I2PDF_AddImage" LIB hLib

//  static unsigned int I2PDF_SetDPI(unsigned int dpi);
DLL32 STATIC FUNCTION I2PDF_SetDPI( nDpi AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_SetDPI" LIB hLib

//   static unsigned int I2PDF_MakePDF(char *output, int options, char *errorText, unsigned int maxErrorTextSize);
DLL32 STATIC FUNCTION I2PDF_MakePDF( cOutFile AS LPSTR, nOptions AS LONG, cErrTxt AS LPSTR, nMaxESize AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_MakePDF" LIB hLib
 
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Rpreview issues - PDF

Post by TimStone »

Vilian,

I have tried your code which is almost identical to mine. The differences:

You use LoadLib32( ) and I'm using LoadLibrary( )
You are using the additional call: iErr := I2PDF_MetaTextFitBoundingRect()

When I run it with your setup, I get 7 pop-up boxes saying Error: 0. Loading: 0. and there is no error, but also no .pdf file is created.

I will look at this more this morning.

Mr. Rao,

This line will work correctly and allow a PDF to be created:

Code: Select all

 
 oPrn:Say( nRow, 4 * nCsp, MemoLine( m_labtxt, 60, lx,, .T. ), oFnorm )
 
This line will abort the entire application but displays no error message:

Code: Select all

 oPrn:SayText( nRow, 4 * nCsp, MemoLine( m_labtxt, 60, lx,, .T. ),,, oFnorm )
 
Tim
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Rpreview issues - PDF

Post by nageswaragunupudi »

Last night I chatted with Mr. Vilian and requested him to check both :Say() and :SayText(). He confirmed both working correctly to me in person and also in his post above. He is using bcc and I know you are using MSVC.

I searched and located the old evaluation version of image2pdf dll I downloaded in 2009 and tested with bcc and msvc using the code posted by Mr. Vilian.

This is my test program. Depending on the choice of the user, it creates PDF either by using the default (Word) or using FWH function or Image2PDF. I compiled using MSVC (2017) and did not encounter any runtime errors or problems.

Code: Select all

#include "fivewin.ch"

static hLib

//----------------------------------------------------------------------------//
#include "fivewin.ch"

function Main()

   local oPrn, oFont, nCh
   local oBrushRed, oBrushGreen

   nCh   := Alert( "Create PDF using", { "FWH", "WORD", "IMG2PDF" } )
   if nCh == 0
      return nil
   elseif nCh == 1
      TPreview():bSaveAsPDF := { |o| FWSavePreviewToPDF( o:oDevice ) }
   elseif nCh == 3
      TPreview():bSaveAsPDF := { |o| Image2PDF( o:oDevice:aMeta ) }
   endif

   PRINT oPrn PREVIEW

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-20 OF oPrn
   DEFINE BRUSH oBrushRed    COLOR CLR_HRED
   DEFINE BRUSH oBrushGreen  COLOR CLR_HGREEN

   PAGE

      @  300,100 PRINT TO oPrn TEXT "YELLOW ON RED"   SIZE 2000,200 PIXEL FONT oFont COLOR CLR_YELLOW,oBrushRed
      @  620,100 PRINT TO oPrn TEXT "DEFAULT COLORS"  SIZE 2000,200 PIXEL FONT oFont
      @  940,100 PRINT TO oPrn TEXT "BLUE ON GREEN"   SIZE 2000,200 PIXEL FONT oFont COLOR CLR_BLUE,  oBrushGreen
      @ 1260,100 PRINT TO oPrn TEXT "DEFAULT COLORS"  SIZE 2000,200 PIXEL FONT oFont
      @ 1580,100 PRINT TO oPrn TEXT "YELLOW ON RED"   SIZE 2000,200 PIXEL FONT oFont COLOR CLR_YELLOW,oBrushRed

      SetBkColor( oPrn:hDCOut, CLR_HRED )
      oPrn:Say(  300, 2600, "YELLOW ON RED", oFont, 2000, CLR_YELLOW, 2 )
      SetBkColor( oPrn:hDCOut, CLR_HGREEN )
      oPrn:Say(  940, 2600, "BLUE ON GREEN", oFont, 2000, CLR_BLUE,   2 )


   ENDPAGE
   ENDPRINT

   RELEASE FONT oFont
   RELEASE BRUSH oBrushRed, oBrushGreen

return nil

//----------------------------------------------------------------------------//

function Image2PDF( aMeta, cPdf, lView )

   local i, err

   DEFAULT cPDF   := cGetFile( "(*.pdf)|*.pdf|", "Select PDF File to Save",, ;
                               CurDir(), .T. )

   if Empty( cPdf )
      return nil
   endif

   hLib := LoadLib32( "Image2PDF StdCall.dll" )

// err := I2PDF_License( "xxx-xxxx-xxxxx-xxxxxx-xxxxxxx" )

   err  := I2PDF_MetaToNativePDF( )
   err  := I2PDF_MetaTextFitBoundingRect()
   err  := I2PDF_UseEMFDeviceSize( )
   for i := 1 TO Len( aMeta )
      if ( err  := I2PDF_AddImage( aMeta[ i ] ) ) != 0
         exit
      endif
   next
   err  := I2PDF_SetDPI( 0 )
   err  := I2PDF_MakePDF( cPdf, 0, "", 40 )

   FreeLib32( hLib )

   DEFAULT lView := MsgYesNo( "View " + cPdf + "?" )
   if lView
      ShellExecute( 0, "open", cPDF )
   endif

return ( cPdf )

//----------------------------------------------------------------------------//

DLL32 STATIC FUNCTION I2PDF_License( cLicCode AS LPSTR) AS LONG;
   PASCAL FROM "I2PDF_License" LIB hLib

DLL32 STATIC FUNCTION I2PDF_MetaToNativePDF( ) AS LONG;
   PASCAL FROM "I2PDF_MetaToNativePDF" LIB hLib

DLL32 STATIC FUNCTION I2PDF_UseEMFDeviceSize( ) AS LONG;
   PASCAL FROM "I2PDF_UseEMFDeviceSize" LIB hLib

DLL32 STATIC FUNCTION I2PDF_MetaTextFitBoundingRect( ) AS LONG;
   PASCAL FROM "I2PDF_MetaTextFitBoundingRect" LIB hLib

//  static unsigned int I2PDF_AddImage(char *image);
DLL32 STATIC FUNCTION I2PDF_AddImage( cImage AS LPSTR ) AS LONG;
   PASCAL FROM "I2PDF_AddImage" LIB hLib

//  static unsigned int I2PDF_SetDPI(unsigned int dpi);
DLL32 STATIC FUNCTION I2PDF_SetDPI( nDpi AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_SetDPI" LIB hLib

//   static unsigned int I2PDF_MakePDF(char *output, int options, char *errorText, unsigned int maxErrorTextSize);
DLL32 STATIC FUNCTION I2PDF_MakePDF( cOutFile AS LPSTR, nOptions AS LONG, cErrTxt AS LPSTR, nMaxESize AS LONG ) AS LONG;
   PASCAL FROM "I2PDF_MakePDF" LIB hLib
 
Note: @ r,c PRINT commands are translated to :SayText() calls.
You use LoadLib32( ) and I'm using LoadLibrary( )
When I used LoadLib32(), it is working correctly. When I changed to LoadLibrary() no pdf is generated but an hb_out.log file is generated with errors of crash.

Built using buildh32.bat:
Image


This is the print preview screen:
Image

By default, the preview generates PDF using MSWord if installed. This is the PDF generated using MSWord by default.
Image

This is the PDF generated using FWH own function:
Image

This is the PDF generated using Image2PDF (evaluation) DLL.
Image

Observations:
Quality:
Can be seen in the above images.

PDF File sizes:
Image2PDF generates very small PDF files.
Image

Handling of colors:
In the left column, text is printed using :SayText() over color background painted using color brush.
All three pdfs rendered these background colors.
In the right column, text is printed by the method Say() with the background color set by calling SetBkColor(). In this case, the background color is rendered by both FWH own function and MSWord. Image2PDF failed to display the background color totally.
Regards

G. N. Rao.
Hyderabad, India
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Rpreview issues - PDF

Post by vilian »

Some time ago, Adrian Nelson offered to us the source of img2pdf for only $199,00. Here is what he originally wrote in that email:
As you may have seen from the Utility Warrior web site earlier this year (which is no longer available) I made the decision to shut down operations and therefore there will be NO further updates or technical support available.

However, as you have previously purchased the Image2PDF Dynamic Link Library (DLL) you may be relying on it for your business and therefore you may be interested in purchasing the source code for this mature and stable utility.

Having a copy of this source code for your business will give you some degree of future protection as you (or any competent third party or contractor) will be able to make changes to this source code.

Let me know if you are interested in the source code or not and I can send you more information on this.

The source code cost was $299 at the time but I'll reduce it to $199 if you are interested and attached is the readme.txt file which describes the license with an overview of the source code and various open source components used.

The source code is written entirely in C and compiled with Visual Studio 2008 - I've had some customers take the source code and automatically upgrade the solution to use Visual Studio 2013 with no problem - and now of course there is the free Visual Studio Community 2017 which should also work.

If you're still interested I can give you the download link to the full source code ZIP for you to evaluate before purchase.

Of course you are not allowed to share the download link or source code with anyone outside of your company and if you decide not to purchase the license then you must delete the ZIP and all extracted files.


Best regards,
Adrian
I think this could be a very good improvement to FWH.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Rpreview issues - PDF

Post by TimStone »

My copy is dated October 2006. I wonder if there is a later version ? I don't think I tracked updates on it, but I do have a license key.

I appreciate all the research you both have done but I'm still having issues. I'm very puzzled but knowing it "should work" gives me the opportunity to keep trying to find the source of the problem.

What also puzzles me is that every time a function is called, it echoes the error status to me as I noted previously. These correspond to each call to the .dll. To me that is quite strange, but it only occurs with your implementation rather than my previous code. Also, it does not create the file ( .pdf ).

Of course, my method does work fine with the using the SAY() rather than the SayText(). Perhaps I just have an older version.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Rpreview issues - PDF

Post by vilian »

TimStone,

I don't know if your license key will work with the last version of the dll, but here (https://www.4shared.com/zip/YUN_SqHBfi/ ... dCall.html) is a link to download and try it. My version is of November/2007.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
TimStone
Posts: 2536
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA
Contact:

Re: Rpreview issues - PDF

Post by TimStone »

Thank you for the link. Yes my key does work with it. That resolves the error problems.

I still have some issues to resolve. What shows perfectly on the screen does not necessarily get accomplished in the PDF. For example I do have shaded rectangles and boxes that partially display in the pdf, but fully display on the view mode. I'll play with that.

If you want to give me an email address, I can send you the output so you see exactly what I mean.
Tim Stone
http://www.MasterLinkSoftware.com
timstone@masterlinksoftware.com
Using: FWH 19.06 with Harbour 3.2.0 / Microsoft Visual Studio Community 2019
User avatar
vilian
Posts: 795
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: Rpreview issues - PDF

Post by vilian »

TImStone,

Send to vilian@vfatec.com.br
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply