PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Aug 21, 2017 6:28 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Jun 01, 2016 8:00 am 
Offline

Joined: Wed Jun 01, 2016 7:45 am
Posts: 1
Hello Guys,

I´ve created a fillable PDF with OpenOffice and now I want to change the background color of the textbox. For this I use the following code:

Code:
PdfDocument Template = PdfReader.Open("MyPath", PdfDocumentOpenMode.Modify);
PdfAcroField.PdfAcroFieldCollection Form = Template.AcroForm.Fields;

if (Field.GetType() == typeof(PdfTextField))
{
   PdfTextField CurrentField = (PdfTextField)Field;
   CurrentField.ReadOnly = false;
   CurrentField.Value = new PdfString("Test");
   CurrentField.BackColor = Color.Red;
}


If I run this code, the background of the textbox doesn´t change the color, but the value of the textbox changed to "Test". How can I change the background of the textbox?

I also want to copy a screenshot into my PDF. So I use a textfield to define the position of the image. The image should be placed at the same position as the textbox.
So I read out the position of the textfield:

Code:
                                       
PdfArray ImagePosition = (PdfArray)CurrentField.Elements["/Rect"];
double[] Imageformat = {
   Convert.ToDouble(ImagePosition.Elements[0].ToString(), CultureInfo.InvariantCulture),
   Convert.ToDouble(ImagePosition.Elements[1].ToString(), CultureInfo.InvariantCulture),
   Convert.ToDouble(ImagePosition.Elements[2].ToString(), CultureInfo.InvariantCulture),
   Convert.ToDouble(ImagePosition.Elements[3].ToString(), CultureInfo.InvariantCulture)
   };


I´ve got the information that the first element is the x-coordinate, the second is the y-coordinate and the third and the fourth are the width and the height of the textbox. If I use this informations to place an image above the textbox, the image will be placed wrong:

Code:
XGraphics Graphic = XGraphics.FromPdfPage(Template.Pages[1]);

XImage image = XImage.FromGdiPlusImage((Bitmap)Parameter.ParameterValue);
Graphic.DrawImage(image, Imageformat[0], Imageformat[1], Imageformat[2], Imageformat[3]);


How can I place the image above the textbox?

Thank you for help!


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

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 7 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:  
Powered by phpBB® Forum Software © phpBB Group