I am trying to convert .docx/.doc/.ppt/.pptx files to .pdf and I am using below code, but it has high benchmarking times. Do we have an estimate on avg conversion timings for 1MB, 5 MB, 10MB, 30 MB, 50MB and 100 MB files?
Is there a way to optimise the code or this conversion operation? I need to convert files up to 100 MB, any suggestion to optimise and minimise the time?
Gembox.Document ----
public byte ConvertDocToPdfViaGembox(byte docBytes)
{
// Set the license key
GemBox.Document.ComponentInfo.SetLicense(“FREE-LIMITED-KEY”);
using (MemoryStream docxStream = new MemoryStream(docBytes))
{
// Load the DOCX document from the MemoryStream
var document = DocumentModel.Load(docxStream, LoadOptions.DocxDefault);
// Create a MemoryStream to hold the output PDF
using (MemoryStream pdfStream = new MemoryStream())
{
// Save the document as PDF in the MemoryStream
document.Save(pdfStream, GemBox.Document.SaveOptions.PdfDefault);
byte[] pdfBytes = pdfStream.ToArray();
return pdfBytes;
}
}
}
Gembox.Presentation ----
public byte ConvertPptToPdfViaGembox(byte pptBytes)
{
// Set the license key
GemBox.Presentation.ComponentInfo.SetLicense(“FREE-LIMITED-KEY”);
// Load the PPT presentation from the MemoryStream
using (MemoryStream pptStream = new MemoryStream(pptBytes))
{
// Use the correct method to load the presentation from the MemoryStream
var presentation = PresentationDocument.Load(pptStream, GemBox.Presentation.LoadOptions.Ppt);
// Create a MemoryStream to hold the output PDF
using (MemoryStream pdfStream = new MemoryStream())
{
// Save the presentation as a PDF into the MemoryStream
presentation.Save(pdfStream, GemBox.Presentation.SaveOptions.Pdf);
byte[] pdfBytes = pdfStream.ToArray();
return pdfBytes;
}
}
}
Currently, we only have benchmark tests for loading and saving (reading and writing) DOCX files:
But in the future, we may add more tests for other formats as well:
Nevertheless, I must point out that saving a document to PDF requires more time and memory than saving it to DOCX. PDF conversion requires paginating and rendering the whole content, which is an expensive task.
Please send us the input files that reproduce your issue so we can investigate them.
You can send them to us via email or support ticket, see the Contact page.
Regarding the missing chart, to export a chart to PDF, you’ll need to include GemBox.Spreadsheet as well; please read our Chart example:
Sure, let me do that.
Also, could you help me in Gembox.Document. Mine is a .Net 8 application hoisted in a Linux container.
I am getting below error-
System.DllNotFoundException: Unable to load shared library ‘libHarfBuzzSharp’ or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you’re using glibc, consider setting the LD_DEBUG environment variable:
/app/runtimes/linux-x64/native/libHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.13/libHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/app/libHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/app/runtimes/linux-x64/native/liblibHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.13/liblibHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/app/liblibHarfBuzzSharp.so: cannot open shared object file: No such file or directory
/app/runtimes/linux-x64/native/libHarfBuzzSharp: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.13/libHarfBuzzSharp: cannot open shared object file: No such file or directory
/app/libHarfBuzzSharp: cannot open shared object file: No such file or directory
/app/runtimes/linux-x64/native/liblibHarfBuzzSharp: cannot open shared object file: No such file or directory
/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.13/liblibHarfBuzzSharp: cannot open shared object file: No such file or directory
/app/liblibHarfBuzzSharp: cannot open shared object file: No such file or directory
at HarfBuzzSharp.HarfBuzzApi.hb_buffer_create()
at HarfBuzzSharp.Buffer…ctor()
at …ctor()
at .(Object , Boolean , Double , )
at …ctor( )
at GemBox.Document.PdfSaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8e(DocumentModel , Stream , String )
at GemBox.Document.SaveOptions.67tg5rkvl9zwp8v7723mndgzuc3b4vj8e(DocumentModel , Stream , String , Boolean )
at GemBox.Document.DocumentModel.Save(Stream stream, SaveOptions options)
I tried converting a doc file to pdf but saw some formatting issues as attached.
Are there any param inputs that we have with Gembox that would allow us to adjust formatting for the converted tables?
Also, when I try to convert the file on deployed version(.NET 8 app hoisted in Linux container), I face the below error - System.InvalidOperationException: Cannot get a matching glyph typeface for font ‘Times New Roman’.
I am able to successfully convert on local machine in a console app but facing issue with this deployed version.
Note that this is a hidden (unlisted) version. To install it, you’ll need to run the above command on the NuGet Package Manager Console (Tools → NuGet Package Manager → Package Manager Console).
Does this solve your issue?
Regarding the error on Linux, this message indicates that you’re missing font files.
Please read our Docker example:
The problem occurs because that is an EMF image. Currently, GemBox.Document supports exporting EMF, WMF, and SVG images only on Windows.
In other words, your application needs to target the following:
<TargetFramework>net8.0-windows</TargetFramework>
We plan to add cross-platform support for exporting EMF, WMF, and SVG images. Unfortunately, at the moment I cannot tell you exactly when it will be implemented.
Please note that we prioritize feature request implementations by the number of users requesting them and currently we are working on some other features that have greater priority (more user requests).