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 > Sample Code
  New Posts New Posts RSS Feed - Render at high DPI with max width
  FAQ FAQ  Forum Search   Register Register  Login Login

Render at high DPI with max width

 Post Reply Post Reply
Author
Message
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Topic: Render at high DPI with max width
    Posted: 30 Mar 12 at 9:39AM
int outputDPI = 200;
int maxWidth = 1000;

for (int page = 1; page <= totalIMGS; page++)
{
    lib.SelectPage(page);

    double pageWidth = lib.PageWidth();
    double pageHeight = lib.PageHeight();
    double scale = 1;

    int imgWidth = Convert.ToInt32((pageWidth / 72) * outputDPI);
    int imgHeight = Convert.ToInt32((pageHeight / 72) * outputDPI);

    if (imgWidth > maxWidth)
    {
        scale = (double)maxWidth / (double)imgWidth;
        imgWidth = maxWidth;
        imgHeight = Convert.ToInt32(imgHeight * scale);
    }

    using (Bitmap dcBmp = new Bitmap(imgWidth, imgHeight))
    {
        using (Graphics g = Graphics.FromImage(dcBmp))
        {
IntPtr hdc = g.GetHdc();
lib.SetRenderScale(scale);
lib.RenderPageToDC(outputDPI, page, hdc);
g.ReleaseHdc(hdc);
        }
        // dcBmp.Save("page" + page.ToString() + ".bmp");
    }
}

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