[Gambas-user] Create pdf Thumbnail preview..

Gianluigi gradobag at gradobag.it
Sun Feb 26 16:38:13 CET 2023


Il 26/02/23 16:11, Fabien Bodard ha scritto:
> Private Sub ThumbPdfFile(sPath As String, sThumb As String) As Image
>
>   Dim hPdf As PdfDocument
>   Dim hPage As Image
>    dim iSize as integer = 128
>   Try Component.Load("gb.poppler")
>   If Error Then Return
>
>   Try hPdf = New PdfDocument(sPath)
>   If Error Then
>     'Error File.Name(sPath); ": "; Error.Text
>     Return
>   Endif
>
>   If hPdf.Count = 0 Then Return
>
>   hPage = hPdf[0].Render()
>
>   If hPage.W > hPage.H Then
>     hPage = hPage.Stretch(iSize, (iSize * hPage.H) \ hPage.W)
>   Else
>     hPage = hPage.Stretch((iSize * hPage.W) \ hPage.H, iSize)
>   Endif
>
>
>   Return hPage
> End
>
>
> You can find more stuf in the CTaskPreview file in gb.form component code.


Yes, use the gb.poppler component as suggested, more help here:

https://www.gambas-it.org/wiki/index.php/Codice_essenziale_per_mostrare_un_file_PDF_con_le_risorse_del_Componente_gb.poppler

But if you listen to me there is gb.report2 by Fabien Bodard that once 
you understand the mechanism makes your life easier for everything :-)
you can find a Italian lesson here:

https://www.gambas-it.org/wiki/index.php/Creare_report_con_il_componente_gb.report2

Regards

Gianluigi



More information about the User mailing list