Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF, adding image and text sometimes fails Options
Morten Kragh Jensen
Posted: Tuesday, August 11, 2015 4:58:40 AM
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?
eo_support
Posted: Tuesday, August 11, 2015 2:58:42 PM
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!
Morten Kragh Jensen
Posted: Friday, August 21, 2015 8:08:54 AM
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?
eo_support
Posted: Friday, August 21, 2015 9:55:59 AM
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/2669244

Thanks!
Morten Kragh Jensen
Posted: Friday, August 21, 2015 10:08:59 AM
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!
eo_support
Posted: Friday, August 21, 2015 3:04:32 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Great. Glad to hear that you found out the root cause!
Morten Kragh Jensen
Posted: Monday, November 2, 2015 7:25:05 AM
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?
eo_support
Posted: Monday, November 2, 2015 2:40:19 PM
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.aspx

Thanks!
Morten Kragh Jensen
Posted: Friday, November 20, 2015 4:23:16 AM
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.
eo_support
Posted: Friday, November 20, 2015 6:24:18 PM
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.aspx

The 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!
Morten Kragh Jensen
Posted: Tuesday, January 12, 2016 8:31:03 AM
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...
eo_support
Posted: Tuesday, January 12, 2016 2:50:58 PM
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!
eo_support
Posted: Wednesday, January 13, 2016 10:00:42 PM
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!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.