Print Page | Close Window

quickPDF render to Device Context

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1197
Printed Date: 04 Apr 26 at 10:24AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: quickPDF render to Device Context
Posted By: munteanu24d
Subject: quickPDF render to Device Context
Date Posted: 03 Sep 09 at 3:51PM
Hello everybody!

I want to use quickPDF as a viewer in my C++ application, and moreover I need to render to the pdf content to a DC.
I had a look to windows MFC classes, but I do not know exactly which type of DC is supported.

Can somebody give me more details about how to render the PDF to a DC, or point me to some tutorials?

Thanks in advance,|
D.M.



Replies:
Posted By: deabrew
Date Posted: 03 Sep 09 at 4:02PM
Hi D.M.

Try something like this ... 
________________

BOOL CPDFViewerDlg::OnInitDialog()
{
   http://msdn.microsoft.com/en-us/library/fwz35s59%28VS.80%29.aspx - CDialog:: - MFC)

// Draw updated page
m_iDAFileHandle = m_QP.DAOpenFile(m_strFile, CString(_T("")));
m_iPageRef = m_QP.DAFindPage(m_iDAFileHandle, 1);
// Resize window based on new PDF
MoveWindow(0, 0, m_QP.DAGetPageWidth(m_iDAFileHandle, m_iPageRef), 
m_QP.DAGetPageHeight(m_iDAFileHandle, m_iPageRef),TRUE);
// Set the dialog title
CString strTitle;
::GetFileTitle(m_strFile, strTitle.GetBufferSetLength(1024), 1024);
strTitle.ReleaseBuffer();

// Recenter the dialog in the center of the active window
CenterWindow(GetDesktopWindow());

return TRUE;  // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}

void CPDFViewerDlg::OnPaint()
{
CPaintDC dc(this);
m_QP.DARenderPageToDC(m_iDAFileHandle, m_iPageRef, 72,(int) (HDC) dc);
}

________________


Posted By: munteanu24d
Date Posted: 03 Sep 09 at 4:56PM
Thank you so much !
It really worked!

I would like to move from MFC to GTK . Is it possible to render it in a GTK DC too?

Best wishes,
D.M.



Posted By: munteanu24d
Date Posted: 04 Sep 09 at 5:59PM
Just in case somebody will need the answer of my question ... here it is:

Yes, quickPDF can be used to render even to GTK device content.

<code>

HWND m_hwnd = HWND(GDK_WINDOW_HWND(this->m_drawingArea.get_window()>gobj() ));
HDC m_hdc = GetDC(m_hwnd);   
QP.RenderPageToDC(100, 1,(int)(HDC) m_hdc);

</code>



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk