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 15, 2021 7:22 pm

I am attempting to save a PDF with the following code:

Code: Select all
var pdfDoc = new PdfDocument();
pdfDoc.LoadFromBytes(file);
var widget = pdfDoc.Form as PdfFormWidget;
var fields = widget.FieldsWidget.List;

            using (var ms = new MemoryStream())
            {
                pdfDoc.SaveToStream(ms, FileFormat.PDF);

                var model = new UploadDynamicDocumentViewModel
                {
                    DocumentData = doc,
                    File = Convert.ToBase64String(ms.ToArray())
                };

                if (uploadedDoc != null)
                {
                    model.CustomerDocumentId = uploadedDoc.Id;
                }
                return View(model);
            }


This is not preserving the font sizes (for text boxes) that are already embedded into the PDF document.

This code does preserve the font sizes:

Code: Select all
pdfDoc.SaveToFile("C:\\Users\\mike.henry\\Desktop\\mike.pdf");


What can I do to preserve the font sizes for text boxes when saving to stream?

jmhenry5150
 
Posts: 1
Joined: Fri Mar 12, 2021 4:01 pm

Tue Mar 16, 2021 2:26 am

Hello,

Thanks for your inquiry.
I simulated a PDF file with several textboxes and tested your case, but did not reproduce your issue. Please provide us with your input file and your output file to help us investigate further. You can upload them here or send them to us (support@e-iceblue.com) via email. Thanks in advance.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Mar 26, 2021 7:17 am

Hello,

Has your issue been resolved? If not, could you please provide your input file to us for further investigation?

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.Doc