Different results with similar pdf's
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=1834
Printed Date: 13 Jul 25 at 11:44PM Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com
Topic: Different results with similar pdf's
Posted By: ezaidi
Subject: Different results with similar pdf's
Date Posted: 19 May 11 at 3:54PM
Hi I am trying to stamp some pdf files with an overlay, however I seem to be getting different results when creating the stamp on a pdf file generated through autocad with the pdfplot10.hdi 10.0.55.0 driver. All other distiller created pdf's are fine. Here are links to the files I used. Two files are of same height and width and one is a png overlay file.
http://uploading.com/files/31ac5971/Pdf_overlay_problem.zip/
Here is the code I use:
Call QP.SelectPage(I) Rem create a new layer to apply the stamp on and select it Call QP.NewLayer Call QP.SelectLayer(QP.LayerCount) Rem set the transarency of the image Call QP.SetTransparency(40) Rem Set scale based on Page Ht value If QP.PageWidth < QP.PageHeight Then mScale = QP.PageWidth * 0.8 / 800 Else mScale = QP.PageHeight * 0.8 / 800 End If Call QP.SetScale(mScale)
mStampLeft = (QP.PageWidth - QP.ImageWidth) / 2 mStampBot = QP.PageHeight - 10 - QP.ImageHeight Call QP.DrawRotatedImage(mStampLeft, mStampBot, QP.ImageWidth, QP.ImageHeight, 0)
QP.SaveToFile(GetWinDirectories("TempDir") & "Temp.pdf")
Please let me know if this can be fixed.
Thanks!
|
Replies:
Posted By: Ingo
Date Posted: 19 May 11 at 7:28PM
Hi Ezaidi!
I've thought there was a stamp (the png in the zip) on both pdf? I don't find a stamp on both pdf. Nothing. So i don't know where's the problem but i can imagine ... ;-) I don't see a GetOrigin in your code ... Please read all about SetOrigin and GetOrigin in the online reference: http://www.quickpdflibrary.com/help/quickpdf/MeasurementAndCoordinateUnits.php Normally the highest pixel-row is at the top and the lowest is at the bottom but you can't be sure so have a look on SetOrigin and GetOrigin.
Cheers and welcome here, Ingo
|
Posted By: ezaidi
Date Posted: 20 May 11 at 2:10PM
Hi, I gave the pdf's which have not yet had an overlay stamped. If you run the code I use, you will see that the stamp will yield different results on both pdf's. The getorigin function seems to always give me 0 on either pdf.
Thank you for your help
|
Posted By: Ingo
Date Posted: 20 May 11 at 3:05PM
Hi!
This here is only a user-user-forum here. Your code isn't pascal/delphi (my favourite) and it's not a complete project. So there won't be anybody who can try your code in a quick way. You should investigate in things having to do with "rotation". If origin is 0 but one page is rotated (and it is!) after creation then your stamp goes into nothing ;-) Open the files with notepad and search for "rotate"... Try other values using the "bad" pdf... You can try the official knowledgebase in this case, too.
Cheers, Ingo
|
Posted By: ezaidi
Date Posted: 20 May 11 at 9:01PM
Hi, I dont think this has to do with rotation. What seems to be going on is the page size scaling. When I use the pagewidth and height methods, I get 1000 and 1545 respectively on both good and bad pdf's. I use these sizes to decide where my stamp will go. The problem is on the bad pdf, my stamp appears minuscule and completely away from where it should be placed. I also noticed that in order to get my stamp to appear at the right place I have to multiply everything by a factor of 8. For example this works:
Call QP.DrawRotatedImage(mStampLeft * 8, mStampBot * 8, QP.ImageWidth * 8, QP.ImageHeight * 8, Rotation)
Why is there a factor of 8 needed yet the page height and width are the same, the rotation is the same. The only discernible difference is that one pdf was generated with pdfplot10.hdi through autocad and one pdf is generated with distiller (which gives good results)
Let me know if you have any understanding about the scaling that is occurring.
|
Posted By: Rallsolo
Date Posted: 22 May 11 at 2:28AM
I've seen this before in PDFs created from different sources. It has to do with the resolution of the original images placed on the PDFs. One way you can automate the scale is to check the string returned by QP.GetInformation(6) which will give you who created the PDF. If it says pdfplot, automatically multiply by 8. Either that or play with the resolution in AutoCAD when you produce the plot if you can.
|
Posted By: ezaidi
Date Posted: 24 May 11 at 1:06PM
That is exactly what i have done. In my new code I use qp.getinformation(6) and check for pdfplot and then scale by 8. It seems to work well but im still confused as to why pagewidth and pageheight functions give the unscaled resolution. I dont know if this is a bug with quickpdf or what. I would have liked to keep my code clean and have a general solution which works with all pdf versions. Unfortunately, the function which generates the pdf's in autocad does not have any configurations to play with the resolution.
I guess we will have to live with this.
Thanks for your help guys
|
|