PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 16, 2024 1:36 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu May 16, 2024 4:35 am 
Offline

Joined: Thu May 16, 2024 4:24 am
Posts: 1
I encountered two problems:
The first question is why the font is not changed after embedding the value into the pdf

Code:
  XFont font2 = new XFont("DFKai-SB", 12, XFontStyle.Regular);

                XmlDocument xml = new XmlDocument();
                xml.LoadXml(nodeList.Item(i).OuterXml);
                MemoryStream modifiedStream = new MemoryStream();
                PdfDocument inputDocument = PdfReader.Open(new MemoryStream(pdfTemplate), PdfDocumentOpenMode.Modify);
                PdfPage page = inputDocument.Pages[0];
                XGraphics gfx = XGraphics.FromPdfPage(page);
                //  inputDocument.AddCharacters(font2);
                foreach (XmlNode node in xml.DocumentElement.ChildNodes)
                {
                    if (node is XmlElement)
                    {
                        string fieldName = string.Format("topmostSubform[0].Page1[0].{0}[0]", node.Name);
                        PdfTextField field = inputDocument.AcroForm.Fields[fieldName] as PdfTextField;
                        if (field != null)
                        {
                            field.Font = font2;
                            field.Value = new PdfString(node.InnerText);
                        }

                    }
                }






The second question is how to set up this coordinate system? What are the units of the x-axis and y-axis? Is it (pixel)?

Code:
 gfx.DrawImage(image, posx, newPosY, image.PixelWidth * 0.3, image.PixelHeight * 0.3);


After I converted the itextsharp program to pdfsharp, I found that the image position was not in the correct position.



------------
Thanks to everyone who offered to answer questions


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2024 5:20 am 
Offline

Joined: Thu May 16, 2024 5:17 am
Posts: 1
Hello anyone, can anyone answer this question? I'm looking for a solution because I have the same problem. If anyone has one, please tag me. Thanks a lot.mp3 juice tubidy y2mate


Top
 Profile  
Reply with quote  
PostPosted: Thu May 16, 2024 6:31 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 940
Location: CCAA
onc1030 wrote:
The second question is how to set up this coordinate system? What are the units of the x-axis and y-axis? Is it (pixel)?
The are no pixels in PDF.
See also:
viewtopic.php?p=9343#p9343

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


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

All times are UTC


Who is online

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