Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
Embedding font subset vs. text align |
Post Reply |
Author | |
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
Posted: 01 Feb 13 at 1:50PM |
Hey everyone,
I'm trying to create a PDF/A document and I'm using AddTrueTypeSubsettedFont for font embedding. When I draw aligned text with DrawHTMLText and open the document in Adobe Reader, it displays left/center/right aligned text correctly, but instead of justified text it displays left aligned text. But when I try to select that text or move cursor in it, then it behaves like if there was justified text. When I use AddTrueTypeFont to embed a font, then the justification works correctly. But I want to avoid that function, because it produces too large PDFs. So when I embed a whole font, it works, when I embed a subset, it does not. Do I need to add some special character to the font subset, like a space or something, which is needed to draw the justified text? I'm using Quick PDF 9.11, Microsoft Visual C# 2008 Express Edition, Windows 7. Code snippet and picture below.
http://s18.postimage.org/q8pxktrs9/Justify.png Edited by LuProch - 04 Mar 13 at 12:00PM |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
you wrote the solution by yourself. You need to embed all characters, which you like to use. In your sample is a space between the a-words. Dont forget capitals, punctuation makrs ect. Cheers, Werner |
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
OK, so when I have that text containing just "a"-letters and spaces, then I have to embed "a" and " ". Which I did. But the justification doesn't work. So what other characters do I need to embed to make the justification work? I actually tried to embed all UTF characters from 0x0000 to 0xFFFF and it didn't help.
Edited by LuProch - 25 Feb 13 at 10:12AM |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
sorry, my first answer was wrong. I didnt see the blank in "a ". But I'll try it again. In your png all looks fine, without the justified text on bottom. So left, right an center is ok. First it looks, as you found an issue in QPL at DrawHTMLtext with align="justified". But its not sure. Try the correct HTML-spelling align="justify". It may be an mistake in the QPL-reference. If not so, use SetTextAlign in connection with DrawText, DrawWrappedText or DrawMultiLineText. Your have there different options for justify. I hope I could help now. Werner |
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
DrawHTMLtext only works with "justified", not with "justify".
And I need DrawHTMLtext to draw text, which has different parts in different font styles (normal/bold/italic/underline). If I wanted to use DrawText, I would have to split the text and write each part separately, am I right? |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
you are right. With Drawtext you have more to do (splitting as you assume), because you can't use text with different styles as a unit. Sorry, I see no easy way. But you should the wrong working "justified" report as issue to Debenu. Werner |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Can you try the following code which will make it simpler to understand and debug.
QP.SetOrigin(1); int ID = QP.AddTrueTypeSubsettedFont("Times New Roman", "abcd ", 1); QP.SetHTMLNormalFont("Default", ID); double w = 150; double ypos = 10; QP.DrawBox(10, 0, w, 800, 0); QP.SetTextSpacing(-10); QP.DrawHTMLText(10.0, ypos, w, "<font size=\"20pt\"><p align=\"left\">aaaaaaaa aaaaa aaaa aaaaa aaaaa aaaaa aaaaaaaaaaaa</p></font>"); ypos += 180; QP.DrawHTMLText(10.0, ypos, w, "<font size=\"20pt\"><p align=\"center\">bbbbbbbb bbbbb bbbb bbbbb bbbbb bbbbb bbbbbbbbbbbb</p></font>"); ypos += 180; QP.DrawHTMLText(10.0, ypos, w, "<font size=\"20pt\"><p align=\"right\">cccccccc ccccc cccc ccccc ccccc ccccc cccccccccccc</p></font>"); ypos += 180; QP.DrawHTMLText(10.0, ypos, w, "<font size=\"20pt\"><p align=\"justified\">dddddddd ddddd dddd ddddd ddddd ddddd dddddddddddd</p></font>"); ypos += 180; QP.SaveToFile("out.pdf"); Process.Start("out.pdf"); |
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
edvoigt:
I reported the issue to Debenu. AndrewC: I tried your code and played a little with the values. I changed all the "ypos += 180;" to "ypos += 110;", because spaces between texts were too big. Then I changed width and discovered a strange behavior: Justification seems to work when the width is small (w = 150), but not with bigger widths (w = 200). Width 150 Width 200 PS: Why did you use AddTrueTypeSubsettedFont with third parameter set to "1"? Documentation says it should be "0". (I tried both and it didn't affect the justification.) AddTrueTypeSubsettedFont PPS: I forgot to mention in my first post, that my values are in millimetres. Yours are in points. (I again tried both and it doesn't affect the justification, once you convert the values.) SetMeasurementUnits Edited by LuProch - 04 Mar 13 at 12:07PM |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
I later realised that your measurements were in mm.
AddTrueTypeSubsettedFont - should be 0. I have a bad habit of using 1 thinking that it will embed the font - but that is what the function is doing anyway. I also discovered the same behaviour with the various widths which is quite strange. I haven't been able to try down why it doesn't work as expected. I will keep working on it but have many other cases I am working on at the same time. Andrew.
|
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
I did some more experiments with the PDF file created with your code (w = 200).
CREATING When I create the file with QuickPDF DLL 9.11, 9.12 or 9.13, it doesn't change anything. DISPLAYING I tried to view the created file in Adobe, Foxit, Chrome and also with the Quick PDF Library application on the "PDF Preview" tab. Justification is not displayed correctly in: - Adobe Reader 10.1.6 - Foxit Reader 4.3.0.1110 - Google Chrome 25.0.1364.152 - Quick PDF Library application 9.11 - Quick PDF Library application 9.12 Justification is displayed correctly in: - Quick PDF Library application 9.13 PRINTING I tried to print the created file to printer with PrintDocument function from Quick PDF DLL. Justification is not printed correctly with: - Quick PDF DLL 9.11 - Quick PDF DLL 9.12 Justification is printed correctly with: - Quick PDF DLL 9.13 |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
This code is working correctly
int ID = QP.AddStandardFont(8); // Standard Font = Times New Roman QP.SetHTMLNormalFont("Default", ID); double w = 180; double ypos = 10; QP.DrawBox(10, 0, w, 800, 0); QP.DrawHTMLText(10.0, ypos, w, "<font size=\"20pt\"><p align=\"justified\">dddddddd ddddd dddd ddddd ddddd ddddd dddddddddddd</p></font>"); ypos += 180; QP.SaveToFile("out.pdf"); I believe it is because the AddTrueTypeSubsettedFont is creating a Composite font and Composite fonts do not support the PDF WordSpacing operator that we are using to space the text out correctly. I will need to spend some time to see if I can work on a work-around for subsetted fonts but it the existing HTML code could require some fundamental changes for rendering justified text. Andrew
|
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
In summary:
- AddTrueTypeFont: Produces too big PDF files with embedded fonts. - AddTrueTypeSubsettedFont: Justification of HTML text doesn't work. - AddStandardFont: Offers only the few standard fonts. Also first line of text is shifted up and line spacing is smaller. I'm starting to be a bit desperate here... Nevertheless, thank you both for your help. I hope this issue will be eventually resolved in Quick PDF library. Edited by LuProch - 07 Mar 13 at 11:25AM |
|
LuProch
Beginner Joined: 01 Feb 13 Status: Offline Points: 14 |
Post Options
Thanks(0)
|
So my last option was to use AddStandardFont, but I found out that some letters with diacritics are missing in the resulting PDF file. I'm doomed.
Code snippet: (I put it in a picture, because my browser didn't display the letters with diacritics correctly either.) http://s12.postimage.org/voeep7qn1/Diacritics_code.png Result: http://s23.postimage.org/kpds3xshn/Diacritics.png Edited by LuProch - 07 Mar 13 at 3:43PM |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
The upcoming QPL 9.14 Beta 2 will support justified text using TrueType subsetted fonts that also include foreign characters such as German and French characters with diacritics etc.
Andrew. Edited by AndrewC - 27 Mar 13 at 1:05AM |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store