Excellent thanks Tilman & team.

~Matt

On 24 March 2018 at 21:55, Tilman Hausherr <[email protected]> wrote:

> Am 24.03.2018 um 19:37 schrieb Matt Pryor:
>
>> Hi Tillman
>>
>> Okay, sure I'd be happy to help test.
>>
>> Below is what I've written for a new class OS400FontDirFinder, although I
>> haven't had a chance to test it on our AS400 to double check if the files
>> out of /QIBM can be read like normal files or if I need to use the JT400
>> toolkit to access the files (as is the case with some folders), which
>> might
>> complicate things. Hopefully I'll test on Monday and get back to you.
>>
>
> Issue created:
> https://issues.apache.org/jira/browse/PDFBOX-4165
>
> Snapshot available:
> https://repository.apache.org/content/groups/snapshots/org/a
> pache/pdfbox/pdfbox-app/2.0.10-SNAPSHOT/
>
> Tilman
>
>
>
>
>> package org.apache.fontbox.util.autodetect;
>>
>> public class OS400FontDirFinder extends NativeFontDirFinder {
>>
>> public OS400FontDirFinder() {
>> // TODO Auto-generated constructor stub
>> }
>>
>> @Override
>> protected String[] getSearchableDirectories() {
>>            return new String[] { System.getProperty("user.home") +
>> "/.fonts", // user
>>                  "/QIBM/ProdData/OS400/Fonts"
>>            };
>> }
>>
>> }
>>
>> And this was my change to determineDirFinder() in FontFileFinder:
>>
>>      private FontDirFinder determineDirFinder()
>>      {
>>          final String osName = System.getProperty("os.name");
>>          if (osName.startsWith("Windows"))
>>          {
>>              return new WindowsFontDirFinder();
>>          }
>>          else
>>          {
>>              if (osName.startsWith("Mac"))
>>              {
>>                  return new MacFontDirFinder();
>>              }
>>              else if (osName.startsWith("OS/400")) {
>>              return new OS400FontDirFinder();
>>              } else
>>              {
>>                  return new UnixFontDirFinder();
>>              }
>>          }
>>      }
>>
>> On 23 March 2018 at 19:35, Tilman Hausherr <[email protected]> wrote:
>>
>> Am 23.03.2018 um 18:07 schrieb Matt Pryor:
>>>
>>> Hi again Tillman
>>>>
>>>> Believe I sorted this by copying the AS400 fonts folder into
>>>> System.getProperty("user.home")/.fonts
>>>>
>>>> If I wanted to provide an OS400 implementation of NativeFontDirFinder to
>>>> look in the right place, and modify FontFileFinder to use it, what's the
>>>> best way of doing it?
>>>>
>>>> Either modify directly by creating an OS400FontDirFinder that is
>>> assigned
>>> in FontFileFinder, or assign your own fontmapper to FontMappers.set().
>>> (this is somewhat complicated, so I suggest you use the workaround you
>>> mentioned, and let us implement something for OS/400 for version 2.0.10
>>> and
>>> higher).
>>>
>>> If you're willing to test, I'll create an issue.
>>>
>>> Tilman
>>>
>>>
>>>
>>>
>>>
>>>
>>> Thanks for your help
>>>> Matt
>>>>
>>>>
>>>>
>>>>
>>>> On 23 March 2018 at 16:11, Matt Pryor <[email protected]
>>>> >
>>>> wrote:
>>>>
>>>> Thanks Tillman, none of those folders exist, and after a little research
>>>>
>>>>> it seems that there are supposed to be true-type fonts in this folder:
>>>>>
>>>>> /QIBM/ProdData/OS400/Fonts/TTFonts/
>>>>>
>>>>> Although we don't have any, possibly because it's an optional extra
>>>>> which
>>>>> we haven't installed yet.
>>>>>
>>>>> Are truetype fonts what you look for?
>>>>>
>>>>> The os.name system property is "OS/400".
>>>>>
>>>>> Unable to find the .pdfbox.cache file at present, not sure where it's
>>>>> being written to.
>>>>>
>>>>> Thanks again for your help, much appreciated.
>>>>>
>>>>> Matt
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 22 March 2018 at 20:24, Tilman Hausherr <[email protected]>
>>>>> wrote:
>>>>>
>>>>> Hello Matt,
>>>>>
>>>>>> Your attachments don't go through. But what I can tell you is that 1.8
>>>>>> had many errors in rendering, so the many differences are usually not
>>>>>> a
>>>>>> bug, but an improvement.
>>>>>>
>>>>>> The case you describe ("but it looks nothing like Courier") could be
>>>>>> because of missing fonts on your system so the "Liberation Sans"
>>>>>> fallback
>>>>>> is used. Try to have Courier, Arial/Helvetica, Times, Symbol and Zapf
>>>>>> Dingats in your font directory.
>>>>>> Another possibility is that fonts are not found. Please post the
>>>>>> .pdfbox.cache from the user directory. Does this file have all the
>>>>>> fonts on
>>>>>> your system? If not, please tell what directories to search.
>>>>>>
>>>>>> To find out more, have a look at
>>>>>> \fontbox\src\main\java\org\apache\fontbox\util\autodetect\
>>>>>> UnixFontDirFinder.java
>>>>>> and the other "finders" in the package.
>>>>>>
>>>>>> It has
>>>>>>
>>>>>>           return new String[] { System.getProperty("user.home") +
>>>>>> "/.fonts", // user
>>>>>>                   "/usr/local/fonts", // local
>>>>>>                   "/usr/local/share/fonts", // local shared
>>>>>>                   "/usr/share/fonts", // system
>>>>>>                   "/usr/X11R6/lib/X11/fonts" // X
>>>>>>           };
>>>>>>
>>>>>> If that one isn't enough, please tell where the fonts are, and tell
>>>>>> also
>>>>>> what System.getProperty("os.name") returns.
>>>>>>
>>>>>> Tilman
>>>>>>
>>>>>>
>>>>>> Am 22.03.2018 um 20:24 schrieb Matt Pryor:
>>>>>>
>>>>>> Hello
>>>>>>
>>>>>>> I'm resending this from the address I'm subscribed with, so hope it
>>>>>>> doesn't appear twice.
>>>>>>>
>>>>>>> We use PDFBox in our software which runs on IBM system i / AS400s to
>>>>>>> convert PDF files to TIFFs. We have many users who are on older JVMs,
>>>>>>> such
>>>>>>> as 1.5, so have to maintain code for them as well as people on newer
>>>>>>> JVMs.
>>>>>>>
>>>>>>> We recently swapped over to PDFBox 2.0.8 for users who are on JRE 1.6
>>>>>>> or
>>>>>>> above and have had complaints from customers about the fonts
>>>>>>> changing.
>>>>>>> The
>>>>>>> issue does not occur when I test in a Windows environment but does on
>>>>>>> the
>>>>>>> iSeries JVM.
>>>>>>>
>>>>>>> I have attached two sample TIFF files, the first is generated with
>>>>>>> PDFBox 1.8 and the second with PDFBox 2.0.8 (named accordingly)
>>>>>>>
>>>>>>> I put logging output in the SetFontAndSize class and confirm that
>>>>>>> it's
>>>>>>> using "Courier-Bold" in 2.0.8, but it looks nothing like Courier.
>>>>>>>
>>>>>>> This is the code to create a BufferedImage from the PDF pages, which
>>>>>>> then gets inserted into the TIFF file
>>>>>>>
>>>>>>> PDFBox 1.8 code:
>>>>>>> ==============
>>>>>>>
>>>>>>>       int imageType = BufferedImage.TYPE_INT_RGB;
>>>>>>>
>>>>>>> int resolution = (int) PRINTER_RESOLUTION;
>>>>>>>
>>>>>>> PDDocument document = PDDocument.load( pdf );
>>>>>>>
>>>>>>> List<PDPage> pages =
>>>>>>>
>>>>>>> (List <PDPage>) document.getDocumentCatalog().getAllPages();
>>>>>>>
>>>>>>>       int pagesSize = pages.size();
>>>>>>>
>>>>>>>       for (int i = 1 - 1; i < pagesSize; i++) {
>>>>>>>
>>>>>>> PDPage page = pages.get(i);
>>>>>>>
>>>>>>> BufferedImage image = page.convertToImage(imageType, resolution);
>>>>>>>
>>>>>>> ….
>>>>>>>
>>>>>>>       }
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> PDFBox 2.0.8 code:
>>>>>>> ================
>>>>>>>
>>>>>>>       PDDocument document = PDDocument.load( pdf );
>>>>>>>       PDPageTree pagetree = document.getDocumentCatalog().
>>>>>>> getPages();
>>>>>>>       int pagesSize = pagetree.getCount();
>>>>>>>       PDFRenderer pdfRenderer = new PDFRenderer(document);
>>>>>>>       for (int i = 1 - 1; i < pagesSize; i++) {
>>>>>>>           PDPage page = pagetree.get(i);
>>>>>>> BufferedImage image = pdfRenderer.renderImageWithDPI(i, 200,
>>>>>>> ImageType.RGB);
>>>>>>>           ...
>>>>>>>       }
>>>>>>>
>>>>>>> I'm hoping someone might be able to point me in the direction of
>>>>>>> what's
>>>>>>> going wrong or perhaps give me a better idea about how PDFBox
>>>>>>> generates or
>>>>>>> gets fonts. I realise the platform that I'm running on is rather
>>>>>>> obscure!
>>>>>>>
>>>>>>> Many thanks in advance
>>>>>>> --
>>>>>>> Matt Pryor
>>>>>>>
>>>>>>> The International Presence Group of Companies
>>>>>>>
>>>>>>> EMAIL:[email protected] <mailto:[email protected]>
>>>>>>>
>>>>>>> URL:www.International-presence.com <http://www.international-pres
>>>>>>> ence.com/>
>>>>>>>
>>>>>>>
>>>>>>> ------------------------------------------------------------
>>>>>>> ---------
>>>>>>> To unsubscribe, e-mail: [email protected]
>>>>>>> For additional commands, e-mail: [email protected]
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>> Matt Pryor
>>>>>
>>>>> The International Presence Group of Companies
>>>>>
>>>>> EMAIL: [email protected]
>>>>>
>>>>> URL: www.International-presence.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>


-- 
Matt Pryor

The International Presence Group of Companies

EMAIL: [email protected]

URL: www.International-presence.com

Reply via email to