Print Page | Close Window

PDF Font Display Issue

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3674
Printed Date: 22 Nov 24 at 7:57PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: PDF Font Display Issue
Posted By: ysr
Subject: PDF Font Display Issue
Date Posted: 11 Feb 19 at 12:40AM
I have a PDF file that uses MSLineDraw (Embedded Subset) font to show lines and borders.

For this file, if I write a text using DrawText, all the borders drawing are getting messed up and after writing, it shows only the Helvetica font in the Document properties Font List.

Also I noticed this issue happens not just with DrawText and even if I use SetTextSize (without writing anything using that size), this issue happens.

I have already tried NormalizePage, TransformFile, CombineContentStreams etc without much luck.



Replies:
Posted By: Ingo
Date Posted: 11 Feb 19 at 9:29AM
Hi ysr,

few things to keep in mind...
QuickPDF works with unicode.
Fonts used before and after have to be the same to get comparable results.
If you need an external font inside the library you have to add it (AddTrueTypeFont).
Regarding lines we have DrawLine in the library:
https://www.debenu.com/docs/pdf_library_reference/DrawLine.php

HTH Ingo




-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 11 Feb 19 at 10:12PM
Hi Ingo,

Thank you very much for your reply.

The existing font is MSLineDraw and the Encoding is shown as "Built In" (When I view the font details via Adobe properties screen).

I am not trying to draw any line. On this file, even if I just call SetTextSize(12) and save the file, all the previous fonts are getting removed, only Helvetica font is added and the contents get messed up.


Posted By: Ingo
Date Posted: 12 Feb 19 at 10:39AM
Regarding the issue "fonts" you should read in the developer guide at chapter 4.15 and further.
http://www.debenu.com/docs/pdf_library_developer_guide/foxit_quick_pdf_library_15_developer_guide.pdf

The library supports only some standard fonts. In the developer guide you'll find these fonts.
If you need additionally fonts for a matching layout you have to add these fonts as font files.

If you have an external pdf file and want to know if there's a font file inside (not referenced) then you can use function "HasFontResources".

If we should check your pdf document for similar results with our routines you should upload the pdf anywhere posting the link here.



-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 13 Feb 19 at 6:35AM
Hi Ingo,

The sample file is available at http://203.89.208.176/samplefile.pdf

For this, If I do a draw text the file gets messed up. I do not think it is the way I am using drawtext or adding fonts, as it works with every other file.


Posted By: Ingo
Date Posted: 13 Feb 19 at 7:42AM
Hi,

i did the download and will check it within few days.
Perhaps another one here will do the same.
The problem will be the used font i think...



-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 14 Feb 19 at 9:11AM
Thank you very much Ingo. Really appreciate the support especially on a community forum.


Posted By: Ingo
Date Posted: 14 Feb 19 at 7:02PM
Hi Yoganathan,

what i've done so far...
I've checked your file with my PDF-Analyzer.
There is one font referenced: CourierNew.
There is one font embedded: MSLineDraw.

Then i've added a page number at the bottom, on the right side "page 1 from 1".
I didn't select a font doing this.
QuickPDF took "Times Bold" - Now i've a second font referenced in the pdf.
My rendered preview wasn't messed up - it still looks well layouted.

What you should do before drawing text into a new (for you new) pdf document:

1. Using CombineContentStreams:
https://www.debenu.com/docs/pdf_library_reference/CombineContentStreams.php
2. Using NormalizePage:
https://www.debenu.com/docs/pdf_library_reference/NormalizePage.php

Then you shouldn't have problems like described here.



-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 14 Feb 19 at 7:34PM
Hi Ingo,

Thank you very much for that. I did use both of those functions and also tried various others such as BalanceContentSTreams etc without much luck. I assume I may not be using them in the right order or with right parameters.

Would it be possible to share the sample code that worked for you?


Posted By: Ingo
Date Posted: 14 Feb 19 at 8:06PM
Hi,


mmmmh... here it is but i fear this won't help you much.

// . . .
   QP  := TDebenuPDFLibrary1611.Create;
   try
      Save_Cursor   := Screen.Cursor;
      Screen.Cursor := crHourglass;    // Show hourglass cursor

      QP.LoadFromFile(Edit1.text, '');
      QP.SetTempPath(tpath);

      If QP.EncryptionStatus > 0 Then
         QP.Decrypt;

//-- if rb5 checked = true ... new page numbering at the bottom

      if rb5.Checked = True Then
         begin
            QP.SetOrigin(1);
            QP.SetMeasurementUnits(0);
// . . .
            sfont := QP.AddStandardFont(10);
// . . .
            QP.SelectFont(sfont);
// . . .
            If ( Trim(combocolor.Text) = 'red' ) or ( Trim(combocolor.Text) = 'rot' ) Then
               QP.SetTextColor(1,0,0);
// . . .
            for i := 1 to QP.PageCount do
                begin
// . . .
                   QP.SelectPage(i);
// . . .
                   QP.SetTextSize(StrToInt(snrufg.Text));
// . . .
                   QP.DrawText(StrToInt(snrpos.Text), QP.PageHeight - ( 3 + StrToInt(snrufg.Text) ), gtxt);
                end;
            QP.SetMeasurementUnits(0);
         end;
//-------------------------------------------
   finally
// . . .




-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 14 Feb 19 at 8:44PM
Thanks Ingo

 A couple of questions though

1) On this code you are not using NormalizePage or CombineContent streams. Did it work without those?
2) How do you save the file at the end? I use SaveToFile to overwrite the same file.


Posted By: Ingo
Date Posted: 14 Feb 19 at 9:21PM
Normalize and combine are at another place more at the top ...
I'm using the normal Save from QuickPDF.

Yes. It CAN work without Normalize and Combine... but not for all files.
If there's a file with rotate nnn included then it won't work proper without Normalize...




-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 14 Feb 19 at 9:28PM
Shouldn't the CombineContentstreams need to be done after loading the file and NormalizePage for each file rather than at the top?


Posted By: Ingo
Date Posted: 14 Feb 19 at 10:18PM
I MEAN AFTER LOAD!
With "at the top" i mean not in the code range i've copied but before.
Please read the online reference, the online samples, the developer guide, ...




-------------
Cheers,
Ingo



Posted By: ysr
Date Posted: 08 Mar 19 at 2:14AM
Just for the benefit of others who may have similar issue, with the help of Debenu (Foxit) support team we found:

1) The file had the page media box and page resources defined outside of page object
2) By calling BalancePageTree(0) once the file is loaded, we managed to fix the issue.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk