Sign In  Sign Up Live-Chat

Automatic font substitution without exception

Last post 09-07-2007, 1:58 PM by Hans.firefox. 4 replies.
Sort Posts: Previous Next
  •  09-04-2007, 10:59 PM 93510

    Automatic font substitution without exception

    Attachment: Present (inaccessible)

    Is there any way to force Aspose PDF to throw an exception if a substitute font is required? Take this XML for example:

        <Text IsSpaced="true" LineSpacing="1.8">
          <Segment FontName="Arial" FontSize="12">Line 1</Segment>
        </Text>
        <Text IsSpaced="true" LineSpacing="1.8">
          <Segment FontName="Arial-Bold" IsTrueTypeFontBold="true" FontSize="12">Line 2</Segment>
        </Text>


    The font Arial-Bold gets silently changed to Times-Bold, I would much prefer it threw an exception then do this automatically so it's easier to correct especially if you use a memory stream so you don’t even see the XML file.

    Background: Above XML generated by Aspose Words, from word document template I believe this was caused by copy & pasting some text from elsewhere which MS Word formatted with this strange font name. As you can see the attached word document opens fine.

    Attached Copy of word document, xml produced, pdf produced

     
  •  09-05-2007, 2:39 AM 93529 in reply to 93510

    Re: Automatic font substitution without exception

    Hi,

    Thank you for considering Aspose.

    Well, right now the architecture is like that if there is some Font name present in the XML and that Font is not installed on the system or this Font name is fake, then Aspose.Pdf converts and take that font as a default Font, i.e "Times New Roman". But in case of Word to Pdf conversion, if this XML is generated by Aspose.Words, then please let them(Aspose.Words) know that why it is generating a Font name that doesn't exist.

    For us it is difficult to throw an exception as usually user won't like to see a crash during conversion and for normal user it is difficult to identify the problem. But I will discuss this with the developers about the oppurtunity to throw an exception, if Font doesn't exist or not installed and will let you know soon.

    Hope you understand.

    Thanks.

     
  •  09-05-2007, 4:05 AM 93542 in reply to 93529

    Re: Automatic font substitution without exception

    Thanks, please could you move this to the Aspose.Words forum.

    I realise you can’t satisfy everyone since I fully agree people will be upset if it suddenly breaks existing applications. But at the same time if a user has a special font on his desktop but not on the server they would want to know what went wrong.

    ·        Perhaps you could have a strict mode which defaults to false

    ·        A warnings class which gets populated for any assumptions

    I don’t mind if you don’t fix it now I know about the problem, but new users might not be so patient.

     
  •  09-05-2007, 4:57 AM 93551 in reply to 93542

    Re: Automatic font substitution without exception

    I have logged this issue as PDFNET-3688. We will add a new property Pdf.IsFontNotFoundExceptionThrown. The default value is false. If this property is set to true, FontNotFoundException will be thrown when font not found.
    Tommy Wang
    Lead Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
  •  09-07-2007, 1:58 PM 94022 in reply to 93542

    Re: Automatic font substitution without exception

    Attachment: Present (inaccessible)
    Hi,

    Please try the attachment. It will satisfy your requirement.
    We have added a new property Pdf.IsFontNotFoundExceptionThrown. Its default value is false. If you want to throw out exception when error FontName is specified, you just need to add the following codes before the Save() method, Like:
      ...
      pdf1.
    IsFontNotFoundExceptionThrown = true;
      pdf1.Save(...);

    This
    property is also supported in xml, you can set it true like this:
      Pdf xmlns="Aspose.Pdf" IsFontNotFoundExceptionThrown="true">

    Best regards.
    Hans


    Hans Zhang
    Product Developer
    Aspose Changsha Team
    About Us
    Contact Us
     
View as RSS news feed in XML