Print Page | Close Window

DrawText

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=2597
Printed Date: 26 Jan 26 at 2:59AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: DrawText
Posted By: moakley
Subject: DrawText
Date Posted: 09 Apr 13 at 9:07PM
Simple task is to draw text, add an annotation, in one of the 4 corners of the page.  This annotation will be added to either just the first page or all pages.  Please note that I do not control how the PDFs are created.  I am using the code at the bottom.
 
The issue I am having is that some pages contain a single object and if that image is rotated 90 degrees clockwise, then an annotation added to the bottom-left corner will run up the bottom right corner when displayed in a PDF viewer, Adobe or FoxIt.  Using the API is there a way to account for the single object pages and recognize page orientation in order to draw the text as required for display in a viewer.
 
Thanks, Mike...
 
                    double XOffset = 0.0;
                    double YOffset = 0.0;
                    int fontId = 0;
                    for (int i = 1; i <= iNumPages; i++)
                    {
                        if (i == 1 || endorseData.AllPages)
                        {
                            qp.SelectPage(i);
                            qp.SetMeasurementUnits(0);
                            qp.SetOrigin(endorseData.Origin);
                            fontId = qp.AddTrueTypeFont(endorseData.FontName, 0);
                            qp.SelectFont(fontId);
                            qp.SetTextSize(endorseData.FontSize);
                            if (endorseData.Origin == 1)
                            {
                                // top-left
                                XOffset = endorseData.XMargin;
                                YOffset = endorseData.YMargin + qp.GetTextHeight();
                            }
                            else if (endorseData.Origin == 2)
                            {
                                // top-right
                                XOffset = endorseData.XMargin + qp.GetTextWidth(endorseData.Text);
                                YOffset = endorseData.YMargin + qp.GetTextHeight();
                            }
                            else if (endorseData.Origin == 3)
                            {
                                // bottom-right
                                XOffset = endorseData.XMargin + qp.GetTextWidth(endorseData.Text);
                                YOffset = endorseData.YMargin;
                            }
                            else
                            {
                                // bottom-left is the default
                                XOffset = endorseData.XMargin;
                                YOffset = endorseData.YMargin;
                            }
                            qp.DrawText(XOffset, YOffset, endorseData.Text);
                        }
                    }
                    qp.SaveToFile(fullFileName);
 



Replies:
Posted By: Ingo
Date Posted: 09 Apr 13 at 9:16PM
Hi!

You can check if there's rotation on the page and then you have to calculate...
These links will give you an idea what to do:
http://www.quickpdflibrary.com/faq/image-rotation-can-it-be-an-angle-like-60.php
http://www.quickpdflibrary.com/faq/a3-stamping-rotation.php
http://www.quickpdflibrary.com/help/quickpdf/PageRotation.php

Cheers, Ingo


Posted By: moakley
Date Posted: 09 Apr 13 at 9:50PM
What is the direction of rotation?  Appearance is 90 degrees clockwise, top of the page at 3oclock.  When I ran the following command it returned 270.
 
int pr = qp.PageRotation();


Posted By: AndrewC
Date Posted: 10 Apr 13 at 8:18AM
After QP.SelectPage(i) add a call to QP.NormalizePage(0);   This will reset the page rotation to 0 so that you can safely add Annots an DrawText commands.

Andrew.


Posted By: Ingo
Date Posted: 10 Apr 13 at 8:44AM
Hi!
 
"What is the direction of rotation?"
Rotation 0 means 12 o'clock... and it goes clockwise (right):
Rotation 90 means 3 o'clock, 180 means 6 o'clock and 270 means 9 o'clock.
Rotation 360 isn't possible 'cause that's again 0 and 12 o'clock ;-)
 
Regarding your issue rotation 270 means that the page was mirrored.
 
Cheers, Ingo
 


Posted By: moakley
Date Posted: 11 Apr 13 at 8:30PM
We receive a lot of PDFs produced by scanners and some by fax machines.  It is my understanding that the scanners produce the PDFs based on templates.  Typically, one for B&W and one for Color.  What is the advantage of using templates to produce PDFs that use color inversion, rotation, or mirroring of the scanned images?
Thanks, Mike...



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