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

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
lxman  
#1 Posted : Thursday, February 27, 2020 8:44:50 PM(UTC)
Quote
lxman

Rank: Member

Groups: Registered
Joined: 10/19/2017(UTC)
Posts: 14
United States
Location: North Carolina

Was thanked: 1 time(s) in 1 post(s)
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?

Edited by moderator Thursday, February 27, 2020 11:26:02 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Thursday, February 27, 2020 11:25:48 PM(UTC)
Quote
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 1,107

Thanks: 7 times
Was thanked: 130 time(s) in 127 post(s)
You must call the GenerateContent() method before saving the document
doc.Pages[0].GenerateContent();
https://pdfium.patagames...Page_GenerateContent.htm

Edited by user Wednesday, March 4, 2020 2:38:15 AM(UTC)  | Reason: Not specified

Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.