Aspose.PDF (.Net版本)PDF转.doc格式时候没有左边距,内容会紧紧贴在文档左侧,而Docx格式正常示例文档(转换前后).zip (776.8 KB)
您好,同一个文件,PDF转.docx格式正常,转.doc就会左边没有间距。
try
{
Document pdfDocument = new Document(path);
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow;
string fileSaveName = savePath + “\” + Path.GetFileNameWithoutExtension(path);
if (convertType == “保持编辑”)
{
saveOptions.Mode = DocSaveOptions.RecognitionMode.Textbox;
}
if (saveType == “DOCX”)
{
saveOptions.Format = DocSaveOptions.DocFormat.DocX;
fileSaveName += “_out.docx”;
}
else
{
fileSaveName += “_out.doc”;
}
saveOptions.RelativeHorizontalProximity = 2.5f;
saveOptions.RecognizeBullets = true;
lock (objLock)
{
pdfDocument.Save(fileSaveName, saveOptions);
}
}
catch (Exception ex)
{ }
我们使用以下代码生成DOC文件,空间没有任何差异。 您能否与生成的文件共享比较截图。
DOCdocx.jpg
try
{
if (Aspose.Pdf.Document.IsLicensed)
{
Console.WriteLine("License set successfully.");
Document pdfDocument = new Document(dataDir + "+¡-++-+¦.pdf");
DocSaveOptions saveOptions = new DocSaveOptions();
saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow;
saveOptions.Mode = DocSaveOptions.RecognitionMode.Textbox;
//saveOptions.Format = DocSaveOptions.DocFormat.DocX;
saveOptions.RelativeHorizontalProximity = 2.5f;
saveOptions.RecognizeBullets = true;
pdfDocument.Save(dataDir + "Aspose.PDF_19.8.doc", saveOptions);
}
else {
Console.WriteLine("License not set!");
}
}
catch (Exception ex)
{
}
当保存为doc格式的时候,使用saveOptions.Mode = DocSaveOptions.RecognitionMode.Flow才会出现格式问题。而使用saveOptions.Mode = DocSaveOptions.RecognitionMode.Textbox格式是正常的。
格式异常截图.png (119.3 KB)
格式正常截图.png (118.3 KB)
你回复的Flow_Textbox.zip压缩包中的Flow_Aspose.PDF_19.8.doc文件,你打开文档后,没发现文档是有问题的吗?明显和Textbox_Aspose.PDF_19.8.doc不一样啊,有问题的文档是不局中的,是紧挨着左侧的,没有左边距的。你不明白我意思的话,就看下我给你回复的格式异常截图.png标红的部分。