DOCX conversion to PDF issues
Posted: Mon Jul 23, 2018 12:31 am
I have tried a small piece of code I have got here in the blog to convert DOCX to PDF and I have tried. It works fine, it creates the PDF but the "look" of the contents is not the same as in the DOC. For instance, I can see some squares on every bullet that don´t exist in the original document. Lines in PDF that don´t exist in the DOC. Lines in the DOC that are not in the PDF. I have attached a document showing the errors I have found.
I am using 14.0.0.52. Were these errors solved in some latest version? Is there some workaround? The piece of code to convert I am using is:
public bool ConvertDocxToPDF (string inputFile, ref string errorMessage)
{
try
{
byte[] docx = File.ReadAllBytes(inputFile);
GdPictureDocumentConverter converter = new GdPictureDocumentConverter();
var status = converter.LoadFromStream(new MemoryStream(docx), GdPicture14.DocumentFormat.DocumentFormatOpenXMLWord);
if (status == GdPictureStatus.OK)
{
MemoryStream pdfdocument = new MemoryStream();
status = converter.SaveAsPDF(inputFile.Replace(".docx", ".pdf").Replace(".doc",".pdf"),PdfConformance.PDF);
if (status != GdPictureStatus.OK)
{
return false;
}
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}
I am using 14.0.0.52. Were these errors solved in some latest version? Is there some workaround? The piece of code to convert I am using is:
public bool ConvertDocxToPDF (string inputFile, ref string errorMessage)
{
try
{
byte[] docx = File.ReadAllBytes(inputFile);
GdPictureDocumentConverter converter = new GdPictureDocumentConverter();
var status = converter.LoadFromStream(new MemoryStream(docx), GdPicture14.DocumentFormat.DocumentFormatOpenXMLWord);
if (status == GdPictureStatus.OK)
{
MemoryStream pdfdocument = new MemoryStream();
status = converter.SaveAsPDF(inputFile.Replace(".docx", ".pdf").Replace(".doc",".pdf"),PdfConformance.PDF);
if (status != GdPictureStatus.OK)
{
return false;
}
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
return false;
}