PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 8:28 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Mon Sep 11, 2023 4:11 pm 
Offline

Joined: Fri Sep 08, 2023 5:27 pm
Posts: 12
Hi - my company is trying to move from another third party Pdf tool to PdfSharp & I'm comparing the Pdf's created by both. I'm seeing an issue when I grab a PdfTextField's rectangle's X, Y, width & height values from the field's "/Rect" annotation. I had written another post that was answered concerning getting the correct X & Y position out of the "/Rect" values - I needed to use gfx.Transformer.WordToDefaultPage() to get the correct X & Y - that problem was solved. But now there's an issue with Width and Height - the width and height values in the "/Rect" are not correct - they are way to big, maybe 2 1/2 times to size they should be. The other Pdf tool returns Width & Height values of about 154.8 & 32.3, which is correct in points: The field in the Pdf template looks to be about 2" long * 3/8" high. But PdfSharp is returning the "/Rect" Width and Height values as about 226.8 & 70.1. My question is, are these values being read in from my template form by PdfSharp in something other than points? Do I need to convert them somehow?

Thank you,
Chris B


Top
 Profile  
Reply with quote  
PostPosted: Mon Sep 11, 2023 6:13 pm 
Offline

Joined: Fri Sep 08, 2023 5:27 pm
Posts: 12
I figured this out - just in case someone else has this issue.

The "/Rect" values of a PdfSharp's PdfTextField are not stored as [x, y, width, height], which is the way one instantiates an XRect object. They look to be stored as [x1, y1, x2, y2]. To get the height for my XRect I was creating, I just calculated (y2 - y1). For width, I was placing an image in the field, so I actually took the XImage's (height / width) instead of using the PdfTextField's width (x2 - x1), which could be quite arbitrary in my particular case.

ChrisB


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 391 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group