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.

Wed Jan 29, 2020 3:07 pm

Hello
I'm testing Spire.Doc V8.1.10 and have to clone a document piece A.docx (see attachment) into another one.
The A.docx has a unique paragraph, which has a unique lettre (A) formatted with some "text effects" (calibri font, 72 pt, 1pt black border, no color fill).
Cloning this paragraph and saving it in docx format keeps effect but don't keep font (calibri 72 pt --> Time new roman 72 pt).
Cloning this paragraph and saving it in pdf format keeps font and size, but don't keep effect (black color fill).

My test code :
Code: Select all
    internal void Run()
    {
      string inputFileName = Path.Combine(Application.StartupPath, "A.docx");
      string outputDOCXFileName = Path.Combine(Application.StartupPath, $"A {DateTime.Now:yyyy-MM-dd HH-mm-ss}.docx");
      string outputPDFFileName = Path.Combine(Application.StartupPath, $"A {DateTime.Now:yyyy-MM-dd HH-mm-ss}.pdf");
      using (Document inputDoc = new Document(inputFileName))
      {
        Paragraph paragraph = inputDoc.Sections[0].Paragraphs[0];
        using (Document outputDoc = new Document())
        {
          Section section = outputDoc.AddSection();
          section.Paragraphs.Add(paragraph.Clone() as Paragraph);
          outputDoc.SaveToFile(outputDOCXFileName, FileFormat.Docx);
          Process.Start(outputDOCXFileName);
          outputDoc.SaveToFile(outputPDFFileName, FileFormat.PDF);
          Process.Start(outputPDFFileName);
          outputDoc.Close();
        }
        inputDoc.Close();
      }
    }

danielhalte1
 
Posts: 23
Joined: Sat Dec 14, 2019 12:50 am

Thu Jan 30, 2020 4:03 am

Hello,

Thanks for your message.
I did notice the issue you mentioned and posted it to our Dev team with the ticket SPIREDOC-3875 for further investigations. If there is any update, we will keep you informed. Sorry for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Mon Feb 10, 2020 8:16 am

Hello,

Greetings from E-iceblue.
After further investigation, since the source document uses the font in the default styles, please add CloneDefaultStyleTo() to copy the default style of source document to the target document firstly to keep the same font in saved .docx file. The below is full testing code.
Code: Select all
Document inputDoc = new Document(@"A.docx");
{
    Paragraph paragraph = inputDoc.Sections[0].Paragraphs[0];
    using (Document outputDoc = new Document())
    {
       
        Section section = outputDoc.AddSection();
        inputDoc.CloneDefaultStyleTo(outputDoc);
        section.Paragraphs.Add(paragraph.Clone() as Paragraph);
        outputDoc.SaveToFile(@"result.docx", Spire.Doc.FileFormat.Docx);
        outputDoc.Close();
    }
    inputDoc.Close();
}

And the font effect issue of generated PDF has not been resolved yet, our Dev team is still working on it. We will keep you informed regarding any available updates. Thanks for your patience.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1261
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc