xsharp.eu • ReportPro3 PDF Export
Page 1 of 1

ReportPro3 PDF Export

Posted: Tue May 04, 2021 8:27 am
by HeikoP
Hello,

we found out, that exporting in a PDF creates a different size of the report compared to the result from an external PDF printer driver like Microsoft PDf or PDF24. It seems that the height is the same, but the width is a little smaller and the offset is moved to the left.

So if you would reprint the document from a saved pdf, it shows a different result than that what is printed directly to the printer. Does anonybody have similar problems or knows how to fix it?

TIA

Heiko

ReportPro3 PDF Export

Posted: Tue May 04, 2021 10:41 am
by ic2
Hello Heiko,

I wondered if the PDF's from Microsoft PDF and PDF24 are exactly the same?

What I remember from earlier PDF "sessions" is that every PDF creator shows some differences, also in how it looks.

Dick

ReportPro3 PDF Export

Posted: Tue May 04, 2021 1:14 pm
by robert
Heiko,
RP3 uses WPDF for PDF output. This code was created by Filip Fransen.
The page size is passed as an integer.
I suspect the different page size is the result of incorrect rounding.
Maybe we need to change the resolution ?

Robert

ReportPro3 PDF Export

Posted: Tue May 04, 2021 1:56 pm
by HeikoP
Hello Dick,

Microsoft PDF and PDF24 both looks good. There are no visible differences in the reports i have testet. Binary they are of course not the same.

Heiko

ReportPro3 PDF Export

Posted: Tue May 04, 2021 2:00 pm
by HeikoP
Robert,

that could be.

If also found this line of code:
DEFINE WPPDF_NoOffsetEMF := 32 // Activates an experimental switch which can help to remove unwanted X a,d Y offsets
I will try this setting (as an integer 1) as an initialize. And report what happens.

Heiko

ReportPro3 PDF Export

Posted: Fri May 07, 2021 1:45 pm
by HeikoP
Robert,

i changed a method and got almost same results in creating a pdf compared to pdf24, but the code is really weird again.

Here are my changes. I tested them with DIN A4 and DIN A5 and different margins.

Heiko



METHOD ExportMF( sPED AS RPPageExportData, hMetaFile AS PTR, nPageNo AS LONGINT ) AS LOGIC PASCAL CLASS rpExportPDF

LOCAL nWIDTH, nHEIGHT AS FLOAT
LOCAL nTop, nLeft, nBottom as FLOAT
local nDPIDivisor:=20 as float

SELF:nLastPageNo:=nPageNo

// Calculate page : TWIPS -> 72 dpi
nWIDTH := sPED.nPaperWidth / nDPIDivisor
nHEIGHT := sPED.nPaperLength / nDPIDivisor
nLeft := sPED.nLeftMargin / nDPIDivisor
nTop := sPED.nTopMargin / nDPIDivisor

* WPDF_StartPageEx( self:liPDF, Integer(nWIDTH), Integer(nHEIGHT), iif( sPED.lLandscape, 90, 0 ) )
* Changed to no Rotation, the PDF should not display rotated!
WPDF_StartPageEx( self:liPDF, Integer(nWIDTH), Integer(nHEIGHT), iif( sPED.lLandscape, 0, 0 ) )

* WPDF_DrawMetafile( self:liPDF, hMetaFile, Integer(nLEFT), Integer(nTOP), Integer(nWIDTH-nLEFT), Integer(nHEIGHT-nTOP) )
* I really wonder why this changes the PDF in almost the same layout compared to PDF24.
* Especially I can´t explain the 1.6 factor, but somehow this works.
* nLeft+(nLeft*0.083+8.2) is also really magic, but i transformed the offset to a linar equation, and it work too.
* maybe there are bugs in the pdf-Lib.

WPDF_DrawMetafile( self:liPDF,;
hMetaFile, ;
Integer(nLeft +((nLeft)*1.6)),;
Integer(nTop+48),;
Integer(nWIDTH-((nLeft+(nLeft*0.083+8.2))/1.6)),;
Integer(nHEIGHT-20);
)

WPDF_EndPage( SELF:liPDF )

RETURN TRUE