Hot answers tagged

9

Here this is my code which i used in my wordpress site in custom post type for adding the pdf to the post and its work for me try to change its and use it. Hope it will help function add_custom_meta_boxes() { add_meta_box('wp_custom_attachment', 'Hotel Brochure', 'wp_custom_attachment', 'hotel_post', 'normal', 'high'); } add_action('add_meta_boxes', ...


4

If I'm not totally mistaken, the code you have given on your update won't work, because the file/mime type pdf isn't supported by the WP_image_editor class called by wp_get_image_editor(). Creating a thumbnail from a uploaded pdf file can be achieved though. Below code gives you a insight in a possibility how to do it, I commented all the important things ...


4

WP-MPDF has always worked extremely well for me and has a decent templating system you can override. Thanks!


3

I was half way through writing a long answer explaining why there weren't any ... when I found one. WP Post to PDF is a plugin, updated for WP 3.3.2, that generates PDFs locally and caches them for later.


2

Yes it's possible. File upload is a default feature of WordPress. You don't need to use plugins for this. Read how to upload files in WordPress.


2

Right now, the support for tagging media is pretty disappointing. You can add tags or categories to the attachment post type, but you'll find the UI is unacceptably bad (it's a text box where you enter terms separated by commas). There's a plugin Media Tags that is decent though, so you might look into that. GravityForms is nice for front-end uploading, but ...


2

Thanks to @BrianFegter comment, I was able to find and fix the problem. It was just a problem of case-sensitivity. My development environment, http://serverpress.com/products/desktopserver/ , doesn't have a problem with finding the pdf when the file name was caps and the anchor tag link was in lower case. My hosting provider seems to be the problem though, ...


2

The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file. <?php if (have_posts()) : the_post(); $pdf_title = $post->post_title; $pdf_src = get_attached_file($post->ID ); $bytes = filesize( $pdf_src ); header("Pragma:...


2

Your question seems pretty specific to your situation, and while there might be a plug-in out there that can achieve what you're looking for, it probably won't fill all your needs without some hackery. So, have you considered creating a profile view on the front end and just setting up a print stylesheet for it? You could pass the user's ID to the page as ...


2

If you are talking about menus and your theme uses the Menu API, then upload the PDF to a publicly accessible server-- doesn't have to to be the one your site uses-- then go to Appearance -> Menus, Navigate to a menu, or create one find the "Links" dialogue, input the URL and the link text Save


2

Using add_rewrite_endpoint <?php if ( ! class_exists( 'PDFRewriteEndpoint' ) ): class PDFRewriteEndpoint { /** * Add actions and filters in constructor. */ public function __construct() { add_action( 'parse_request', array ( $this, 'sniff_requests' ), 0 ); add_action( 'init', array ( $this, ...


2

Well, I think you only need to modify the favicon.ico file in your WordPress root directory. Previous answer: I guess you want to change this icon (/wp-includes/images/media/document.png): that shows up for PDF documents in the Media Library. You could then use the wp_mime_type_icon filter to change the icon: add_filter( 'wp_mime_type_icon', function( $...


2

Possibilities to fetch attachments WordPress saves files not only to a physical disk, but as well as attachment post type into your MySQL/MariaDB database. This means you have two possibilities to query for uploaded files and you have to chose what you need in which scenario/context. Filesystem only To loop through all files or a specific type in a ...


2

I've found what's been missing in the code. You have to add this also: add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' ); function mycustom_wpcf7_mail_components( $components ) { $components['attachments'][] = get_template_directory().'/pdf/test.pdf'; return $components; } Now everything is working fine and the file is ...


2

The preview images for PDF documents are created within wp_generate_attachment_metadata() [src]. The full size preview image will have the -pdf.jpg extension [src]. The preview images info for the PDF document is stored in _wp_attachment_metadata in the post meta table. Here's an example data for a test.pdf document: Array ( [0] => Array ( ...


1

You cannot restrict users from downloading a file from a path using a wordpress login for various reasons, the most important is that the WP login is handled by PHP while the download is handled via Apache. That said, there is a way to achieve the result of what you're after. What you need to do is write a custom download handler for your PDFs. There are ...


1

Your approach does not provide security. I could hand-craft a cookie named "wordpress_logged_in" (containing any arbitrary value) and have access to your PDF files. You may want to rethink your solution to put a PHP script in between the files and the users. e.g. User Clicks download button PHP Script handles fetching document If authenticated user, PHP ...


1

Instead of attaching the attachments to body content. Pass it as separate parameter. Like the below one. @wp_mail($to, $subject, $msg, $headers,$mail_attachment); I guess it solves your problem.


1

To summarize the discussion in the comments, the answer for the question as it is asked is that it is not possible. The web standards as they are right now do not have a facility to declare a favicon for PDF files, only for the whole domain via the favicon.ico file. You can try to hack around it by set the favicon.ico at the root of the site to the icon ...


1

You can use the Custom URL field, to modify the attachment link for each one of your gallery images: where this is supported by the following plugin: <?php /** * Plugin Name: Custom Attachments Links * Description: Adds a new media field, to override the default attachment links. * Plugin URI: http://wordpress.stackexchange.com/a/176668/26350 ...


1

I've got it fixed: I needed to add the wp-load file that contains all the WP-functions include('../../../../../wp-load.php'); global $post; $id = $_GET['id']; $content_post = get_post($id); $content = $content_post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); Now the content ...


1

The only reliable cross browser solution is to embed the .pdf in a iframe. add_filter('media_send_to_editor', 'my_pdf_embed', 20, 3); function my_pdf_embed($html, $id) { $attachment = get_post($id); //fetching attachment by $id passed through $mime_type = $attachment->post_mime_type; //getting the mime-type if ($mime_type == 'application/...


1

If you're using Apache, you can add something like this in your .htaccess file AddType application/octet-stream .pdf This will force everything with a .pdf extension to download instead of display in the browser. If however you are not using Apache or if you want only certain files to download and others to display directly, you could use PHP to do this. ...


1

Your question interested me a bit. I haven't attempted to print profile fields before; but I could certainly see it's uses. So: Other than try to explain everything involved; I have made a simple plugin on GitHub. Simply follow the installation instructions; and it will provide you with a basic template for further modifications, if you like. It can ...


1

That looks like it is a template file. If so, the function add_header_info is hooked into send_headers long after send_headers had fired. You will need to move that code so that it executes earlier. It should work from a mu-plugin file, a plugin file or from your theme's functions.php. However, $FileType and those other variables are going to be out of ...


1

I just got this working last night using the above code (and the extra comment) and there are a few things I'd like to add here. First, in the "To get the PDF" section, 'wpcf-brochure' should be changed to 'wp_custom_attachment'. Next, to answer the final question from OP, to make it appear in the back end, here's the technique I used. Before the line ...


1

Yes, this can be done in WordPress. Check out http://wp.tutsplus.com/tutorials/allow-users-to-submit-images-your-site/ for some code examples. You will have to modify the logic to suit your needs of course, but the above link should get you pointed in the right direction.


1

You should set your MIME types for your pdf. 'application/pdf' and/or 'application/x-pdf' sorry for the quick answer, no time to go into detail but this should get you on the way


1

I'd say you're gonna need external assistance... Zend Framework https://stackoverflow.com/a/4520725 $pdf = Zend_Pdf::load($pdfPath); echo $pdf->properties['Title'] . "\n"; echo $pdf->properties['Author'] . "\n"; XMP PHP Toolkit https://stackoverflow.com/a/8862702 XMP Toolkit PHP Extension is a PHP module which includes the Adobe XMP Toolkit ...


1

Also - check out PressBooks ... http://pressbooks.com/ I've used it for one of my ebooks and it's great ... also does Kindle and Nook file formats.


Only top voted, non community-wiki answers of a minimum length are eligible