WordPress.org

Forums

[resolved] Extra spaces in vcard download file (5 posts)

  1. miowebdesigns
    Member
    Posted 10 months ago #

    I have a vcard program that I have never used within WordPress. It is the basic vcard creation that you can find on any website.

    print <<<END
    BEGIN:VCARD
    VERSION:3.0
    N:$last;$first;$middle;;;
    FN:$fullname
    TITLE:$title
    PHOTO;VALUE=URL;TYPE=JPG:$path$photo
    ORG:$office
    TEL;WORK;VOICE:$tel
    TEL;WORK;FAX:$fax
    EMAIL;TYPE=PREF;INTERNET:$attorney_email
    ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;$address=0D=0A$address2;$city;$state;$zip;$country;
    URL;TYPE=WORK:http://criminallawsexcrimessacramento.com/
    END:VCARD
    END;
    
    $output = ob_get_contents();
    
    header('Content-Type: text/x-vcard');
    header('Content-Disposition: attachment; filename=vCard_' . $filename . '.vcf');
    echo trim($output);
    exit();

    The problem is the output has extra leading zeros. When I use this code on a php site, not WordPress, the output has no extra spaces. Not sure why the extra spaces are happening or how to remove them. As you can see in the code I am using trim().
    example of file
    "
    BEGIN:VCARD
    VERSION:3.0
    N:Daly;Kresta;N.;;;
    FN:Kresta N. Daly
    TITLE:Partner
    PHOTO;VALUE=URL;TYPE=JPG:http://kd.bothwip2013.com//images/attorney_photos/kresta-image.png
    ORG:Sacramento
    TEL;WORK;VOICE:(916) 440-8600
    TEL;WORK;FAX:(916) 440-9610
    EMAIL;TYPE=PREF;INTERNET:kdaly@barth-daly.com
    ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;431 I Street, Suite 201=0D=0A;Sacramento;CA;95814;United States;
    URL;TYPE=WORK:http://criminallawsexcrimessacramento.com/
    END:VCARD"

    Thanks for any suggestions.
    Michael

  2. miowebdesigns
    Member
    Posted 10 months ago #

    Here is the solution: I found a plugin, hcard-vcard-generator-wordpress-plugin. I modified that to accept my files data and it worked fine.

    Thanks for all the help.

  3. dalemoore
    Member
    Posted 10 months ago #

    Hi miowebdesigns,

    Sorry to hijack your thread, but I can't find any other way to contact you. You posted a year ago for the plugin WP-Property with this problem: https://usabilitydynamics.com/products/wp-property/forum/topic/add-file-attachment/ and I was wondering how you solved it? I've been wracking my brain trying to figure out why it outputs every attachment instead of just that post's, and the plugin's owner's aren't very responsive. Thanks if you can help.

  4. miowebdesigns
    Member
    Posted 10 months ago #

    Dale,
    I ended up using add media to include a download. Then I used a little CSS to make it look nice. It was a lot easier than I made it out to be. Hope this helps.

  5. dalemoore
    Member
    Posted 10 months ago #

    Ah, I see. I also used Add Media to attach the PDF, but I can't for the life of me figure out how to get it to show in the property overview for each listing. It shows just fine in the details/single property layout, but not in the overview. None of the attachment code I normally use works. Thanks for your response.

Reply

You must log in to post.

About this Topic

Tags