Get a failure when converting PUB to PDF

we got an error:

Aspose.Pub.Exceptions.ConvertException: Can't create PDF font with name = Times New Roman --> PDF: Font Times New Roman was not found
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zunhvw5McAVAr(TextStyle #=zCFq1_x4=, Document #=zv8$WPwE=)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zH8ZVcbwFYk8r(TextGroup #=zZ2j_HO3rp3qU, Document #=zv8$WPwE=, Font& #=zfOHLuwY=, Single& #=zrVbfsKA=)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zYimk8Ff2_iHAAWwVJg==(TextParagraph #=zk82vTjD6a7KWSuM1Xw==, ParagraphStyle #=zOgCvhJWg_C9m, #=z6d0_Z8naPx3sAZJSlf9Co$I= #=zKtHbdUU=, #=zSFF19$ivcc9nGxRwFYGRxBA= #=z_2FLBQY=)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=z$oL3Ewt3a2lFmtL1pD2DsX4=(#=zoNEWlDHW7qyz #=zxAWwgrg=, #=z6d0_Z8naPx3sAZJSlf9Co$I= #=zKtHbdUU=, Double #=zgF4feI0oVwpI, #=zSFF19$ivcc9nGxRwFYGRxBA= #=z_2FLBQY=)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=z23rDfy2kkee4(#=zSFF19$ivcc9nGxRwFYGRxBA= #=z_2FLBQY=, #=z6d0_Z8naPx3sAZJSlf9Co$I= #=zKtHbdUU=, TextBuilder #=zkq0lhAiG6n8e, Double #=zRY$NWdwSDTC2, Double #=z1AEf4PZHWBgY)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=z$eqbAaJpO3mK(#=zzawfAvMYq$Muxlf5A37CUQ4= #=zrgpOPi0=, Page #=zqDCwvF6IOgFo, #=zSFF19$ivcc9nGxRwFYGRxBA= #=z_2FLBQY=, TextBuilder #=zkq0lhAiG6n8e, Double #=zRY$NWdwSDTC2, Double #=z1AEf4PZHWBgY)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zMo4YDgs=(#=zzawfAvMYq$Muxlf5A37CUQ4= #=zrgpOPi0=, Page #=zqDCwvF6IOgFo, #=zSFF19$ivcc9nGxRwFYGRxBA= #=z_2FLBQY=, TextBuilder #=zkq0lhAiG6n8e, Double #=zRY$NWdwSDTC2, Double #=z1AEf4PZHWBgY)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zsh9tBonsY0Pv(Boolean& #=zcOFCMx4=, String& #=zVn45uwI=)
   at #=zsedkhgG8ahbpm5MGaxElEpPK9w6z.#=zIuWcqwE=()
   at #=zYUisVULSEYhE3h46FLG1PeY=.ConvertToPdf(Document #=zv8$WPwE=, Stream #=zbaLrUyon3CiD)

Code:

var parser = PubFactory.CreateParser(stream);
var document = parser.Parse();
using var pubStream = new MemoryStream();
PubFactory.CreatePdfConverter().ConvertToPdf(document, pubStream);

It was run in Linux server, and it can’t be allowed that install the font in Linux server, could we have any workarounds for this case?
Actually, we only want to get the text from a pub file, we don’t care about Font.

@Kent.Sun

  1. The error occurs because Aspose.Pub attempts to use the ‘Times New Roman’ font during PDF conversion, but this font is not present in the Linux environment .
  2. Aspose.Pub does not offer a built-in method to substitute missing fonts during PDF generation, resulting in a ConvertException when the required font is unavailable .
  3. There is no direct workaround provided in the context for handling missing fonts in PUB to PDF conversion on Linux without installing fonts system-wide .

Since you only need the text content and not the formatting, consider extracting text directly from the PUB document using document.GetText() after parsing, bypassing the PDF conversion entirely .

@Kent.Sun

Would you please share your sample PUB file for our reference? We will log an investigation ticket and share the ID with you.

@asad.ali

  1. The error occurs because Aspose.Pub attempts to use the ‘Times New Roman’ font during PDF conversion, but this font is not present in the Linux environment . This leads to a ConvertException when the required font is unavailable .

  2. Aspose.Pub does not offer a built-in method to substitute missing fonts during PDF generation, which results in the failure you’re experiencing . Since you are unable to install fonts on the Linux server, this limitation impacts your ability to convert the PUB file to PDF directly.

  3. A workaround for extracting text without font formatting is to use document.GetText() after parsing the PUB document, bypassing the PDF conversion entirely . This approach allows you to retrieve the textual content without needing to render the document into PDF format.

If you’d like further assistance, please share a sample PUB file for deeper investigation .

New Microsoft Publisher Document.zip (5.4 KB)

Hi @asad.ali, uploaded, thanks for your assistance.

@Kent.Sun

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PUBNET-440

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.