Ive been using
pdf.RenderPagePicture
to create a mini preview of my PDF pages using DynaPDFMBS
When the page is portrait, it works
When the page is landscape, (done by using call pdf.SetOrientationEx(90) )
I get a landscape shaped image, but only a portion of the page rendered, centred in the area.
So I lose some of the image
my code is:
myimage = pdf.RenderPagePicture(pdf.getpagecount , pdf.GetPageWidth /2 , pdf.GetPageHeight/2 ,2)
There are no parameters I can throw at this.
Am I doing something wrong… how do I get a preview of a PDF page which is at landscape mode.?
Thank you. RenderPagePicture at least has a bug there with rotated page.
So
RenderPagePicture(PageNum as Integer) as picture
has a bug, that it didn’t pick right size for orientated pages, so I’ll fix it.
But for
Preformatted text
RenderPagePicture(PageNum as Integer, Width as Integer, Height as Integer, DefScale as Integer = 2, matrix as DynaPDFMatrixMBS = nil) as picture
you have to swap width/height yourself as that defines the picture size you want. The page will be centered in this area.
Thanks, I’ll try that.
Alternatively I may have to resort to manually setting all page sizes
( instead of using the constants for Letter and A4 then applying rotation)
Now that I removed 'preformatted text I find that the code above is exactly what I already have.
And I have already tried changing the width and height parameters
But for clarity:
if my page is portrait, and I use this code with height > width, it works.
If my page is landscape, and I use this code with width> height (ie Landscape shape), I do get a landscape image, but what it contains is a square of rendered image and a lot of white space.
So the created image is the right size, but what is rendered upon it , seems always to be based on the portrait dimensions.
I have a work around.
Instead of using the PDF page size constants and using set rotationEX
I set the point sizes of all page types manually, and swap the sizes of height and width if landscape is required.
In essence, everything is now ‘portrait’ even if the page is wider than it is tall.
if this is of use to anyone else (there are some page sizes here that DynaPDF doesnt have constants for anyway…)
if bLandscapeRequired then
select case nPDFPageSize
case dynapdfmbs.kpfDIN_A4
call pdf.SetPageHeight(595)
call pdf.SetPageWidth(842)
case dynapdfmbs.kpfDIN_A5
call pdf.SetPageHeight(420)
call pdf.SetPageWidth(595)
case dynapdfmbs.kpfDIN_A3
call pdf.SetPageHeight(842)
call pdf.SetPageWidth(1190)
case myExtraConstants.kpdf_DINA2
call pdf.SetPageHeight(1191)
call pdf.SetPageWidth(1684)
case myExtraConstants.kpdf_DINA1
call pdf.SetPageHeight(1684)
call pdf.SetPageWidth(2384)
case myExtraConstants.kpdf_DINA0
Call pdf.SetPageHeight(2384)
call pdf.SetPageWidth(3370)
case myExtraConstants.kpdf_DIN2A0
call pdf.SetPageHeight(3370)
call pdf.SetPageWidth(4768)
case myExtraConstants.kpdf_DIN4A0
call pdf.SetPageHeight(4768)
call pdf.SetPageWidth(6741)
case dynapdfmbs.kpfUS_Letter
call pdf.SetPageHeight(612)
call pdf.SetPageWidth(792)
case myExtraConstants.kpdf_TABLOID
call pdf.SetPageHeight(792)
call pdf.SetPageWidth(1216)
case myExtraConstants.kpdf_USLegal
call pdf.SetPageHeight(612)
call pdf.SetPageWidth(1008)
end select
else
select case nPDFPageSize
case dynapdfmbs.kpfDIN_A4
call pdf.SetPageWidth(595)
call pdf.SetPageHeight(842)
case dynapdfmbs.kpfDIN_A5
call pdf.SetPageWidth(420)
call pdf.SetPageHeight(595)
case dynapdfmbs.kpfDIN_A3
call pdf.SetPageWidth(842)
call pdf.SetPageHeight(1190)
case myExtraConstants.kpdf_DINA2
call pdf.SetPageWidth(1191)
call pdf.SetPageHeight(1684)
case myExtraConstants.kpdf_DINA1
call pdf.SetPageWidth(1684)
call pdf.SetPageHeight(2384)
case myExtraConstants.kpdf_DINA0
Call pdf.SetPageWidth(2384)
call pdf.SetPageHeight(3370)
case myExtraConstants.kpdf_DIN2A0
call pdf.SetPageWidth(3370)
call pdf.SetPageHeight(4768)
case myExtraConstants.kpdf_DIN4A0
call pdf.SetPageWidth(4768)
call pdf.SetPageHeight(6741)
case dynapdfmbs.kpfUS_Letter
call pdf.SetPageWidth(612)
call pdf.SetPageHeight(792)
case myExtraConstants.kpdf_TABLOID
call pdf.SetPageWidth(792)
call pdf.SetPageHeight(1216)
case myExtraConstants.kpdf_USLegal
call pdf.SetPageWidth(612)
call pdf.SetPageHeight(1008)
end select
end if