Hello,
I am starting some experiments with PoDoFo 0.9.5 on Windows. I'd say that for
what I saw of the code, peeking at it while preparing it to build in my
environment, it looks very good, and it seems to cover all my needs.
Though very initial tests reveal something that might prove complex to
overcome, unless I am making something awfully wrong (on this platform -
Windows).
Using this test code, which is essentially the short demo code:
using namespace PoDoFo;
PdfStreamedDocument document("test.pdf");
PdfPage* pPage =
document.CreatePage(PdfPage::CreateStandardPageSize(ePdfPageSize_A4));
PdfFont* pFont = document.CreateFont("Arial");
pFont->SetFontSize(18.0);
PdfPainter painter;
painter.SetPage(pPage);
painter.SetFont(pFont);
painter.DrawText(56.69, pPage->GetPageSize().GetHeight() - 56.69,
"Accentués... Chiffres 0123456789!");
painter.FinishPage();
document.GetInfo()->SetTitle(PdfString("Hello World"));
document.Close();
(A)
(A.1) I get a test.pdf of 535 KB (!). It renders good, and Adobe Reader
confirms ArialMT embedded (which explains the size of the file). But I have to
produce smaller files than that.
(A.2) So to test subsetting, I replace the above CreateFont() by:
PdfFont* pFont = document.CreateFontSubset("Arial", false, false);
Now the test.pdf file is between 16 and 17 KB. The size shrinks heavily on
this test containing very few characters, that's expected. Again the file looks
good, Acrobat Reader and Mac Preview confirms ArialMT partially embedded, no
substitution done for display.
[ Side note: I'm writing code on Windows, but regarding PDF output I always
test / assess their output validity / quality on Mac with Adobe Reader and
macOS Preview App. If my Windows produced files do the job when displayed or
printer there, they most probably are good for use. :) ]
(B)
Now I'm running the same tests with "Consolas".
(B.1) With CreateFont("Consolas") the file is about 250 KB. It renders good
(just as with Arial) and nothing suspect in the font properties displayed by
Acrobat.
(B.2) Using CreateFontSubset("Consolas", false, false);
The file is about 12 KB.
But it displays white (no text visible at all) on Acrobat and partially on the
Mac Preview app (only the text "Accentués... Chiffres" but not the digits
themselves), yet Acrobat confirms "Consolas, partial embedding, Truetype, no
substitution", just as it did for Arial.
I don't know yet what goes wrong. Is it the subsetting which goes wrong? Does
it go wrong due to whatever specifics in the Consolas font (which I don't
know/suspect about)?
What path would you suggest me to follow to get deeper on this?
(C)
What steps should I take to NOT embed a font at all (knowing the consequences
of it being substituted right or wrong on display/print)?
I sometimes like to not embed at all because I control the process which builds
the file, sends it away and the process that receives it and prints it and both
*have* available the fonts that I selectively choose not to embed. The
advantage is the file produced is *very* small (should be about 1 to 2 KB for
the above test snippet, using other PDF writing tools as a comparison).
Aside from this I spotted some C++ details, while using a C++14 and a C++17
environment, which you might want to consider adjusting (if not already done in
trunk: I'm using the 0.9.5 archive, not checking out subversion yet). I'll
write another post about these C++ details a bit later.
Thanks a lot for any comment or hint anyone could offer to help get these first
steps. I have used other libraries over these last years for this kind of work,
so I know a small bit about these matters, just need to get properly acquainted
with PoDoFo specifics. Switching to PoDoFo would simplify some things for me:
because it apparently offers all the features for which I need different
libraries today, and because it is written in C++, like any other code I emit.
--
Best Regards, Meilleures salutations, Met vriendelijke groeten,
Olivier Mascia
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users