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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - RenderPageToString and page size question
  FAQ FAQ  Forum Search   Register Register  Login Login

RenderPageToString and page size question

 Post Reply Post Reply
Author
Message
wjbons View Drop Down
Beginner
Beginner


Joined: 17 Jun 10
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote wjbons Quote  Post ReplyReply Direct Link To This Post Topic: RenderPageToString and page size question
    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)
Back to Top
Dimitry View Drop Down
Team Player
Team Player


Joined: 18 Feb 10
Status: Offline
Points: 37
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dimitry Quote  Post ReplyReply Direct Link To This Post Posted: 01 Nov 10 at 7:08PM
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
Back to Top
wjbons View Drop Down
Beginner
Beginner


Joined: 17 Jun 10
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote wjbons Quote  Post ReplyReply Direct Link To This Post Posted: 02 Nov 10 at 10:30AM
thanks for your help.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store