libharu

Discussion in 'iOS Programming' started by jagatnibas, Sep 27, 2011.

  1. jagatnibas macrumors regular

    Joined:
    Jul 28, 2008
    #1
    i am using libharu to write some texts to pdf file.

    i am putting file size as a4, so what's the pixel wise width and height ?

    when i do

    HPDF_Page_TextOut(page1, 50.00, 50.00, [str UTF8String]);
    it starts writing from down to up rather than up to down


    i also need some hint in writing multiline texts wordwrapping kind of.

    thanks in advance
     
  2. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #2
    There is no intrinsic size in pixels. It depends on the pixels-per-inch used to render the page. For example, if you render an A4 page at 150 ppi, the resulting image would be 1240px by 1754px. The same page rendered at 660 ppi would be 4962px by 7014px.


    I don't know libharu. You know iOS itself can produce PDF files right? http://developer.apple.com/library/...gPrintingiOS/GeneratingPDF/GeneratingPDF.html
     
  3. jagatnibas thread starter macrumors regular

    Joined:
    Jul 28, 2008
    #3
    Thanks, I used following code to successfully write text into pdf and abandoned libharu. But the problem here is, I see symbols like hyphen, and aphostrophe is getting converted to some garbage characters ! How to rectify that ?

    Code:
    CGContextSelectFont (pdfContext, "Helvetica-Bold", kHeadingFontSize, kCGEncodingMacRoman);
    CGContextShowTextAtPoint (pdfContext, 55, line_point, keytext, strlen(keytext));
    
     
  4. jiminaus macrumors 65816

    jiminaus

    Joined:
    Dec 16, 2010
    Location:
    Sydney
    #4
    If I use your code it works fine with this:
    Code:
    CGFloat kHeadingFontSize = 12.0f;
    CGFloat line_point = 50.0f;
    const char* keytext = "He said, 'Hello-world'!";
    
    What is keytext? More importantly what encoding is keytext?
     
  5. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #5
    Stay away from ShowTextAtPoint. It expects your text to be in MacRoman. You can use the standard NSString string drawing methods to draw your text into the context.
     

Share This Page