• Visitor

    Visitor - 2013-02-25

    I'm trying to create a font type 3
    First I tried to create it using just

    (PDFontType3) PDFontType3.META.createNew();

    But obviously I didn't configured anything inside it.
    so I got a

    at de.intarsys.pdf.font.PDFontType3.getGlyphWidthEncoded(PDFontType3.java:147)

    then I got a pdf with font type3 inside to extract and reuse in another pdf
    but I got this error:

    java.lang.IllegalStateException: You can not merge objects from different documents
    at de.intarsys.pdf.cos.COSIndirectObject.registerWith(COSIndirectObject.java:514)

    Which is quite clear
    so I tried to reconstruct the new Font starting from the old font using this:

            PDFontType3 newfont  = (PDFontType3) PDFontType3.META.createNew();

    but I got this error:

    java.lang.IllegalStateException: object may only be contained once (use indirect object)
    at de.intarsys.pdf.cos.COSCompositeObject.associate(COSCompositeObject.java:94)
    at de.intarsys.pdf.cos.COSObject.addContainer(COSObject.java:214)

    so now I'm stuck at this point.

    how could I extract type3 fonts and re embed  in another PDF?

  • Visitor

    Visitor - 2013-02-25

    solved with this:

            PDFontType3 newfont  = (PDFontType3) PDFontType3.META.createFromCos(fontResource.cosGetObject().copyDeep());
  • mtraut

    mtraut - 2013-02-25

    Hi. Im glad you found a solution to your question - it is the right one!

    You can find an example that uses resources from another PDF file in the "Overlay" example, where a complete page content is drawn on the target page.

    The jPod PDF model is strictly attached to a document (compare the W3C DOM model). To use a part of one document, copy it and attach it to the new document. When making a copy, you must always be aware of the complex internal structure of PD level objects, that for example often have back references or references to some other resources you did not intend to copy.

    BTW. when you have an issue, you should always provide complete context. The constructor (PDFontType3) PDFontType3.META.createNew(); will never result in a NPE. This must be a follow up problem later in the context.


Log in to post a comment.