pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Petzold <zakkings...@gmail.com>
Subject Re: TTF embedding issue
Date Tue, 19 Sep 2017 19:46:42 GMT
Hi,

thanks, that (Type0Font.java) was exactly the missing link I needed.
Also CID 0 is required as you mentioned. I end up with a method like

public Map<Integer, Integer> readCidToGidMap(PDCIDFont descendantFont)
throws IOException {
    Map<Integer, Integer> cidToGid = new HashMap<>();

    // first add 0
    cidToGid.put(0, 0);

    for (int code = 0; code < 65535; ++code) {
        if (descendantFont.hasGlyph(code)) {
            cidToGid.put(descendantFont.codeToCID(code),
descendantFont.codeToGID(code));
        }
    }
    return cidToGid;
}

With this map and the code from

org.apache.pdfbox.pdmodel.font.PDCIDFontType2Embedder#buildCIDToGIDMap
org.apache.pdfbox.pdmodel.font.PDCIDFontType2Embedder#buildCIDSet

both validation problems vanished. My PDF is valid PDF/A now for
pdfbox, veraPDF and Adobe Preflight. Certainly good enough for me :)

Many thanks!

On Tue, Sep 19, 2017 at 6:21 PM, Tilman Hausherr <THausherr@t-online.de> wrote:
> Hi,
>
> The two methods in PDCIDFontType2Embedder are "isolated" and both work with
> a cidToGid map. You need to create that yourself, have a look at
> Type0Font.java in the PDFDebugger subproject. The lower part of the
> constructor calls readMap() which builds a table that has CID and GIDs so
> you should modify that to your need.
>
> When done, you should check your file not just with PDFBox preflight but
> also with verapdf.
>
> If you need more help, please share your file (upload to sharehoster) and
> the code you've written. I suspect you may have to add CID 0 manually.
>
> Tilman
>
>
>
> Am 19.09.2017 um 09:05 schrieb Jan Petzold:
>>
>> Hi Tilman,
>>
>> thanks for your quick reply.
>>
>> The goal is indeed to create PDF/A documents. It is just a single
>> file. I was able to fix/bypass all other issues reported, the only
>> remaining ones are those I mentioned.
>>
>> Regarding
>>
>>> this would require to create the two items (CIDToGIDMap and CIDSet) from
>>> the existing font subset.
>>
>> Can you give me some idea on how to do that? I saw the code in
>> PDCIDFontType2Embedder but not sure how to "apply" it to my existing
>> PDF.
>>
>> Thanks a lot!
>>
>> On Tue, Sep 19, 2017 at 7:35 AM, Tilman Hausherr <THausherr@t-online.de>
>> wrote:
>>>
>>> What exactly is your assignment? Convert some files so that they are
>>> PDF/A-1b? Because you wrote "I'm trying to convert" but not to what.
>>>
>>> Is it just that one file, or many?
>>>
>>> Making files PDF/A compatible isn't just fixing some fonts... there may
>>> be
>>> many issues. Callas and PDF-Tools have software for that.
>>>
>>> Re the two issues you mention, this would require to create the two items
>>> (CIDToGIDMap and CIDSet) from the existing font subset. Would be some
>>> hours
>>> of work, but possible... maybe look at the file with PDFDebugger whether
>>> the
>>> font shows something useful re GIDs. See also PDCIDFontType2Embedder for
>>> how
>>> it is calculated...
>>>
>>> What you did likely didn't work because it was subsets.
>>>
>>> Tilman
>>>
>>>
>>> Am 19.09.2017 um 07:21 schrieb Jan Petzold:
>>>>
>>>> Hi, I'm new to pdfbox. I'm trying to convert an existing PDF which
>>>> uses an embedded OpenSans font
>>>> (https://fonts.google.com/specimen/Open+Sans) and receive these errors
>>>> from preflight:
>>>>
>>>> 3.1.9: Invalid Font definition, FZUADF+OpenSans: mandatory CIDToGIDMap
>>>> missing
>>>> 3.1.11: Invalid Font definition, FZUADF+OpenSans: The CIDSet entry is
>>>> missing for the Composite Subset
>>>>
>>>> Everything else seems to be fine, but for these I don't really have a
>>>> starting point. I can modify the source font (TTF file) if I have to,
>>>> the question would be how to do that and what exactly.
>>>>
>>>> I also tried to just replace the embedded font with a new one
>>>> (basically iterate through PDF pages, get the resources, replace fonts
>>>> with my new ones) which "fixes" the error but results in a garbage
>>>> document not displaying valid text.
>>>>
>>>> Any advice would be very welcome :)
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Mime
View raw message