Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Mon Mar 07, 2022 7:08 am

Hi,

Is there an option to export the word to PDF but make it to letter format.

I see there is an option to set pagesize to Letter. Do you have option for setting it to Fit to Page before its saved to pdf.

Thank you

AmisHealth
 
Posts: 8
Joined: Fri Apr 21, 2017 5:59 am

Mon Mar 07, 2022 7:47 am

Hello,

Thanks for your inquiry!

Sorry that we do not have the option to set the paper size setting of the page when convert the Word file to PDF, even in the Microsoft Word, the option setting of it does not have the paper size setting.
ConvertOptionsForWord.png

Actually, we generate the PDF relate on the paper size of each section in the Word file, the only way to change the PDF paper size is changing the size of Word section. If you do not want to change the paper size of the Word, you can reset the size after converting it to PDF refer to the following code. Hope you can understand.

Code: Select all
            Document document = new Document();
            document.LoadFromFile("E:\\testdoc\\doc2.docx");
            Dictionary<Section , SizeF > Section_size = new Dictionary<Section , SizeF >();
            foreach (Section section in document.Sections)
            {
                Section_size.Add(section, section.PageSetup.PageSize);
                section.PageSetup.PageSize = PageSize.Letter;
            }
            document.SaveToFile("res.pdf");
            foreach(KeyValuePair<Section, SizeF> keyValue in Section_size)
            {
                keyValue.Key.PageSetup.PageSize = keyValue.Value;
            }


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Mar 11, 2022 7:28 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc

cron