How do I make FastReport generate a PDF that's viewable on iOS?
Asked Answered
M

7

6

I am using FastReports, and its resulting PDFs cannot be read correctly on iOS. Because iOS reads PDF/A, which FastReports doesn't support. This is apparently a known bug in FastReports 4.0, and it will be fixed in FastReports 5.0. However, 5.0 is a long way away, and has been in development for years by now.

So my simple solution - and I'd prefer a simple as possible solution, so I can remove it again once FastReports 5.0 is out - right now is to simply print the existing PDF to another PDF. Can this be done without installing a PDF printer on the system and just use Delphi?

And if not, is there a converter that accepts PDF files and outputs PDF files?

Marmolada answered 7/5, 2013 at 11:29 Comment(16)
Actually, I was trying to avoid a Windows Printer. But editing PDFs might be worth searching for (I just need to avoid doing any actual editing).Marmolada
Your title is misleading. Question body states what you want to avoid PDF virtual printer.Epidemiology
You are right, 'print' in the title was misleading; I've changed it to 'convert' and added the appropriate tags. I added the 'fastreport' tag in the hope someone who uses FastReports were familiar with the issue, considering it is a problem for FastReports.Marmolada
Please explain more clearly in which respect the resulting PDF should differ from the source.Alleviate
It shouldn't. Or put in another way; it should become a PDF/A version or somehow capable of appearing on an iOS device. I do not intend to do any editing on the PDF, merely make a different sort of PDF, I suppose.Marmolada
iOS devices are not limitted to PDF/A (BTW, which flavour? There are three PDF/A standards (1, 2, and 3) each of them offering two or three subtypes (a, b, and u)). Furthermore depending on the original PDF sensible conversion to PDF/A variants may be impossible, especially automatic conversion.Alleviate
To be quite frank; I don't know. All I know is that the PDFs produced by FastReports works in Adobe Acrobat Reader, Evince and Foxit Reader on Windows and whatever Android uses to read its PDF files. Only iOS remains the exception (even if you install Adobe's Acrobat Reader on that platform). Then I learnt about something called PDF/A; I had no idea there were subflavours of that.Marmolada
Can you post a sample PDF file generated with FastReport so we can take a look at it? I'm curious to see such a file.Disadvantaged
Here is a sample report, I hope that helps: sviip.dk/report.pdf I apologise for the slightly lackluster design, but we are currently also working on redesigning and testing other things in regards to the reports.Marmolada
Oh gosh, this is embarrassing; I realised the problem was that I did not embed the fonts, after I showed it to the people in the #ghostscript channel. So I don't know how to close this question or which answer to chose. Because none of them actually solved my issue (they lead me there). But then again, I wasn't being specific about my issue with iOS; that the fonts were missing. And it would be rude now to edit the question to reflect that then answer it myself.Marmolada
@Marmolada You could just add your own answer explaining everything without changing the questionBibulous
In any case, PDF documents produced by FastReport are broken beyond belief. Their standard answer is that they cannot be viewed properly by other programs (like Firefox or Chrome preview) because they are not PDF/A, which is just bollocks. And their problems are not limited to fonts, but shapes as well. And they've been promising FR5 "any day soon" for years. Hopefully now that they have a bigger customer base they'll comply.Carbonaceous
I think you could edit the question to be "How do I make FastReport generate a PDF that's viewable on iOS?" It would open the door to add your own answer about including the necessary fonts, but it wouldn't invalidate the other answers about re-generating the PDF.Geochronology
@LeonardoHerrera +1 FR generated PDF files kills QuarkExpress instance on Mac while importing them. It's the worst PDF generator I've seen so far (but I love the report engine itself)Presentiment
@SirRufo - yeah, FastReport it's an incredibly good tool in so many aspects, except in this regard. Thankfully, it is extensible - I solved my problem with SynPDF (see my answer below.)Carbonaceous
Swearing in another language is still swearing :)Including
C
5

Try using SynPDF. It's open source, and its results are good, while managing file size to a very acceptable level. It produces PDF/A docs.

A Fast Report export unit can be found in the following location:

http://synopse.info/forum/viewtopic.php?id=781

Carbonaceous answered 7/5, 2013 at 15:2 Comment(4)
+1 This is the IMHO best solution (at least using Open Source library, without the need of an external printer or conversion tool). You do not need to convert the PDF, but generate it using either PDF/A docs, either embed the fonts.Lysol
Even though I answered this question myself, I will take this as the accepted answer, because it is the best solution. It is the most forward solution, and probably be the one I eventually implement, when other issues with my program aren't as pressing. :)Marmolada
Good to know! It's not difficult at all - you just make sure that, once you get the zip package with the needed files, go to the Synopse repository and download the latest version.Carbonaceous
SynPDF seems to work fine. Only trouble seemed to be it collided with our system that uses RTTI, but we figured out to disable several features in SynPDF that wasn't interesting to us, which made it work.Marmolada
M
3

I figured out my problem. To solution was to enable embedded fonts in the PDF, as I am using Tahoma and Arial, two fonts which are not available on iOS. I assume I had initially disabled this feature, to save filesize.

But I realise that I am comfortable sending a large file, even to iOS devices. So embedding fonts is the solution for me.

But I would like to give a mention to another answer by yms, which suggests using Helvetica (seeing as Tahoma and Arial are sans serif typefaces) as this is available on most platforms, including iOS. Or - perhaps as I gather from descriptions - part of the PDF engine rather than what lies on the platform.

However, despite this, I still think that to ensure that PDF is truly portable (P in PDF), one should embed all fonts, regardless of their availability. Because - who knows? - you might have some user with a PDF reader that doesn't. Oh and, it only counts for 'simple fonts', not CID fonts. CID fonts must be embedded.

In fact; as far as I understand Arial is an alias for Helvetica in the PDF spec, so it would load Helvetica instead; but it didn't work because it was a CID font.

Marmolada answered 7/5, 2013 at 14:46 Comment(1)
You can embed true-type fonts subset directly from FastReport, using a third-party PDF exporter, e.g. our Open Source SynPdf, as stated by this answer. No external printer, no PDF to convert. Direct output of a file content, as recognized by mobile devices.Lysol
E
1

Creating of PDF is technically editing of a new empty PDFl. The simpliest solution would be to "view PDFs" - render them to TBitmap - then copy it onto the new PDF's TCanvas. But that would kill all vector info... So probably the dummy load -> pretend editing -> save to new file would be able to do it

https://stackoverflow.com/search?q=%5Bdelphi%5D+PDF+edit - a lotta lot of PDF libraries discussed for Delphi, you can download them and try one after another, checking how different libraries fit to the kind and feature-reachness of documents you work with.

I did not marked this question a duplicate only because don't know which one would be best match here.

Exoergic answered 7/5, 2013 at 11:49 Comment(0)
N
1

Delphi, and most high level languages, allow for running subprocesses. You can use that to spawn and control ghostscript. I've successfully used this to read and convert pdfs from various proprietary, and broken, formats into properly constructed, smaller pdfs. There are quite a few options, so you will need to play around with it to get your settings correct.

Nomadic answered 7/5, 2013 at 12:25 Comment(6)
I think GhostScript might be along the lines of what I am looking for. I suppose I'd preferred it had been some sort of unit/class in Delphi, but I suppose I can live with that.Marmolada
@svip, I've found that most pdf libraries only provide basic features, or cost money. GS has been around forever, and will be the tool most able to read your input.Nomadic
It was; it just wasn't able to find my fonts (Tahoma and Arial), so that's sort of weird.Marmolada
@Marmolada yeah, telling it to find fonts is a bit of a pain. I've got the command line option needed buried somewhere, and I actually had to debug it with the Artifex people a year ago. There was a bug where it wasn't working correctly or something, but it got fixed in a recent version.Nomadic
The thing is; when I do not provide -sFONTPATH=, it complains as it runs through the file, but it produces a file (albeit with some textual errors; ø becomes ³, for instance). When I run it with -sFONTPATH="C:\windows\fonts\" there are no complaints, but it produces a single blank page.Marmolada
@Marmolada I don't remember what I did to get around those issues exactly, and I don't have the code at the moment. I'm pretty sure it's a font mapping issue,docs here, and you can also ask on the IRC channel. They are a great bunch of guys, just make sure you've read the docs first. :)Nomadic
H
0

I've not tried it personally, but Gnostice eDocEngine should do what you want.

http://www.gnostice.com/edocengine_vcl.asp

eDocEngine can create documents in clipboard, PDF, RTF, HTML, XHTML, EXCEL, TEXT, CSV, Quattro Pro, LOTUS 1-2-3, DIF, SYLK, TIFF, PNG, SVG (XML-based vector graphics), JPEG, GIF, BMP, EMF and WMF formats. eDocEngine ships with ready-to-use Report-Export interfaces that tightly integrate with popular Delphi reporting tools such as ReportBuilder, FastReport, Rave, QuickReport, and Ace Reporter.

Hibbard answered 7/5, 2013 at 11:44 Comment(0)
S
0

I was in a similar situation about 12 months ago and ended up buying llpdflib (http://www.llion.net/llpdflib.php) as I couldn't wait any longer for Fast Report VCL 5. It's been working very well producing PDF/A and much smaller sized PDFs.

Stallworth answered 7/5, 2013 at 13:31 Comment(0)
O
0

It's an old post, but we hat the same problem. We solved it with the components from http://www.wptools.de/. A little dll from the tool wpdf generates perfect pdf for windows, ios and android. The files show the font correct and are not so large.

Orton answered 27/2, 2014 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.