Positioning problem

Hi,

I’ve been using the following code on our websites for a long time with no problems. It places a logo and some text at the top of the first page of a PDF document:

'Get the dimensions of the first page of the PDF
objFileInfo = New PdfFileInfo(Server.MapPath(String.Format("{0}_temp.pdf", strTemporaryDocumentID.ToString)))
sngWidth = objFileInfo.GetPageWidth(1)
sngHeight = objFileInfo.GetPageHeight(1)

'Add GSC logo and text watermark
objPdfFileMend = New PdfFileMend(Server.MapPath(String.Format("{0}_temp.pdf", strTemporaryDocumentID.ToString)), Server.MapPath(String.Format("{0}.pdf", strTemporaryDocumentID.ToString)))
objPdfFileMend.AddText(New FormattedText("CV downloaded from [www.publicsectorcareers.org](http://www.publicsectorcareers.org/)", New FontColor(0, 115, 189), Aspose.Pdf.Kit.FontStyle.HelveticaBold, EncodingType.Winansi, False, 9), 1, 105, 816.3, sngWidth, sngHeight - 10)
objPdfFileMend.AddImage(Server.MapPath("Images/Documents/logo_document_watermark.gif"), 1, 5, 808.6, 100, 836.6)
objPdfFileMend.Close()

I have just noticed that there is a problem when viewing some documents in Adobe Reader 8 - the logo appears off the top of the page and I can’t see the text at all.

Do you know if there is a problem with Adobe Reader 8, or could my code be written differently?

An example PDF is attached.

Many thanks,

Tim

Hello Tim,

I have tried viewing the Pdf file with Adobe Reader 8.0.0 and Adobe Reader 5.0 and I have been able to see the text, but i cant see the logo in either the case. Please check the Pdf once again, and also If you could share the expected Pdf it would be more helpful for us to understand the issue.

Hi,

I have sent you a PDF in an email (subject "Positioing problem").

Thanks,

Tim

Hello Tim,

Thanks for considering Aspose.

Thanks for sharing the resource files. I have tried viewing the file with Adobe Reader 5.0 & 8.0.0 and was able to view the Logo as well as text as you mentioned. In previous post file I wasn't able to see the Logo but can see the text.
Can you Please explain your requirement little more & about the difference that you have mentioned.

Hi Tim,

I think it may be caused by the difference page size of pdfs (the height of the test page is only 792). Please revise 2 lines in the code as following(red font).

objPdfFileMend.AddText(New FormattedText("CV downloaded from www.publicsectorcareers.org", New FontColor(0, 115, 189), Aspose.Pdf.Kit.FontStyle.HelveticaBold, EncodingType.Winansi, False, 9), 1, 105, sngHeight - 20, sngWidth, sngHeight - 10)
objPdfFileMend.AddImage(Server.MapPath("Images/Documents/logo_document_watermark.gif"), 1, 5, sngHeight - 20, 100, sngHeight - 10)

And if you are using the latest version(3.1.0.0) of Aspose.Pdf.Kit, you could use the new function of PdfFileStamp.AddHeader, please refer to http://www.aspose.com/documentation/file-format-components/aspose.pdf.kit-for-.net-and-java/aspose.pdf.kit.pdffilestamp.addheader_overload_2.html

Thanks,

Hi Felix,

That's what it was - I should have thought of that! Many thanks for all your help.

Best wishes,

Tim