FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Rpreview issues - PDF
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: Rpreview issues - PDF

Posted: Mon May 06, 2019 09:58 AM
I use libHaru for EMF 2 PDF, here https://github.com/APerricone/emf2pdf but the support is limited of what I need :-)

see https://github.com/APerricone/emf2pdf/blob/master/FWH_Test/main.prg
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Rpreview issues - PDF

Posted: Mon May 06, 2019 10:01 AM
AntoninoP wrote:I use libHaru for EMF 2 PDF, here https://github.com/APerricone/emf2pdf but the support is limited of what I need :-)

see https://github.com/APerricone/emf2pdf/blob/master/FWH_Test/main.prg

I have seen mastintin's reference to your post.
Later he said he tested and it is not fully developed.
We have not tried it yet.
Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: Rpreview issues - PDF

Posted: Mon May 06, 2019 10:08 AM

Ops. instead I missed the mastintin's reference :lol:
I made some modification at the library because this thread, and now the example is working.
In our program we use this lib to convert reports to pdf, so the support is limited.

@maustin what did you try to crash the exporter?

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 07:59 AM
AntoninoP, Add this in your code ...
Code (fw): Select all Collapse
void Emf2Pdf::ParseFile()
.....
  case EMR_RECTANGLE:         nRead += Rectangle(); break;
....

Code (fw): Select all Collapse
size_t Emf2Pdf::Rectangle()
{
   RECTL bound;
   fread(&bound, 4, 4, f);
   float x = bound.left * xScale  ;
   float y = currHeight - bound.bottom * yScale ;
   float rx = ( bound.right - bound.left) * xScale ;
   float ry = (bound.bottom - bound.top) * yScale ;

   HPDF_Page_Rectangle(page, x, y, rx,  ry ) ;


   if (currentPen.width > 0 && currentBrush.solid)
   {
      HPDF_Page_FillStroke(page);
   }
   else if (currentPen.width > 0)
   {
      HPDF_Page_Stroke(page);
   }
   else if (currentBrush.solid)
   {
      HPDF_Page_Fill(page);
   }

   return 16;
}

:-)
Saludos.
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 08:27 AM

If we use this code, may I know what libraries we need to link to our application?

Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 08:50 AM
@Maustin done, have you tried it? I will do a test ASAP.

@Nages It uses libHaru, with hbmk2 it is enough add hbhpdf.hbc, see this hbmk2 project file
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 09:06 AM
AntoninoP wrote:@Maustin , have you tried it? I will do a test ASAP.

Yes. I've tried it with a simple listing.
pdf generate

preview original
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 09:18 AM

Can one of you be kind enough to do me favour?
I posted a sample program on the 1st page of this post.
Can pdf be generated from that program and post a screen-shot and also let us know the size of pdf file.
That would be very educative for many of our users.

Next question:
If FWH uses this function, no application can be built with FWH without linking with libharu.lib.
Can FWH distribute libharu.lib with its distribution?

Or should this function be made available to users to use it at their choice and in that case they will obtain libharu.lib and link

Regards



G. N. Rao.

Hyderabad, India
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 09:27 AM
The result pdf is 4636 byte

more than the png :-)

personally, I would prefer to decide whether to include libharu or not
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 09:56 AM

Nages...
1.- libHaru is a free, cross platform, open source library for generating PDF files. ... from http://libharu.org/
2.- hbpdf library is in harbour/contrib .

3.- According to AntoninoP , I would prefer to decide whether or not to include libharu.

use this is a good idea to force the use depending on the case :

TPreview():bSaveAsPDF := {|o| TPrinter2PDF(o:oDevice)}
PRINT oPrn PREVIEW

4.- still work in the process to generate pdf from emf.
I would not say that it is usable in production for all cases, only for the simplest.

Missing the roundrectangles, insertion of images (especially bmp), etc, etc.
For text and lines it is valid but they would lack color of lines, shadows etc

It's a very good idea that you lack development (time) :-)

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 10:10 AM
The results are EXCELLENT !!!
File size is very small. Better than the pdf created by MsWord.

4.- still work in the process to generate pdf from emf.
I would not say that it is usable in production for all cases, only for the simplest.

I do not understand. Can you please clarify?
It is enough for us if it can embed an array of emf files into a multipage pdf.
We do not need anything more for our work.

For example:
XBROWSER "customer.dbf"
If this preview is saved as pdf, that should be fine for us. Do you agree?

We need to study the licensing terms about including the library.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 10:46 AM
Nages ...

Here the emf is not embedded in the pdf.
Here the code analyze the content of the emf and convert it to pdf format.

For example: The emf is analyzed and a text is found, this text is passed to pdf text (with all the advantages of size and possibility of searching).
It is a Rectangle is passed to rectangle pdf ... etc.

But if the preview has a bitmap logo? ... this is not yet implemented ( I think, ), so it would not work ...
He also seems to have problems with some character such as the €

See this :


Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 11:01 AM

Oh, I see.

I thought the emf is embedded into pdf as an image. That is what we require.
The image in emf may contain text, drawings, images, even totally unknown Unicode chars.

Hope our expert Mr. AntonioP can throw some light on this.

Regards



G. N. Rao.

Hyderabad, India
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 11:10 AM
For a long time I also use Harupdf from Carlos Mora lib: https://bitbucket.org/carlos_mora/pdfprinter, with some modifications of Manuel, to print pdfs on FivEdit with fantastic results



I did not know about Antonino's work, and I'm also going to try it
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: Rpreview issues - PDF

Posted: Wed May 08, 2019 11:44 AM

It is possible to embed an image in harupdf (jpg, png).
You can convert the emf in jpg or better in png, but this is where we lose quality and generate a very large pdf, and the text is not text is image.
The result would be similar to what we have now, only change Tpdf() code for Harupdf code ...
Regards