[Gambas-user] Create pdf Thumbnail preview..

Fabien Bodard gambas.fr at gmail.com
Sun Feb 26 16:11:20 CET 2023


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20230226/5fb91342/attachment.htm>


More information about the User mailing list