Rpreview issues - PDF

Re: Rpreview issues - PDF

Postby AntoninoP » Mon May 06, 2019 9: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
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Rpreview issues - PDF

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rpreview issues - PDF

Postby AntoninoP » 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?
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Rpreview issues - PDF

Postby mastintin » Wed May 08, 2019 7:59 am

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.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Rpreview issues - PDF

Postby nageswaragunupudi » Wed May 08, 2019 8: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rpreview issues - PDF

Postby AntoninoP » Wed May 08, 2019 8: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
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Rpreview issues - PDF

Postby mastintin » Wed May 08, 2019 9: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
Image
preview original
Image
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Rpreview issues - PDF

Postby nageswaragunupudi » Wed May 08, 2019 9: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rpreview issues - PDF

Postby AntoninoP » Wed May 08, 2019 9:27 am

The result pdf is 4636 byte
Image
more than the png :)

personally, I would prefer to decide whether to include libharu or not
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Rpreview issues - PDF

Postby mastintin » Wed May 08, 2019 9: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) :-)
Last edited by mastintin on Wed May 08, 2019 10:11 am, edited 1 time in total.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Rpreview issues - PDF

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rpreview issues - PDF

Postby mastintin » 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 :

Image
Image
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Rpreview issues - PDF

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rpreview issues - PDF

Postby cnavarro » 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

Image

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
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Rpreview issues - PDF

Postby mastintin » 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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests