logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Post a reply
From:
Message:

Maximum number of characters in each post is: 32767
Bold Italic Underline   Highlight Quote Choose Language for Syntax Highlighting Insert Image Insert an existing Attachment or upload a new File... Create Link   Unordered List Ordered List   Left Justify Center Justify Right Justify   Outdent Indent   More BBCode Tags
Font Color Font Size
Security Image:
Enter The Letters From The Security Image:
  Preview Post Cancel

Last 10 Posts (In reverse order)
Paul Rayman Posted: Thursday, February 27, 2020 8:25:48 PM(UTC)
 
You must call the GenerateContent() method before saving the document
doc.Pages[0].GenerateContent();
https://pdfium.patagames...Page_GenerateContent.htm
lxman Posted: Thursday, February 27, 2020 5:44:50 PM(UTC)
 
I am trying to draw up a simple app to show how to change the font size of a PdfTextObject. What I have thus far:

Code:
    public partial class Form1 : Form
    {
        public Form1()
        {
            PdfCommon.Initialize("");
            InitializeComponent();
        }

        private void BtnLoad_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog ofd = new OpenFileDialog
            {
                AutoUpgradeEnabled = true,
                CheckFileExists = true,
                CheckPathExists = true,
                ReadOnlyChecked = true,
                DefaultExt = "pdf",
                DereferenceLinks = true,
                SupportMultiDottedExtensions = true,
                ShowHelp = false,
                Multiselect = false,
                ShowReadOnly = false,
                Title = "Please select a PDF file."
            })
            {
                DialogResult dr = ofd.ShowDialog();
                if ((dr == DialogResult.Yes) || (dr == DialogResult.OK))
                {
                    PdfDocument doc = PdfDocument.Load(ofd.FileName, new PdfForms());
                    doc.Pages[0].PageObjects.OfType<PdfTextObject>().First().FontSize += 20;
                    doc.Save(@"C:\temp\Output.pdf", SaveFlags.RemoveUnusedObjects);
                }
            }
        }
    }

This is just a rough draft, obviously - no error checking, etc.

The point is, when I get down to line 30, I can see the FontSize property of that particular object does in fact change. And when I look at the two PDF's (source and saved) they are in fact different file sizes. But physically, when I open the output file, I see no difference in that PdfTextObject at all.

I've also tried changing the matrix, and also am unable to change the output's appearance.

Am I just taking the wrong approach here?