Help with PDF in FWH-19.09 please. - SOLVED

Help with PDF in FWH-19.09 please. - SOLVED

Postby Cgallegoa » Tue Dec 03, 2019 1:07 am

Hello friends,

I updated to FWH-19.09 but I have a couple of problems with PDF generation from PREVIEW.

The process is:
1.- An invoice is generated
2.- It is sent to print (electronic invoicing) and the PDF, that will be validated via SOAP / WSDL and sent to the client, should be automatically generated.
3.- Sometimes it is necessary to reprint the invoices from the PREVIEW, and from there, the PDF is generated manually.

This works perfect if PDFs are forced to be generated directly, WITHOUT using HaruPDF or MsWord, but the internal class of FWH. The problem
is that the resulting PDFs weigh too much.

To avoid using HaruPDF or MsWord I make the following changes;
a.- Disable "#define USEGDI" in PRV2PDF.PRG and change
Code: Select all  Expand view  RUN
CLASSDATA bSaveAsPDF INIT {| Self | :: SaveAs (.t.)}

by
Code: Select all  Expand view  RUN
CLASSDATA bSaveAsPDF INIT {| Self | FWSavePreviewToPDF (Self)}

It works well, but generates very large PDFs, and for electronic invoicing small PDFs are required.

Ideally, HaruPDF or MsWord should be used, but in doing so, following the instructions in the "WhatsNew.txt" of FWH-19.09 the following problem occurs:

1.- The PDF is distorted and does not paint the color of the logos.
To solve it without making changes to the classes in FWH-19.09, when generating the invoice and putting the logo, I put RASTER at 0
Code: Select all  Expand view  RUN
// nRaster: = SRCAND: = 8913094
nRaster: = 0
xaCoord: = oPrn: CmRect2Pix ({1.45, 1.78, 5.20, 1.02})
oPrn: SayImage (xaCoord [1], xaCoord [2], cLogo, xaCoord [3], xaCoord [4], nRaster)
 


Although the logos (shape and color) are drawn well, it randomly generates micro PDFs.

I've tried everything, but I can't find a solution. Any suggestions of what I need or what am I doing wrong will be eternally grateful

Good quality - bad weight 584Kb
Image

Good weight 202Kb - bad quality
Image

Micro PDF
Image

For information, the same document, with PDFCREATOR, with very good quality, weighs only 32Kb

Thanks and regards
Last edited by Cgallegoa on Wed Dec 04, 2019 10:23 pm, edited 1 time in total.
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Help with PDF in FWH-19.09 please.

Postby nageswaragunupudi » Tue Dec 03, 2019 11:10 am

By default FWH1909 exactly behaves like FWH1906.

In other words, FWH1909 does not at all use HaruPDF by default.

To avoid usine MS Word, you need not change rpreview.prg like this as youd did.
CLASSDATA bSaveAsPDF INIT {| Self | :: SaveAs (.t.)}
by
CLASSDATA bSaveAsPDF INIT {| Self | FWSavePreviewToPDF (Self)}


Keep rpreview.prg without any changes
and
add this line of code in your application program at any place before the print function.

Code: Select all  Expand view  RUN

TPreview():bSaveAsPDF := { |o| FWSavePreviewToPDF(o) }
 


After this, all previews generate will use the internal function of FWH, but not MSWord.

In other words, for generating PDF from Preview, you should not find any difference in behavior by upgrading to FWH1909.

Next, let us look into what is the best way to generate PDFs in your case.

With FWH1909 we have 3 options (1) FWH Internal (2) MSWord (3) HaruPDF

In our tests...
1) FWH Internal: Reasonable quality but very large files.
2) MSWord: Better quality and reasonably smaller size
Limitations: Does not support vertical fonts.
You brought out the issues of MicroPDF which we did not come across and we would like to test more.
3) HaruPDF: Better than (1) and (2) but with some limitations:
No Unicode support. For English this is ok.
The choice of fonts is limited.
But these two are not big limitations in most cases.
Most importantly you need to use the latest print functions.

We advise you to first test fwh\samples\pdfharu1.prg, pdfharu2.pdf, print01.prg, print02.prg and pring03.prg.
All these programs let you test the outputs with (1) fwh internal (2) MSWord (3) HaruPDF and also (4) Image2PDF.
Study and compare the outputs.
Study the recommended way to print images and barcodes. (important for you)

Still, if you are not fully clear, please share one sample print program with us on our personal email and we will help you to optimize it.

First please study the above samples in detail. Both outputs and program code.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10653
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Help with PDF in FWH-19.09 please.

Postby cnavarro » Tue Dec 03, 2019 9:27 pm

Little by little it will improve and add new features
Fivedit use HaruPdf for save as pdf

Image
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Help with PDF in FWH-19.09 please.

Postby Cgallegoa » Wed Dec 04, 2019 10:23 pm

Rao, Cristobal,

Thank you for your interest.

Already solved. Incompatibility in xHarbour's AnsiToWide function:

In PRV2PDF, the Emf2Jpeg () function is invoked, which in turn calls GDIPLUSEMFTOJPG as follows:
Code: Select all  Expand view  RUN
GDIPLUSEMFTOJPG (cBuf, Len (cBuf), AnsiToWide (cJpeg), 5)

That line was randomly generating a wrong extension to the jpg file on which the pdf is built. After the extension, the function added strange characters (possibly Chinese).

I solved it with the following change:
Code: Select all  Expand view  RUN
GDIPLUSEMFTOJPG (cBuf, Len (cBuf), AnsiToWide (cJpeg + Chr (0)), 5)

Apparently it works perfect.

A big hugs and thansk for your help,
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 494
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 99 guests