Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
RenderPageToString and page size question |
Post Reply |
Author | |
wjbons
Beginner Joined: 17 Jun 10 Status: Offline Points: 17 |
Post Options
Thanks(0)
Posted: 01 Nov 10 at 8:43AM |
Hi,
I use the RenderPageToString to get a bitmap from the pdf content.
But default it has a certain size.
I want to create a bitmap in a different size of let's say page 1.
If I use the SetPageDimensions function it crops the bitmap to a part of the page content and does not resize the content (clipped). I tried using the setpagebox, but did not get the right solution out. Qs:
How can I create a smaller output bitmap than the original size which contains the full page content?
( I am able to create the original bitmap and afterwards resize this one, but that is more time consuming)
|
|
Dimitry
Team Player Joined: 18 Feb 10 Status: Offline Points: 37 |
Post Options
Thanks(0)
|
Actually there are two ways to render page to bitmap of certain size:
1. The first way is to define DPI for RenderPageToString().
Unlike output bitmap size, actual page size isn't affected by rendering with various DPI.
So PageWidth() and PageHeight() will be same until being changed via SetPageDimensions().
2. The second way is just to resize output Bitmap using Canvas.CopyRect().
Here is code sample:
// Image1: TImage; - destination for resized Bitmap
// Bitmap: TBitmap; - our source Bitmap
var
s, d: TRect;
begin
s.Left := 0;
s.Top := 0; s.Right := Bitmap.Width; s.Bottom := Bitmap.Height; d.Left := 0;
d.Top := 0; d.Right := Round(Bitmap.Width/2); // width and height are resized by 50% d.Bottom := Round(Bitmap.Width/2); Image1.Canvas.CopyRect(d, Bitmap.Canvas, s);
end;
The first way gives definitely highest output quality, but the second is much faster because it uses StretchBlt() API inside.
|
|
Regards,
Dmitry |
|
wjbons
Beginner Joined: 17 Jun 10 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
thanks for your help.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store