image2pdf embeds images only. How does it do in such a small size?
How is MSWord doing it?
Let us not rule out.
It is just that we do not know how they are doing it.
#include "fivewin.ch"
REQUEST DBFCDX
//----------------------------------------------------------------------------//
function Main()
USE CUSTOMER VIA "DBFCDX"
SET FILTER TO RECNO() < 20
GO TOP
TPreview():bSaveAsPDF := { |oPreview| TestPDF( oPreview ) }
XBROWSER "CUSTOMER" COLUMNS "FIRST", "CITY", "SALARY"
return nil
function TestPDF( oPreview )
CreatePDF( "newtest.pdf", oPreview:oDevice:aMeta ) // emf2pdf.prg
ShellExecute( 0, "open", "newtest.pdf" )
return nil
for each f in aMetas
// hMeta := GetEnhMetaFile(f[1])
hMeta := GetEnhMetaFile(f)
static proc pdf_Header(pdf,pRecord,pTable)
local page // GNR
static proc pdf_TextOut(page,pRecord)
LOCAL i // GNR
#ifdef __HARBOUR__
#include <hbapi.h>
#include <hbhpdf.h>
HB_FUNC(HPDF_ADDEMF) // pdf (Pointer), cEMFFIle (stringa)
{
HPDF_Doc pdf = hb_HPDF_Doc_par(1);
if (pdf == 0)
{
hb_ret();
return;
}
Emf2Pdf conv(pdf);
conv.AddEMF(hb_parc(2));
hb_ret();
}
#endif
TPreview():bSaveAsPDF := {|o| TPrinter2PDF(o:oDevice)}
PROC TPrinter2PDF(oPrn, cFile)
LOCAL i, oPdf := HPDF_New()
DEFAULT cFile := cGetFile( "(*.pdf)|*.pdf|", "Select PDF File to Save",, CurDir(), .T. )
//if !empty(oPrn:aMeta)
// ? oPrn:aMeta[1]
//endif
for i:=1 to len(oPrn:aMeta)
HPDF_ADDEMF(oPdf, oPrn:aMeta[i])
next
HPDF_SaveToFile( oPdf, cFile)
return
TPreview():bSaveAsPDF := { |o| SaveMSPdf( o ) }
Function SaveMSPdf( oPreview )
local cPrnName := "Microsoft Print to PDF"
If AScan( aGetPrinters(), cPrnName ) > 0
oPreview:SelPrinter( cPrnName )
oPreview:PrintPage()
else
Msginfo( "impresora "+ cPrnName + " no encontrada" )
endif
Return nil
mastintin wrote:I have tried with "Microsoft Print to PDF" and it gives a great result.
This code to test ( you have to have win10 and the printer installed. )
- Code: Select all Expand view
TPreview():bSaveAsPDF := { |o| SaveMSPdf( o ) }
Function SaveMSPdf( oPreview )
local cPrnName := "Microsoft Print to PDF"
If AScan( aGetPrinters(), cPrnName ) > 0
oPreview:SelPrinter( cPrnName )
oPreview:PrintPage()
else
Msginfo( "impresora "+ cPrnName + " no encontrada" )
endif
Return nil
hmpaquito wrote:Microsoft Print to PDF use is limited.
Only Windows 10.
How to silent mode ?
How to configure ?
How to assignt pdf full file path name ?
Limited, I think.
Regards.
void Emf2Pdf::ParseFile()
{
....
case EMR_ROUNDRECT: nRead += RoundRectangle(); break;
.....
}
//-------------------------------
#include <math.h>
#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif
size_t Emf2Pdf::RoundRectangle()
{
size_t ret = 0;
RECTL bound;
fread(&bound, 4, 4, f); ret += 16;
PRINT_DBG(" (%ix%i)-(%ix%i) \r\n", bound.right, bound.bottom, bound.left, bound.top);
float x = bound.left * xScale;
float r = bound.right * xScale;
float b = currHeight - bound.bottom * yScale;
float t = currHeight - bound.top * yScale;
float w = (bound.right - bound.left) * xScale;
float h = (bound.bottom - bound.top) * yScale;
unsigned long cx;
unsigned long cy;
fread(&cx, 4, 1, f); ret += 4;
fread(&cy, 4, 1, f); ret += 4;
PRINT_DBG(" %i points\r\n", cx);
PRINT_DBG(" %i points\r\n", cy);
float fcx = cx *xScale;
float fcy = cy *yScale;
float nRound = min( fcx, fcy ) ;
double nRay ;
float currWidth = HPDF_Page_GetWidth( page ) ;
if ( currWidth > currHeight ) {
nRay = round(min( nRound, int(h)/2 )) ;
}
else
{
nRay = round(min( nRound, int(w)/2) ) ;
}
HPDF_Page_MoveTo ( page, x + nRay, t ) ;
HPDF_Page_LineTo ( page, r - nRay, t ) ;
HPDF_Page_CurveTo( page, r, t, r, t, r, t - nRay ) ;
HPDF_Page_LineTo ( page, r, b + nRay );
HPDF_Page_CurveTo( page, r, b, r, b, r - nRay, b ) ;
HPDF_Page_LineTo ( page, x + nRay, b ) ;
HPDF_Page_CurveTo( page, x, b, x, b, x, b + nRay ) ;
HPDF_Page_LineTo ( page, x, t - nRay ) ;
HPDF_Page_CurveTo( page, x, t, x, t, x + nRay, t ) ;
// HPDF_Page_GSave(page) ;
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 ret;
}
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 55 guests