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
