Loading...

Tif Page Not Rotating

Support for GdPicture Light Imaging Toolkit and GdPicture Pro Imaging ActiveX/SDK.

Tif Page Not Rotating

Postby JNewhouse » Tue Dec 08, 2009 8:02 am

Hello Loic,

I have a multipage tif file that for testing purposes, i'm trying to rotate the 2nd page, then saving all pages as a pdf. i'm using the following code in VFP

Code: Select all
  oimg = CREATEOBJECT("gdPicturePro5.imaging")
  oimg.SetLicenseNumber("NNNN")
 
  oVwr = CREATEOBJECT("gdPicturePro5.GdViewer")
  oVwr.SetLicenseNumber("NNNN")
 
  oVwr.PdfDPIRendering   = 200
  oVwr.LockControl       = .T. 
  oVwr.PDFRenderingMode  = 2
  oVwr.PDFEnablePageCash = .F.

  lcImageFile = "C:\temp\~plic133.tif"
 
  lcResult = "C:\temp\rotate_test.pdf"

  oVwr.DisplayFromFile(lcImageFile)
  lnPageCnt = oVwr.PageCount

  ** create a new pdf file
  oImg.PDFNewPDFEx(lcResult, "My Title", "My Author", "My Subject", "My Keywords", "My Creator")
  oImg.PdfSetMeasurementUnits(3)
  oImg.PdfSetCompressionLevel(9)
  oVwr.LockControl = .T.   

  FOR x = 1 TO lnPageCnt
    oVwr.DisplayFrame(x) 
    IF x = 2
      r= oVwr.Rotate90()     
    ENDIF
    lnImageId = oVwr.GetNativeImage   
     
    lnNewImageId = oImg.CreateClonedImageI(lnImageId)
    oImg.SetNativeImage(lnNewImageId)
    nPDFImage = oImg.PdfAddImageFromGdPictureImage(lnNewImageId)
  ENDFOR

  ** now add the pdf pages
  FOR x = 1 TO lnPageCnt
    lnWidth  = oImg.PdfGetImageWidth(x)
    lnHeight = oImg.PdfGetImageHeight(x)
    oImg.PdfSetPageDimensions(lnWidth, lnHeight)
    oImg.PdfNewPage()
    oImg.PdfDrawImage(x, 0, 0, lnWidth, lnHeight)
    oImg.PdfEndPage()
  ENDFOR
  oImg.PdfSavePdf()
  oVwr.CloseImage


i will send the sample tiff file to you separately. you should see that the 2nd page is not rotated in the resulting pdf file. with further testing i found, that it does work correctly if my original file is a pdf.

Thanks as always!

Jean-Claude
JNewhouse
 
Posts: 41
Joined: Thu Nov 15, 2007 9:37 pm

Re: Tif Page Not Rotating

Postby Loïc » Fri Dec 11, 2009 9:58 am

Hi JC,

I am sorry, I forgot this post.

Here your code with some modifications, let me know if you don't understand all.

Code: Select all
      oimg = CREATEOBJECT("gdPicturePro5.imaging")
      oimg.SetLicenseNumber("NNNN")
     
      oVwr = CREATEOBJECT("gdPicturePro5.GdViewer")
      oVwr.SetLicenseNumber("NNNN")
     
      oVwr.PdfDPIRendering   = 200
      oVwr.LockControl       = .T.
      oVwr.PDFRenderingMode  = 2
      oVwr.PDFEnablePageCash = .F.

      lcImageFile = "C:\temp\~plic133.tif"
     
      lcResult = "C:\temp\rotate_test.pdf"

      oVwr.DisplayFromFile(lcImageFile)
      lnPageCnt = oVwr.PageCount

      ** create a new pdf file
      oImg.PDFNewPDFEx(lcResult, "My Title", "My Author", "My Subject", "My Keywords", "My Creator")
      oImg.PdfSetMeasurementUnits(3)
      oImg.PdfSetCompressionLevel(9)
      oVwr.LockControl = .T.   

      FOR x = 1 TO lnPageCnt
        oVwr.DisplayFrame(x)

        lnImageId = oVwr.GetNativeImage   
         
        lnNewImageId = oImg.CreateClonedImageI(lnImageId)
        oImg.SetNativeImage(lnNewImageId)
        IF x = 2
          r= oImg.Rotate(Rotate90FlipNone)
        ENDIF

        nPDFImage = oImg.PdfAddImageFromGdPictureImage(lnNewImageId)
      ENDFOR

      ** now add the pdf pages
      FOR x = 1 TO lnPageCnt
        lnWidth  = oImg.PdfGetImageWidth(x)
        lnHeight = oImg.PdfGetImageHeight(x)
        oImg.PdfSetPageDimensions(lnWidth, lnHeight)
        oImg.PdfNewPage()
        oImg.PdfDrawImage(x, 0, 0, lnWidth, lnHeight)
        oImg.PdfEndPage()
      ENDFOR
      oImg.PdfSavePdf()
      oVwr.CloseImage


With best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4437
Joined: Tue Oct 17, 2006 10:48 pm
Location: France


Return to GdPicture [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest

cron