Skip navigation
Currently Being Moderated

How to get font attributes(height,width,name, type) of a PDF or PDF page?

Nov 18, 2011 12:02 AM

Hi,

 

I am developing a plugin which writes data in a particular location in a pdf.  First I was using hardcoded font width and height as well as other font attributes like name (CourierStd), type(Type-1) etc. But now want to get these font attirbutes according to the pdf on which my plugin is doing the processing. I am not able to figure out any API to extract text from the pdf and then use that text to get the font attributes.

Can anyone please suggest a way to get the font attributes used in pdf or a particulsr pdf page???

 

Thanks in advance.

 
Replies
  • Currently Being Moderated
    Nov 18, 2011 4:53 AM   in reply to poortip87

    The PDFEdit APIs will give you that information.

     

    From: Adobe Forums <forums@adobe.com<mailto:forums@adobe.com>>

    Reply-To: "jive-1375850423-8igo-2-2eggi@mail.forums.adobe.com<mailto:jive-1375850423-8igo-2-2eggi@mail.forums.adobe.com>" <jive-1375850423-8igo-2-2eggi@mail.forums.adobe.com<mailto:jive-1375850423-8igo-2-2eggi@mail.forums.adobe.com>>

    Date: Fri, 18 Nov 2011 00:03:03 -0800

    To: Leonard Rosenthol <lrosenth@adobe.com<mailto:lrosenth@adobe.com>>

    Subject: Re: How to get font attributes(height,width,name, type) of a PDF or PDF page? How to get font attributes(height,width,name, type) of a PDF or PDF page?

     

    How to get font attributes(height,width,name, type) of a PDF or PDF page?

    created by poortip87<http://forums.adobe.com/people/poortip87> in Acrobat SDK - View the full discussion<http://forums.adobe.com/message/4033746#4033746

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 11:04 PM   in reply to lrosenth

    Are you saying that the only way to get these attributes to access them programmatically?  That is, write a javascript program?  What happened to context menu properties?  Doesn't Acrobat support that capability?

     

    -- Roy Zider

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 17, 2012 11:26 PM   in reply to FUBARinSFO

    You are in a developers forum, so we gave you a developer;s answer.

     

    If you are asking about simple user, manual access to such information, then you should consult the Acrobat forum.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 1:27 AM   in reply to lrosenth

    You missed your calling, irosenth.  You should have been a lawyer.  The helpful response is to 1) give a complete answer, such as here's how you do it in user space, and 2) answer the question I posed. Since you're a developer, surely you know the answer.

     

    Surely you don't think somebody is going to write some code in order to check the typeface of a pdf he is trying to copy or reference, unless it's absolutely necessary, do you?

     

    In any case, I happen to be working through many of the issues surrounding the use of this API, and they're not pretty.  Simple solutions are always welcome.

     

    -- Roy Zider

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 2:08 AM   in reply to FUBARinSFO

    I do standards – it's similar :).

     

    But I am still not understanding your need.

     

    A PDF doesn't have font attributes nor does a PDF page.  Only the actual text on a page have such attributes.

     

    So not really sure what you are asking about.

     

    Also, you haven't told us the development environment/language/platform you are working with.  Also, are you planning to work with Acrobat or Reader or the Adobe PDFLibrary.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 9:57 AM   in reply to lrosenth

    Iosenth:

     

    I was adding my comment to the query of the original poster. In his post, he was looking to identify the fonts and attributes of a pdf page at a particular point (" a particular location in a pdf. ")

     

    The question was not answered.  Your response was "The PDFEdit APIs will give you that information". I didn't understand the associated links, as they appear to be email links, not links to helpful answers.  But I did understand your answer to be, effectively, RTFM.  That answer you characterized as a "developer's answer".  Did I get that right?

     

    In my case, I've found that Microsoft Word 2007 doesn't seem to do a very good job of translating or mapping some Adobe PDF fonts into installed fonts.  In particular, the Adobe Javascript Reference uses CourierStd for code snippets -- which come out on Word not mapped to Courier New but rather to some other roman font. 

     

    I know the font on the PDF is CourierStd because Word says its font is 'Courier Std", not because I was able to pluck it from the PDF.  Right clicking for a context menu properties of a selection doesn't yield a 'Properties' selection, so the user can't identify the font he or she is looking at.  At least I wasn't able to do it, and that is the gist of my interest in this original post.

     

    I don't think it's reasonable to write a program to have to do this, but of course if it can't be done otherwise, and hasn't been impleted yet in the tenth turn of the version crank of Acrobat, then reference to the API will be necessary.  But even then, RTFM does not appear to me to be particularly helpful.

     

    -- Roy

     

    Message was edited by: FUBARinSFO

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 2:12 PM   in reply to FUBARinSFO

    MSWord 2007 doesn't support reading PDF files – so how would it be translating or mapping fonts from a PDF??

     

    Are you using some program to convert PDF to Word?  If so, what program?  Adobe Acrobat?  What version?

     

    If you use the Edit Object or Touchup Text tool in Acrobat, you can select pieces of text, right click for Properties and see what font (etc.) has been used.   This has been part of Acrobat since at least version 5.

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 18, 2012 6:24 PM   in reply to lrosenth

    Yes, that's true.  Word 2007 does not read PDF files.

     

    Perhaps it was not clear, but when you document a js file by writing the documentation in Word, you sometimes have occasion to cite code snippets from the JS API reference. Copy/paste into Word of the text selection in the PDF results in the mismatch, because CourierStd/Courier Std is what Word 'says' is the font it has pasted into the docx, but is the name and not the actual font it is using (since it's not installed). 

     

    Both the Edit Object Touchup Text tools do the job.  Thanks -- that's what I was looking to solve.  Would have been nice to just be able to paint the selection and get the Properties from the context menu, but this is better than writing a script to reference the API, don't you think?

     

    Seems Adobe could have improved on this since version 5, but then maybe things move a bit more slowly in Adobe-land than elsewhere.

     

    -- Roy Zider

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points