Print Page | Close Window

Previewing a PDF before Saving?

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=2985
Printed Date: 19 May 24 at 9:52AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Previewing a PDF before Saving?
Posted By: stevemaughan
Subject: Previewing a PDF before Saving?
Date Posted: 08 Oct 14 at 1:19PM
Hi - 

I'm sure this question will reveal my newbie credentials - but here goes.

I'm going to use QuickPDF as my "printing engine". So instead of writing two routine, one to export to a PDF file, and the other to print to a printer, I'm going to write the PDF export then do a shell command to print it when necessary.

The one obstacle is print preview. 

What's the best way to show the PDF file? 

Can I create it in memory and somehow show it on a canvas (which would be wonderful!). 

Or do I have to save it to disk and then re-open it to preview?

All help appreciated,

Steve



Replies:
Posted By: mLipok
Date Posted: 08 Oct 14 at 3:06PM
You can use Debenu Viewer or
using QuickPDF RenderPageToDC

here is example in AutoIt

Func _QP_Display($oQP, $iLeft, $iTop, $iWidth, $iSelectPage = 1)
If Not IsObj($oQP) Then
; TODO
Else
; select Page
$oQP.SelectPage($iSelectPage);
$oQP.CombineContentStreams()
$oQP.SelectContentStream(1)

; calculate DPI
Local $iPageWidth = $oQP.PageWidth();
Local $iPageHeight = $oQP.PageHeight();
Local $iDisplayDPI = ($iWidth / $iPageWidth) * 72

; create GUI
Local $iHeight = ($iWidth * $iPageHeight) / $iPageWidth
Local $hwnd = GUICreate('QuickPDF Test Display', $iWidth, $iHeight, $iLeft, $iTop)
GUISetState(@SW_SHOW)
Local $hDC = _WinAPI_GetDC($hwnd)

; render QP object to Device Context
$oQP.RenderPageToDC($iDisplayDPI, $iSelectPage, $hDC);

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
_WinAPI_ReleaseDC($hwnd, $hDC)
GUIDelete($hwnd) ; Deletes a GUI window and all controls that it contains.
EndIf
EndFunc   ;==>_QP_Display



-------------
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600


Posted By: stevemaughan
Date Posted: 08 Oct 14 at 3:19PM
Great!  I'll investigate the RenderPageToDC procedure,

Thanks,

Steve



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