|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
I run an old version of EO.PDF (2012 - version 4.0.34.2) which is used to automatically add an image (signature) and text (date) to the second page in pdf files uploaded on a website.
The following code does the work:
System.Drawing.Image sig = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath("/Content/Underskrift.png")); EO.Pdf.Drawing.PdfImage pdfImg = new EO.Pdf.Drawing.PdfImage(sig); EO.Pdf.Contents.PdfImageContent cnt = new EO.Pdf.Contents.PdfImageContent(pdfImg); cnt.GfxMatrix.Translate(370, 113); cnt.AutoScale(); contract.Pages[1].Contents.Add(cnt);
EO.Pdf.Contents.PdfTextLayer textLayer = new EO.Pdf.Contents.PdfTextLayer(); textLayer.Font = new EO.Pdf.Drawing.PdfFont("Verdana", 12); EO.Pdf.Contents.PdfTextContent cntDate = new EO.Pdf.Contents.PdfTextContent(DateTime.Now.ToShortDateString()); cntDate.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Matrix; cntDate.GfxMatrix.Translate(335, 113); textLayer.Contents.Add(cntDate); contract.Pages[1].Contents.Add(textLayer);
This often fails in various ways: - the text (date) is missing - the image (signature) and text (date) is placed is a wrong position (rotated 90 degrees and about half of this original size)
About half of the uploaded pdf files are processed without errors...
I don't understand why this is happening. It is a known bug fixed in later releases?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
Your code looks correct. However we did fix some issue related to the page's current matrix state. The page's content supposes to restore its matrix state to its original state when it ends. However we've seen many PDF file doesn't do that. That would leave the page's transformation matrix in a modified state right before contents you added. This modified matrix state in turn changes the final output. In our new version we automatically scan the existing content to make sure that the initial matrix state is automatically restored before you add any contents. So you can give it a try and see if it works for you.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
Hi, when I download your product from http://www.essentialobjects.com/Download.aspx and try to run the .msi file I get the following error: "Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access the item.". How to proceed from here?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, Please see if this Microsoft support page helps: https://support.microsoft.com/en-us/kb/2669244Thanks!
|
|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
Hi, my antivirus (Kaspersky) was apparently blocking me even accessing the file. Thank you for your assistance!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Glad to hear that you found out the root cause!
|
|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
Hi, updating to the latest version of EO.PDF fixed some of the issues. But I still have an issue, which leaves the inserted image (signature) and text (date) in a wrong position (rotated 90 degrees and placed on the right side of the paper).
It seems like the issues might be related to the PDF version. - Pdf files in version 1.3 (Acrobat 4.x) seems to be handled correctly - Pdf files in version 1.4 (Acrobat 5.x) and 1.5 (Acrobat 6.x) seems to be left with the above issue.
Does this make sense to you? And most importantly, could you guide me in any way to fix the issue?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, You can send us a test file and we will be able to look into the file and tell you exactly what's wrong. Please see here for instructions on how to send test project/files to us: http://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
It took some time to get a pdf file with anonymous data to sent to you. I just e-mailed you the test project, and look forward to your response.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi, We have looked into the file and found the root of the problem is the page in this PDF is "Rotate" (a property on the page object). We have fixed the issue and posted a new build that addressed this problem. Please download the new build from our download page. After you download the new build, please use the ACM interface instead of the low level content API interface. The "Rotate" property changes the coordinate space for the page and the low level content API will be affected by this. However the ACM interface is capable of automatically adjust based on this altered coordinate space, thus it is capable of producing the right result (Note that the previous versions do not produce the correct result even with ACM interface). If you have not used ACM interface, you can take a look of it here: http://www.essentialobjects.com/doc/pdf/acm/overview.aspxThe code will be something like this:
Code: C#
//Load the document and image
PdfDocument doc = new PdfDocument("original.pdf");
Image image = Image.FromFile("logo.png");
AcmImage acmImg = new AcmImage(image);
//Position the image
acmImage.Style.Left = left_in_inches;
acmImage.Style.Top = top_in_inches;
//Render the image to the first page
AcmRender render = new AcmRender(doc.Pages[0], 0);
render.Render(acmImg);
Hope this helps. Please feel free to let us know if you still have any questions. Thanks!
|
|
Rank: Member Groups: Member
Joined: 6/5/2012 Posts: 10
|
I am having problems positioning the image and text on all types of pdf files. I have just mailed you a test project with steps to reproduce...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
We have found the root cause of this problem. We will post a new build with fix as soon as possible.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Hi,
We have just posted a new build. Please see if it resolves the issue for you.
Thanks!
|
|