Attach pdf
Attach pdf
Has anyone been able to successfully implement the attachment of a .pdf document to an item? I would like to include "sample pages" - I have tried to convert a pdf to a jpg and attach it as an additional picture but because of the size it blew up the page.
Bryan Bundgaard
AC7 User http://www.SchoolSupplyStore.com
AC7 User http://www.SchoolSupplyStore.com
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Attach pdf
I'm getting ready to try it for it to display on a page. We are able to add it as a link in a description field after uploading it in the images section. It came out with a URL like http://www.directpaintball.com/Assets/icon_x.pdf. Boss doesn't have an ftp program so that gives him a way to upload it in the admin, then link to it.
I'll post back if I find any kind of conversion to image that keeps the size down.
I'll post back if I find any kind of conversion to image that keeps the size down.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Attach pdf
I know this was a long time ago but I was wondering if there was ever any solution to this. @Bryan, (if you still come here) I didn't notice any attached to your books on your site so this leads me to believe it never happened.
Problem is, the store I building right now has to have safety manuals available to download for each specific product, and I have found no way to create a field that allows the admin to upload a pdf specific to the product and then display this download link on the product page.
This HAS to be possible. The other carts I normally use can do this so I know AC can as well since other carts aren't doing anything special that AC can't do.
Problem is, the store I building right now has to have safety manuals available to download for each specific product, and I have found no way to create a field that allows the admin to upload a pdf specific to the product and then display this download link on the product page.
This HAS to be possible. The other carts I normally use can do this so I know AC can as well since other carts aren't doing anything special that AC can't do.
-
- Lieutenant Commander (LCDR)
- Posts: 87
- Joined: Fri Nov 20, 2009 8:46 am
Re: Attach pdf
It's pretty easy to display the PDF as a download in the product page. Take a look in the description for this product page:
http://www.nationaltoolwarehouse.com/Bo ... C1071.aspx
The field is a product template field but the concept works the same for the custom product fields - just change the code to reference the product custom fields. This code assumes the field contains the full URL for the PDF. We are looking for multiple fields to display, so this code is a little overkill for just one custom field. Here's the code from our control that displays the URL and the code that file the control from the database.
custom\productcustomfieldsdialog.ascx code:
custom\productcustomfieldsdialog.ascx.cs code
http://www.nationaltoolwarehouse.com/Bo ... C1071.aspx
The field is a product template field but the concept works the same for the custom product fields - just change the code to reference the product custom fields. This code assumes the field contains the full URL for the PDF. We are looking for multiple fields to display, so this code is a little overkill for just one custom field. Here's the code from our control that displays the URL and the code that file the control from the database.
custom\productcustomfieldsdialog.ascx code:
Code: Select all
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ProductCustomFieldsDialog.ascx.cs" Inherits="ConLib_ProductCustomFieldsDialog" EnableViewState="false" %>
<asp:PlaceHolder ID="phCustomFields" runat="server"></asp:PlaceHolder>
Code: Select all
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using CommerceBuilder.Products;
using CommerceBuilder.Utility;
public partial class ConLib_ProductCustomFieldsDialog : System.Web.UI.UserControl
{
protected void Page_PreRender(object sender, EventArgs e)
{
if (this.Visible)
{
List<string> keys = new List<string>();
List<string> values = new List<string>();
StringBuilder sbMSDS = new StringBuilder();
int _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
Product _Product = ProductDataSource.Load(_ProductId);
if (_Product != null)
{
foreach (ProductTemplateField tf in _Product.TemplateFields)
{
if (!string.IsNullOrEmpty(tf.InputValue) && tf.InputField.IsMerchantField)
{
keys.Add(tf.InputField.Name);
values.Add(tf.InputValue);
}
}
foreach (ProductCustomField cf in _Product.CustomFields)
{
if (!string.IsNullOrEmpty(cf.FieldValue))
{
keys.Add(cf.FieldName);
values.Add(cf.FieldValue);
}
}
}
//DO NOT DISPLAY THIS CONTROL IF NO CUSTOM FIELDS AVAILABLE
if (keys.Count > 0)
{
for (int i = 0; i < keys.Count; i++)
{
string key = keys[i];
string value = values[i];
switch (key)
{
case "MSDS Sheet":
sbMSDS.AppendFormat("<div><span class=\"customLink\"><a href=\"{0}\" alt=\"{1}\" target=\"_new\"><img src=\"/App_Themes/NTW/images/msds-icon.png\" border=\"0\"/><span class=\"MSDS_Link\">Click to View MSDS</span></a></span></div>", value, key);
break;
}
}
phCustomFields.Controls.Add(new LiteralControl(sbMSDS.ToString()));
}
if (sbMSDS.Length == 0)
{
this.Controls.Clear();
}
}
}
}
David Johnson
Re: Attach pdf
Yeah the MSDS you have there is exactly what I'm going to have to attach to every product.
Re: Attach pdf
I think I could do with a product template field instead of a custom field. I will check out the product template field creation and try out your code. Thanks for helping.
Re: Attach pdf
Based on your previous posts, I would suggest you just use the custom fields. I think you said that any product could have one of these fields. You would just need to switch the product template look to code like this for the custom fields:
Code: Select all
ProductCustomFieldCollection customFields = ProductCustomFieldDataSource.LoadForProduct(_ProductId);
string customValues = string.Empty;
foreach (ProductCustomField pcf in customFields)
{
if (pcf.FieldName == "FAQ")
customValues += string.Format("Freq. Asked Questions = {0}<br />", pcf.FieldValue);
}
FAQ.Text = customValues.ToString();