Alaska Software Inc. - quickpdf and getting device context
Username: Password:
AuthorTopic: quickpdf and getting device context
Rudolf Reinthalerquickpdf and getting device context
on Mon, 14 Mar 2011 08:16:50 +0100
Hello,
I would like to extract a page as bitmap from a PDF to a Windows Device 
Context. There is in QUICKPDF a function available 
(RenderPageToDC(nDPI,nPage,nHandle)), where I can define a 32-bit handle 
of the device context. But how to get it in a bitmap object ?
regards
Rudolf
Rudolf ReinthalerRe: quickpdf and getting device context
on Mon, 14 Mar 2011 08:43:30 +0100
Hello,
there is also a function RenderPageToVariant(), maybe this one is better 
for this purpuse, but what must I do with the variant to create the 
bitmap object ?
regards
Rudolf




Function QuickPDF0723.PDFLibrary::RenderPageToVariant(DPI As Long, Page 
As Long,
   Options As Long) As Variant

Am 14.03.2011 08:16, schrieb Rudolf Reinthaler:
> Hello,
> I would like to extract a page as bitmap from a PDF to a Windows Device
> Context. There is in QUICKPDF a function available
> (RenderPageToDC(nDPI,nPage,nHandle)), where I can define a 32-bit handle
> of the device context. But how to get it in a bitmap object ?
> regards
> Rudolf
Pablo BotellaRe: quickpdf and getting device context
on Mon, 14 Mar 2011 09:42:15 +0100
Hi,

I think RenderPageToVariant() is only available on the ActiveX version, but in the DLL version you have RenderPageToString() and RenderPageToFile() methods.

nDpi := 300 
nPage := 1
nOption := 0   0 = BMP,1 = JPEG,2 = WMF,3 = EMF
                      4 = EPS,5 = PNG,6 = GIF,7 = TIFF,8 = EMF+

cFileName :=  cPathCombine( cAppPath() , MyBmp.bmp" )

cImgBytes := oPdf:RenderPageToString( nDpi,nPage,nOption)
lMemoWrite( cFileName  , cImgBytes)

or

oPdf:RenderPageToFile( nDpi,nPage,nOption, cAnsiToUtf8( cFileName ) )

  Note that RenderPageToFile() wants UTF8 filenames

Regards,
Pablo
Rudolf ReinthalerRe: quickpdf and getting device context
on Mon, 14 Mar 2011 09:47:08 +0100
Hello Pablo,
thank you, how can I make from cImgBytes the bitmap object without 
saving to file ? I must be aware of speed and saving to file would take 
time.

regards
Rudolf

Am 14.03.2011 09:42, schrieb Pablo Botella:
> Hi,
>
> I think RenderPageToVariant() is only available on the ActiveX version, but in the DLL version you have RenderPageToString() and RenderPageToFile() methods.
>
> nDpi := 300
> nPage := 1
> nOption := 0   0 = BMP,1 = JPEG,2 = WMF,3 = EMF
>                        4 = EPS,5 = PNG,6 = GIF,7 = TIFF,8 = EMF+
>
> cFileName :=  cPathCombine( cAppPath() , MyBmp.bmp" )
>
> cImgBytes := oPdf:RenderPageToString( nDpi,nPage,nOption)
> lMemoWrite( cFileName  , cImgBytes)
>
> or
>
> oPdf:RenderPageToFile( nDpi,nPage,nOption, cAnsiToUtf8( cFileName ) )
>
>    Note that RenderPageToFile() wants UTF8 filenames
>
> Regards,
> Pablo
Rudolf ReinthalerRe: quickpdf and getting device context
on Mon, 14 Mar 2011 11:50:53 +0100
Hello,
problem solved with the help from pablo. Attached the sample.
regards
Rudolf

function pdftest()
******************************************************************
local oStatic1,oBitmap,nPageID,nPages,abuffer := {}
TQuickPdf():Register(QUICKPDF_KEY)
cFile := "laststrokes.pdf"
WITH OBJECT ( oPdf := TQuickPdf():New() )
      nPageID := .:LoadFromFile(cFile)
      nPages := .:PageCount()
      for x := 1 to nPages
           aadd(aBuffer,substr(.:RenderPagetoString(96,x,0),15))
      next x
      .:Destroy()
END WITH

@ 0,0   DCSTATIC TYPE XBPSTATIC_TYPE_RECESSEDBOX SIZE 100,50 OBJECT oStatic1

oBitmap := xbpBitmap():new():create()
oBitmap:setbuffer(aBuffer[1])

@ .1,.1  DCSTATIC TYPE XBPSTATIC_TYPE_BITMAP SIZE 100,50 CAPTION oBitmap 
OBJECT oBitmap1 PARENT oStatic1

dcread gui fit
return nil
Edgar Borger Re: quickpdf and getting device context
on Mon, 14 Mar 2011 10:00:48 -0300
Hello Rudolf,

with XbpPDF you have a RenderToBMP and a RenderToPS method that you can 
use for this purpose.

Regards,
Edgar



Em 14/03/2011 04:16, Rudolf Reinthaler escreveu:
> Hello,
> I would like to extract a page as bitmap from a PDF to a Windows Device
> Context. There is in QUICKPDF a function available
> (RenderPageToDC(nDPI,nPage,nHandle)), where I can define a 32-bit handle
> of the device context. But how to get it in a bitmap object ?
> regards
> Rudolf
Rudolf ReinthalerRe: quickpdf and getting device context
on Mon, 14 Mar 2011 17:59:24 +0100
Hello Edgar,
thank you, but solved so far.
regards
Rudolf

Am 14.03.2011 14:00, schrieb Edgar Borger:
> Hello Rudolf,
>
> with XbpPDF you have a RenderToBMP and a RenderToPS method that you can
> use for this purpose.
>
> Regards,
> Edgar
>
>
>
> Em 14/03/2011 04:16, Rudolf Reinthaler escreveu:
>> Hello,
>> I would like to extract a page as bitmap from a PDF to a Windows Device
>> Context. There is in QUICKPDF a function available
>> (RenderPageToDC(nDPI,nPage,nHandle)), where I can define a 32-bit handle
>> of the device context. But how to get it in a bitmap object ?
>> regards
>> Rudolf
>