PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 3:49 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Fri Sep 09, 2016 12:50 pm 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
Hi there, I am writing a small program at the moment to automatically fill forms in a PDF. PDFSharp cannot properly flatten forms at this times so I figured I would write my own workaround for it. I decided I would make use of the DrawString method, as I can get the position of where the string can be placed from the Rectangle of the TextField. I can also get the Font Name, Font Style and Font Size properties from the .Font member of the TextField, which you can see in the following code:

Code:
struct Font
{
   public string Name;
   public string Style;
   public double Size;
}
fontDetails.Name = currField.ContentFontName.ToString();
fontDetails.Size = currField.Font.Size;


I was also hoping to be able to find out the Alignment of the TextField so that I can properly Left, Center or Right justify the string with the XStringFormats parameter of DrawString().

Is there a way to find the alignment of a Field?

Thanks, RBrNx


Top
 Profile  
Reply with quote  
PostPosted: Fri Sep 09, 2016 7:13 pm 
Offline

Joined: Tue Sep 30, 2014 12:29 pm
Posts: 36
Check the /Q entry in the fields dictionary.
If this entry is not present, check the /Q entry of the AcroForm-Dictionary.
Possible values are:
0 Left-justified
1 Centered
2 Right-justified

Have a look at the spec for more details: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
Chapter 12.7.3 and 12.7.3.3


Top
 Profile  
Reply with quote  
PostPosted: Tue Sep 13, 2016 11:01 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
(void) wrote:
Check the /Q entry in the fields dictionary.
If this entry is not present, check the /Q entry of the AcroForm-Dictionary.
Possible values are:
0 Left-justified
1 Centered
2 Right-justified

Have a look at the spec for more details: http://wwwimages.adobe.com/content/dam/Adobe/en/devnet/pdf/pdfs/PDF32000_2008.pdf
Chapter 12.7.3 and 12.7.3.3


I've tried looking for the "/Q" entry in the AcroForm, the TextField, and it's kids but I can't seem to find it? There's a link below to the PDF I'm using as a test, can you see if you can find the "/Q" entries? Am I doing something stupid?

http://www.mediafire . com/download/i9ys91ls35ulidr/PDFSharp.pdf

Thanks, RBrNx


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 14, 2016 9:32 am 
Offline

Joined: Mon Sep 05, 2016 7:54 am
Posts: 22
I managed to solve this issue, posted my solution here: viewtopic.php?f=2&t=3444


Top
 Profile  
Reply with quote  
PostPosted: Tue Nov 15, 2016 12:10 pm 
Offline

Joined: Wed Oct 19, 2016 9:14 am
Posts: 7
Location: Australia
Hi, can you elaborate on how you are removing the fields as part of the flatten process ?

I can remove the Annotations I want that are attached to the fields but the fields remain, at least until a signature is applied to the file.

(I have a template with 8 signature locations, and I will generally want to remove 4 or 5 of these)

I guess I could look at adding the signature fields (and associated textfields) programattically to get the exact count I want....

_________________
Thanks

Rob


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 145 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