Page 3 of 4

Re: Rpreview issues - PDF

PostPosted: Mon May 06, 2019 9:58 am
by AntoninoP
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

Re: Rpreview issues - PDF

PostPosted: Mon May 06, 2019 10:01 am
by nageswaragunupudi
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.

Re: Rpreview issues - PDF

PostPosted: Mon May 06, 2019 10:08 am
by AntoninoP
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?

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 7:59 am
by mastintin
AntoninoP, Add this in your code ...
Code: Select all  Expand view


void Emf2Pdf::ParseFile()
.....
  case EMR_RECTANGLE:         nRead += Rectangle(); break;
....

 

Code: Select all  Expand view

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.

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 8:27 am
by nageswaragunupudi
If we use this code, may I know what libraries we need to link to our application?

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 8:50 am
by AntoninoP
@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

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 9:06 am
by mastintin
AntoninoP wrote:@Maustin , have you tried it? I will do a test ASAP.

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

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 9:18 am
by nageswaragunupudi
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

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 9:27 am
by AntoninoP
The result pdf is 4636 byte
Image
more than the png :)

personally, I would prefer to decide whether to include libharu or not

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 9:56 am
by mastintin
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) :-)

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 10:10 am
by nageswaragunupudi
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.

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 10:46 am
by mastintin
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 :

Image
Image

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 11:01 am
by nageswaragunupudi
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.

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 11:10 am
by cnavarro
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

Image

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

Re: Rpreview issues - PDF

PostPosted: Wed May 08, 2019 11:44 am
by mastintin
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