PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

PDFsharp-Questions about font settings and image coordinate
http://forum.pdfsharp.de/viewtopic.php?f=2&t=4593
Page 1 of 1

Author:  onc1030 [ Thu May 16, 2024 4:35 am ]
Post subject:  PDFsharp-Questions about font settings and image coordinate

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

Author:  thompson70 [ Thu May 16, 2024 5:20 am ]
Post subject:  Re: PDFsharp-Questions about font settings and image coordin

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

Author:  TH-Soft [ Thu May 16, 2024 6:31 am ]
Post subject:  Re: PDFsharp-Questions about font settings and image coordin

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

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/