Print Page | Close Window

Get current page canvas

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=2880
Printed Date: 14 Dec 25 at 3:29AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Get current page canvas
Posted By: grapentin
Subject: Get current page canvas
Date Posted: 29 Apr 14 at 1:00AM
I'm on 10.11 and I've used GetCanvasDC to get a canvas so that I can draw RTF text and NewPageFromCanvasDC to apply the canvas. (Previously we were creating a canvas-based type of report, so I'm remapping the old canvas coordinates into a QuickPdf coordinate system. So generally the easiest solution is to carry on with this approach.)
 
The problem is this that NewPageFromCanvasDC always creates a new page in the document, so I end up having to read the text back and then re-create it on the previous page, which can be error-prone. See:
http://www.quickpdflibrary.com/faq/extract-text-and-images-and-insert-into-new-pdf.php" rel="nofollow - http://www.quickpdflibrary.com/faq/extract-text-and-images-and-insert-into-new-pdf.php
 
What I need is to be able to get the current page as a canvas, or apply a canvas over the current page instead of creating a new page. Either that, or find a way to merge two pages together.
 
Any suggestions?



Replies:
Posted By: grapentin
Date Posted: 29 Apr 14 at 6:02AM
I've discovered a few things. Firstly, the DAExtractPageText I was using to read back the RTF does not get me all the font information, such as underlines and strikeouts. So I MUST merge the pages rather than read back the RTF and re-create it on the previous page.
 
 
Finally, I discovered how to merge pages together:
 
pageID = QP.CapturePage(theReport.PDFFile.PageCount);
QP.DrawCapturedPage(pageID, 0, 0, QP.PageWidth, QP.PageHeight)
 
Note that the CapturePage function will remove the page that has been captured.
So when the DrawCapturedPage function executes, the current page is now what was the previous page, which is exactly what I need.


Posted By: AndrewC
Date Posted: 29 Apr 14 at 3:39PM
grapentin,

The LoadFromCanvasDC function is designed to load the first page.  After that you can use NewPageFromCanvasDC.

Your CapturePage code assumes that SetOrigin(1); has been called beforhand.  QP.SelectPage can be used to select the correct page before calling DrawCapturedPage.

Andrew.


Posted By: AndrewC
Date Posted: 29 Apr 14 at 3:42PM
grapetin,

A PDF font doesn't support attributes such as underline, superscript, strikeout.  It really only stores the fontname and some font metric dimentions such as ascent, descent. capheight etc.  A PDF file is just a group of characters drawn on the page.  There is no concept of lines, sentences, paragraphs or other formatting.

Andrew



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