Jump to content

Change page size in generated pdf


Recommended Posts

Hello I'm using tatietel's PDF UDF. I have 3 different sized images I am trying to put into a PDF and make it so each page is orientated so the image fills up the entire page. I've tested out the sizes and it gets the right size but it doesn't actually change the page size for the pdf. Any idea what I'm doing wrong here or suggestions on how to make it work?

 

If UBound($aImgs)<>1 Then
            ;=== load resources used in pdf ===
            For $i=1 To UBound($aImgs)-1
                _LoadResImage("img"&$i, $aImgs[0] & "\" & $aImgs[$i])
            Next
            ;load each image on it's own page
            For $i = 1 To UBound($aImgs)-1
                $z = $i-1
                _getImageSize ($folder&"\preview"&$images[$z]&".png")
        
                if ($iY > $iX) Then
                    _SetPaperSize("a4")
                    _SetOrientation($PDF_ORIENTATION_PORTRAIT)
                EndIf

                if ($iY < $iX) Then
                    _SetPaperSize("a4")
                    _SetOrientation($PDF_ORIENTATION_LANDSCAPE)
                EndIf

                if ($iX = $iY ) Then
                    _SetPaperSize("CUSTOM", 595.276, 595.276)
                    _SetOrientation($PDF_ORIENTATION_LANDSCAPE)
                EndIf

                _BeginPage()
                    _InsertImage("img"&$i, 0, 0, _GetPageWidth()/_GetUnit(), _GetPageHeight()/_GetUnit())
                _EndPage()
            Next
        EndIf

 

Link to comment
Share on other sites

This works for me;

_SetPaperSize("CUSTOM", 841.890, 595.276); A4 landscape
    _SetOrientation($PDF_ORIENTATION_PORTRAIT) ; even for landscape



   

 

Edited by dmob
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...