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();
}
}