| PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
| Process.start() Issue in c# https://forum.pdfsharp.net/viewtopic.php?f=2&t=2560 |
Page 1 of 1 |
| Author: | BextecUK [ Tue Aug 27, 2013 1:43 pm ] |
| Post subject: | Process.start() Issue in c# |
Code: using System; using System.Collections; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using MigraDoc.DocumentObjectModel; using MigraDoc.Rendering; using MigraDoc.Rendering.Printing; using System.Diagnostics; using WindowsFormsApplication1; public partial class ProductDetails : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { PopulateControls(); string currentPageFileName = new FileInfo(this.Request.Url.LocalPath).Name; HyperLink hylnk = (HyperLink)this.Master.FindControl("HyperLink1"); hylnk.NavigateUrl = (currentPageFileName + "?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Request.QueryString["CategoryID"] + "&ProductID=" + Request.QueryString["ProductID"]); HyperLink hylnk2 = (HyperLink)this.Master.FindControl("HyperLink2"); hylnk2.NavigateUrl = (currentPageFileName + "?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Request.QueryString["CategoryID"] + "&ProductID=" + Request.QueryString["ProductID"] + "&Lang=GER"); HyperLink hylnk3 = (HyperLink)this.Master.FindControl("HyperLink3"); hylnk3.NavigateUrl = (currentPageFileName + "?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Request.QueryString["CategoryID"] + "&ProductID=" + Request.QueryString["ProductID"] + "&Lang=ESP"); HyperLink hylnk4 = (HyperLink)this.Master.FindControl("HyperLink4"); hylnk4.NavigateUrl = (currentPageFileName + "?DepartmentID=" + Request.QueryString["DepartmentID"] + "&CategoryID=" + Request.QueryString["CategoryID"] + "&ProductID=" + Request.QueryString["ProductID"] + "&Lang=FR"); } private void PopulateControls() { // Retrieve DepartmentID from the query string string departmentId = Request.QueryString["DepartmentID"]; // Retrieve CategoryID from the query string string categoryId = Request.QueryString["CategoryID"]; // Retrieve Page from the query string string page = Request.QueryString["Page"]; if (page == null) page = "1"; // Retrieve Search string from query string string searchString = Request.QueryString["Search"]; // How many pages of products? int howManyPages = 1; // pager links format string firstPageUrl = ""; string pagerFormat = ""; // If performing a product search if (searchString != null) { // Retrieve AllWords from query string string allWords = Request.QueryString["AllWords"]; // Perform search list.DataSource = CatalogAccess.Search(searchString, allWords, page, out howManyPages); list.DataBind(); // Display pager firstPageUrl = Link.ToSearch(searchString, allWords.ToUpper() == "TRUE", "1"); pagerFormat = Link.ToSearch(searchString, allWords.ToUpper() == "TRUE", "{0}"); } // If browsing a category... else if (categoryId != null) { // Retrieve list of products in a category list.DataSource = CatalogAccess.GetProductsInCategory(categoryId, page, out howManyPages); list.DataBind(); // get first page url and pager format firstPageUrl = Link.ToCategory(departmentId, categoryId, "1"); pagerFormat = Link.ToCategory(departmentId, categoryId, "{0}"); } else if (departmentId != null) { // Retrieve list of products on department promotion list.DataSource = CatalogAccess.GetProductsOnDeptPromo (departmentId, page, out howManyPages); list.DataBind(); // get first page url and pager format firstPageUrl = Link.ToDepartment(departmentId, "1"); pagerFormat = Link.ToDepartment(departmentId, "{0}"); } else { // Retrieve list of products on catalog promotion list.DataSource = CatalogAccess.GetProductsOnFrontPromo(page, out howManyPages); list.DataBind(); // have the current page as integer int currentPage = Int32.Parse(page); } // Display pager controls // topPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, false); // bottomPager.Show(int.Parse(page), howManyPages, firstPageUrl, pagerFormat, true); } // Executed when each item of the list is bound to the data source protected void list_ItemDataBound(object sender, DataListItemEventArgs e) { // obtain the attributes of the product DataRowView dataRow = (DataRowView)e.Item.DataItem; string productId = dataRow["ProductID"].ToString(); DataTable attrTable = CatalogAccess.GetProductAttributes(productId); // get the attribute placeholder PlaceHolder attrPlaceHolder = (PlaceHolder)e.Item.FindControl("attrPlaceHolder"); // temp variables string prevAttributeName = ""; string attributeName, attributeValue, attributeValueId; // current DropDown for attribute values Label attributeNameLabel; DropDownList attributeValuesDropDown = new DropDownList(); // read the list of attributes foreach (DataRow r in attrTable.Rows) { // get attribute data attributeName = r["AttributeName"].ToString(); attributeValue = r["AttributeValue"].ToString(); attributeValueId = r["AttributeValueID"].ToString(); // if starting a new attribute (e.g. Color, Size) if (attributeName != prevAttributeName) { prevAttributeName = attributeName; attributeNameLabel = new Label(); attributeNameLabel.Text = attributeName + ": "; attributeValuesDropDown = new DropDownList(); attrPlaceHolder.Controls.Add(attributeNameLabel); attrPlaceHolder.Controls.Add(attributeValuesDropDown); } // add a new attribute value to the DropDownList attributeValuesDropDown.Items.Add(new ListItem(attributeValue, attributeValueId)); } } public void LinkButton1_Click(object sender, EventArgs e) { CataloguePageGenerator generator = new CataloguePageGenerator(); try { string productId = Request.QueryString["ProductID"].ToString(); string categoryId = Request.QueryString["CategoryID"].ToString(); DataTable dtPSDDetails = new DataTable(); dtPSDDetails = GetGeneric.GetInstance<PDFHelper>().GetALLPDFDetails(productId, categoryId); if (dtPSDDetails != null && dtPSDDetails.Rows.Count > 0) { //generator.Author = dtPSDDetails.Rows[0]["????"].ToString(); <-- get the name of the row returned by the stored procedure generator.Author = "BBP Plastics"; generator.Image = @".\ProductImages\" + dtPSDDetails.Rows[0]["Image"].ToString(); generator.Subject = "BBP Plastics Product data"; generator.Title = dtPSDDetails.Rows[0]["FPN"].ToString(); generator.CartonDimensions = "L: " + dtPSDDetails.Rows[0]["CartonLengthmm"].ToString() + " W: " + dtPSDDetails.Rows[0]["CartonWidthmm"].ToString() + " H: " + dtPSDDetails.Rows[0]["CartonHeightmm"].ToString(); generator.FooterImg = @".\..\footer.png"; generator.PackagingSpec = "Weight of products: " + dtPSDDetails.Rows[0]["WeightOfProductsKilos"].ToString() + "\n\r" + "Weight of bags: " + dtPSDDetails.Rows[0]["WeightOfBagsKilos"].ToString() + "\n\r" + "Weight of cardboard: " + dtPSDDetails.Rows[0]["WeightOfCardboardKilos"].ToString() + "\n\r" + "Total weight of 1 box: " + dtPSDDetails.Rows[0]["Total_WeightKilos"].ToString(); generator.PalletQuantityAndDimensions = "Cartons per pallet:" + dtPSDDetails.Rows[0]["CartonQuantity"].ToString() + "\n\r" + "L: " + dtPSDDetails.Rows[0]["FullPalletLengthmm"].ToString() + " W: " + dtPSDDetails.Rows[0]["FullPalletWidthmm"].ToString() + " H: " + dtPSDDetails.Rows[0]["FullPalletHeightmm"].ToString(); generator.ProductDetails = "Code: " + dtPSDDetails.Rows[0]["ProductCode"].ToString() + "\n\r" + "Carton quantity: " + dtPSDDetails.Rows[0]["CartonQuantity"].ToString() + "\n\r" + "Manufactured in: " + dtPSDDetails.Rows[0]["ManufacturedIn"].ToString() + "\n\r" + "Material: " + dtPSDDetails.Rows[0]["Material"].ToString() + "\n\r" + "Strength: " + dtPSDDetails.Rows[0]["Strength"].ToString() + "\n\r" + "Glass washer safe: " + dtPSDDetails.Rows[0]["GlassWasherSafe"].ToString() + "\n\r" + "Life span: " + dtPSDDetails.Rows[0]["LifeSpan"].ToString() + "\n\r" + "Top width: " + dtPSDDetails.Rows[0]["TopWidth"].ToString() + "\n\r" + "Bottom width: " + dtPSDDetails.Rows[0]["BottomWidth"].ToString() + "\n\r" + "Overall height: " + dtPSDDetails.Rows[0]["OverallHeight"].ToString() + "\n\r" + "Weight: " + dtPSDDetails.Rows[0]["WeightOfComponentsGrams"].ToString() + "\n\r" + "Capacity: " + dtPSDDetails.Rows[0]["Capacity"].ToString() + "\n\r" + "CE Marked: " + dtPSDDetails.Rows[0]["CEMarked"].ToString() + "\n\r" + "Colour: " + dtPSDDetails.Rows[0]["Colour"].ToString() + "\n\r" + "Colour Options: " + "\n\r" + "" + dtPSDDetails.Rows[0]["OtherColoursAvailable"].ToString() + "\n\r" + "Printable: " + dtPSDDetails.Rows[0]["Printable"].ToString() + "\n\r" + "Reusable: " + dtPSDDetails.Rows[0]["Reusable"].ToString() + "\n\r" + "Recyclable: " + dtPSDDetails.Rows[0]["Recyclable"].ToString() + "\n\r" + "Size Options:" + "\n\r" + "" + dtPSDDetails.Rows[0]["OtherSizesAvailable"].ToString(); } } catch { } try { Document document = generator.CreateDocument(); document.UseCmykColor = true; // Create a renderer for PDF that uses Unicode font encoding PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true); // Set the MigraDoc document pdfRenderer.Document = document; // Create the PDF document pdfRenderer.RenderDocument(); // Save the PDF document... //Get the root of the site String rootPath = Server.MapPath("~"); // build the temp folder and file name (folder temppdfs must exist at root) rootPath = rootPath + "\\temppdfs\\"; string filename = rootPath + "test" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf"; pdfRenderer.Save(filename); // ...and start a viewer. Process.Start(filename); // Send PDF to browser MemoryStream stream = new MemoryStream(); document.Save(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", stream.Length.ToString()); Response.BinaryWrite(stream.ToArray()); Response.Flush(); stream.Close(); Response.End(); } catch (Exception ex) { throw ex; } } } In this section I get my errors pdfRenderer.Save(filename); // ...and start a viewer. Process.Start(filename); IT works in visusal studio but not on the website server. I understand that it has access when running locally how can I make it work on the server? I have tried this section // Send PDF to browser MemoryStream stream = new MemoryStream(); //document.Save(); Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", stream.Length.ToString()); Response.BinaryWrite(stream.ToArray()); Response.Flush(); stream.Close(); Response.End(); I have tried this and when I click the button I get a pdf viewer, but not the PDF I have saved I desparately neeed this to work, I am not worried if it does not save the PDF, I just want it to come up on screen so it creates it on the fly HELP |
|
| Author: | Thomas Hoevel [ Tue Aug 27, 2013 1:48 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
Hi! You don't need a filename. And delete "Process.Start", it won't work on the server. Just move "pdfRenderer.Save" down a bit and pass a stream, not a filename: Code: // Send PDF to browser (code snippet with the important change)MemoryStream stream = new MemoryStream(); pdfRenderer.Save(stream, false); // <= moved here from above. Response.Clear(); HTH |
|
| Author: | BextecUK [ Tue Aug 27, 2013 1:54 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
that doesnt work either, I can see the browser try soemthing, but it does not show me a PDF Code: // build the temp folder and file name (folder temppdfs must exist at root)
rootPath = rootPath + "\\temppdfs\\"; string filename = rootPath + "test" + Guid.NewGuid().ToString("N").ToUpper() + ".pdf"; //pdfRenderer.Save(filename); // ...and start a viewer. //Process.Start(filename); // Send PDF to browser MemoryStream stream = new MemoryStream(); pdfRenderer.Save(stream, false); // <= moved here from above. Response.Clear(); |
|
| Author: | BextecUK [ Tue Aug 27, 2013 2:22 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
I have tried running this directly on the server and it does the same, no PDF comes up and the server does have Acrobat installed |
|
| Author: | BextecUK [ Tue Aug 27, 2013 2:39 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
also tested this on the Vis Studio and it did not work Please help |
|
| Author: | Thomas Hoevel [ Tue Aug 27, 2013 3:38 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
You still need the rest of the code (just in case you omitted that): Code: Response.ContentType = "application/pdf"; Response.AddHeader("content-length", stream.Length.ToString()); Response.BinaryWrite(stream.ToArray()); Response.Flush(); stream.Close(); Response.End(); When you step through the code in Visual Studio, you should see that the MemoryStream contains data (stream.Length > 0). |
|
| Author: | BextecUK [ Tue Aug 27, 2013 8:25 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
Thank You Thomas its now working!!! two last questions, 1 how might i get the PDF to have a Border around the page? 2 how doI get the path to the image in a folder that runs from the root off the site such as the images folder? |
|
| Author: | () => true [ Thu Aug 29, 2013 7:42 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
Hi! BextecUK wrote: 1 how might i get the PDF to have a Border around the page? For a single page or for every page?I think a Textframe with a border can be used. To have the border on every page, add the Textframe to the page header. BextecUK wrote: 2 how doI get the path to the image in a folder that runs from the root off the site such as the images folder? ASP.NET is not my area of expertise, but there are functions that convert a site path to an absolute file system path.
|
|
| Author: | BextecUK [ Mon Sep 02, 2013 9:38 am ] |
| Post subject: | Re: Process.start() Issue in c# |
I have sussed the image issue. I just need to add the border. Whats the code for the textFrame? |
|
| Author: | Thomas Hoevel [ Mon Sep 02, 2013 5:10 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
Here is code that draws a red border 2 cm from the edge of the page (assuming DIN A4 format): Code: var tf = section.AddTextFrame(); Adjust DistanceLeft, Top, Width, Height, Color and width of the border line as needed.
tf.RelativeHorizontal = RelativeHorizontal.Page; tf.RelativeVertical = RelativeVertical.Page; tf.WrapFormat.Style = WrapStyle.Through; tf.WrapFormat.DistanceLeft = "2cm"; tf.Top = "2cm"; tf.Width = "17cm"; tf.Height = "257mm"; tf.LineFormat.Color = Colors.Red; tf.LineFormat.Width = 2; |
|
| Author: | BextecUK [ Tue Sep 10, 2013 8:01 am ] |
| Post subject: | Re: Process.start() Issue in c# |
where does this code go? Scrap this message, I have found it |
|
| Author: | BextecUK [ Tue Sep 10, 2013 9:25 am ] |
| Post subject: | Re: Process.start() Issue in c# |
generator.PackagingSpec = "Weight of products: " + dtPSDDetails.Rows[0]["WeightOfProductsKilos"].ToString() + "\n\r" + how can I make the "Weight of products: " bold and the rest standard? |
|
| Author: | Thomas Hoevel [ Tue Sep 10, 2013 9:42 am ] |
| Post subject: | Re: Process.start() Issue in c# |
Use paragraph.AddFormattedText() for each part that requires individual formatting. |
|
| Author: | BextecUK [ Tue Sep 10, 2013 9:51 am ] |
| Post subject: | Re: Process.start() Issue in c# |
on which section? the class or the page that generates it? |
|
| Author: | BextecUK [ Tue Sep 10, 2013 10:02 am ] |
| Post subject: | Re: Process.start() Issue in c# |
I added that into the class and now I have it twice. help |
|
| Author: | BextecUK [ Tue Sep 10, 2013 10:04 am ] |
| Post subject: | Re: Process.start() Issue in c# |
here are my class and generatoe codes cs page Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using MigraDoc.DocumentObjectModel; using MigraDoc.DocumentObjectModel.Tables; using MigraDoc.DocumentObjectModel.Shapes; using System.Configuration; using System.Data; using System.Data.SqlClient; namespace WindowsFormsApplication1 { public class CataloguePageGenerator { private String image = ""; private String title = ""; private String footerImg = ""; private String productDetails = ""; private String packagingSpec = ""; private String cartonDimensions = ""; private String palletQuantityAndDimensions = ""; private String author = ""; private String subject = ""; Document document; TextFrame productDetailsFrame; TextFrame secondFrame; private const String TOP_OF_PAGE = "3cm"; private const String LEFT_MARGIN = "2cm"; private const String SECOND_COLUMN = "11cm"; private const String PARAGRAPH_WIDTH = "6cm"; private const String JUST_BELOW_IMAGE = "9cm"; //"12.5cm"; public String Title { get { return title; } set { title = value; } } public String FooterImg { get { return footerImg; } set { footerImg = value; } } public String ProductDetails { get { return productDetails; } set { productDetails = value; } } public String PackagingSpec { get { return packagingSpec; } set { packagingSpec = value; } } public String CartonDimensions { get { return cartonDimensions; } set { cartonDimensions = value; } } public String PalletQuantityAndDimensions { get { return palletQuantityAndDimensions; } set { palletQuantityAndDimensions = value; } } public String Author { get { return author; } set { author = value; } } public String Subject { get { return subject; } set { subject = value; } } public String Image { get { return image; } set { image = value; } } public Document CreateDocument() { // Create a new MigraDoc document this.document = new Document(); this.document.Info.Title = title; this.document.Info.Subject = subject; this.document.Info.Author = author; CreatePage(); return this.document; } /// <summary> /// Creates the static parts of the invoice. /// </summary> private void CreatePage() { // Each MigraDoc document needs at least one section. Section section = this.document.AddSection(); var tf = section.AddTextFrame(); tf.RelativeHorizontal = RelativeHorizontal.Page; tf.RelativeVertical = RelativeVertical.Page; tf.WrapFormat.Style = WrapStyle.Through; tf.WrapFormat.DistanceLeft = "1cm"; tf.Top = "1cm"; tf.Width = "19cm"; tf.Height = "275mm"; tf.LineFormat.Color = Colors.Black; tf.LineFormat.Width = 2; //#365D75 // title frame Paragraph paragraph = section.Headers.Primary.AddParagraph(); paragraph.AddText(title); paragraph.Format.Font.Size = 20; paragraph.Format.Alignment = ParagraphAlignment.Center; // Place The main image in Image image = section.AddImage(this.image); image.Width = "5.5cm"; image.LockAspectRatio = true; image.RelativeVertical = RelativeVertical.Line; image.RelativeHorizontal = RelativeHorizontal.Margin; image.Top = "10cm"; image.Left = SECOND_COLUMN; image.LineFormat.Style = LineStyle.Single; image.LineFormat.Color = Colors.Black; image.WrapFormat.Style = WrapStyle.Through; // Create footer Image footerimage = section.Footers.Primary.AddImage(this.footerImg); footerimage.Height = "2cm"; footerimage.Width = "17.8cm"; footerimage.Left = "-1cm"; //footerimage.LockAspectRatio = true; footerimage.RelativeVertical = RelativeVertical.Line; footerimage.RelativeHorizontal = RelativeHorizontal.Margin; // Create the text frame for the product this.productDetailsFrame = section.AddTextFrame(); this.productDetailsFrame.Height = "25cm"; this.productDetailsFrame.Width = PARAGRAPH_WIDTH; //this.productDetailsFrame.Left = ShapePosition.Left; this.productDetailsFrame.RelativeHorizontal = RelativeHorizontal.Margin; this.productDetailsFrame.Top = TOP_OF_PAGE; this.productDetailsFrame.Left = LEFT_MARGIN; this.productDetailsFrame.RelativeVertical = RelativeVertical.Page; this.productDetailsFrame.WrapFormat.Style = WrapStyle.TopBottom; // product frame paragraph = this.productDetailsFrame.AddParagraph("Product Details"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.Font.Underline = Underline.Single; paragraph.Format.Font.Bold = true; //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; paragraph = this.productDetailsFrame.AddParagraph("\n\r" + "\n\r" + productDetails); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; //paragraph.Format.Font.Bold = true; paragraph.Format.LineSpacing = 20; paragraph.Format.LineSpacingRule = LineSpacingRule.AtLeast; // Create the text frame for the second column this.secondFrame = section.AddTextFrame(); this.secondFrame.Height = "19.37cm"; this.secondFrame.Width = PARAGRAPH_WIDTH; //this.packagingSpecFrame.Left = ShapePosition.Right; //Left; this.secondFrame.RelativeHorizontal = RelativeHorizontal.Margin; this.secondFrame.Top = JUST_BELOW_IMAGE; this.secondFrame.Left = SECOND_COLUMN; this.secondFrame.RelativeVertical = RelativeVertical.Page; this.secondFrame.WrapFormat.Style = WrapStyle.TopBottom; // packaging paragraph = this.secondFrame.AddParagraph("Packaging Specifications"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.Font.Underline = Underline.Single; // paragraph.Format.Font.Bold = true; //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; paragraph = this.secondFrame.AddParagraph("\n\r" + "\n\r" + packagingSpec + "\n\r" + "\n\r"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.LineSpacing = 18; paragraph.Format.LineSpacingRule = LineSpacingRule.AtLeast; paragraph.AddFormattedText("Weight of products", TextFormat.Bold); //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; // carton paragraph = this.secondFrame.AddParagraph("Carton Dimensions"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.Font.Underline = Underline.Single; paragraph.Format.Font.Bold = true; // paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; paragraph = this.secondFrame.AddParagraph("\n\r" + "\n\r" + cartonDimensions + "\n\r" + "\n\r"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.LineSpacing = 18; paragraph.Format.LineSpacingRule = LineSpacingRule.AtLeast; //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; // pallet paragraph = this.secondFrame.AddParagraph("Pallet Quantity and Dimensions"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.Font.Underline = Underline.Single; paragraph.Format.Font.Bold = true; // paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; paragraph = this.secondFrame.AddParagraph("\n\r" + "\n\r" + palletQuantityAndDimensions + "\n\r"); paragraph.Format.Font.Name = "Arial"; paragraph.Format.Font.Size = 11; paragraph.Format.LineSpacing = 18; paragraph.Format.LineSpacingRule = LineSpacingRule.AtLeast; //paragraph.Format.SpaceAfter = 8; //paragraph.Format.SpaceBefore = 8; } } } generator page Code: CataloguePageGenerator generator = new CataloguePageGenerator(); try { string productId = Request.QueryString["ProductID"].ToString(); string categoryId = Request.QueryString["CategoryID"].ToString(); DataTable dtPSDDetails = new DataTable(); dtPSDDetails = GetGeneric.GetInstance<PDFHelper>().GetALLPDFDetails(productId, categoryId); if (dtPSDDetails != null && dtPSDDetails.Rows.Count > 0) { //generator.Author = dtPSDDetails.Rows[0]["????"].ToString(); <-- get the name of the row returned by the stored procedure generator.Author = "BBP Plastics"; generator.Image = (Server.MapPath("~/ProductImages/" + dtPSDDetails.Rows[0]["Image"].ToString())); generator.Subject = "BBP Plastics Product data"; generator.Title = dtPSDDetails.Rows[0]["FPN"].ToString(); generator.CartonDimensions = "L: " + dtPSDDetails.Rows[0]["CartonLengthmm"].ToString() + " W: " + dtPSDDetails.Rows[0]["CartonWidthmm"].ToString() + " H: " + dtPSDDetails.Rows[0]["CartonHeightmm"].ToString(); generator.FooterImg = (Server.MapPath("footer.png")); generator.PackagingSpec = "Weight of products: " + dtPSDDetails.Rows[0]["WeightOfProductsKilos"].ToString() + "\n\r" + "Weight of bags: " + dtPSDDetails.Rows[0]["WeightOfBagsKilos"].ToString() + "\n\r" + "Weight of cardboard: " + dtPSDDetails.Rows[0]["WeightOfCardboardKilos"].ToString() + "\n\r" + "Total weight of 1 box: " + dtPSDDetails.Rows[0]["Total_WeightKilos"].ToString(); generator.PalletQuantityAndDimensions = "Cartons per pallet:" + dtPSDDetails.Rows[0]["CartonsPerPallet"].ToString() + "\n\r" + "L: " + dtPSDDetails.Rows[0]["FullPalletLengthmm"].ToString() + " W: " + dtPSDDetails.Rows[0]["FullPalletWidthmm"].ToString() + " H: " + dtPSDDetails.Rows[0]["FullPalletHeightmm"].ToString(); generator.ProductDetails = "Product Code: " + dtPSDDetails.Rows[0]["ProductCode"].ToString() + "\n\r" + "Carton quantity: " + dtPSDDetails.Rows[0]["CartonQuantity"].ToString() + "\n\r" + "Manufactured in: " + dtPSDDetails.Rows[0]["ManufacturedIn"].ToString() + "\n\r" + "Material: " + dtPSDDetails.Rows[0]["Material"].ToString() + "\n\r" + "Strength: " + dtPSDDetails.Rows[0]["Strength"].ToString() + "\n\r" + "Glass washer safe: " + dtPSDDetails.Rows[0]["GlassWasherSafe"].ToString() + "\n\r" + "Life span: " + dtPSDDetails.Rows[0]["LifeSpan"].ToString() + "\n\r" + "Top width: " + dtPSDDetails.Rows[0]["TopWidth"].ToString() + "\n\r" + "Bottom width: " + dtPSDDetails.Rows[0]["BottomWidth"].ToString() + "\n\r" + "Overall height: " + dtPSDDetails.Rows[0]["OverallHeight"].ToString() + "\n\r" + "Weight: " + dtPSDDetails.Rows[0]["WeightOfComponentsGrams"].ToString() + "\n\r" + "Capacity: " + dtPSDDetails.Rows[0]["Capacity"].ToString() + "\n\r" + "CE Marked: " + dtPSDDetails.Rows[0]["CEMarked"].ToString() + "\n\r" + "Colour: " + dtPSDDetails.Rows[0]["Colour"].ToString() + "\n\r" + "Colour Options: " + "\n\r" + "" + dtPSDDetails.Rows[0]["OtherColoursAvailable"].ToString() + "\n\r" + "Printable: " + dtPSDDetails.Rows[0]["Printable"].ToString() + "\n\r" + "Reusable: " + dtPSDDetails.Rows[0]["Reusable"].ToString() + "\n\r" + "Recyclable: " + dtPSDDetails.Rows[0]["Recyclable"].ToString() + "\n\r" + "Size Options:" + "\n\r" + "" + dtPSDDetails.Rows[0]["OtherSizesAvailable"].ToString(); } } catch { } on this page I want the start of the lines in bold that are marked in "" quotes |
|
| Author: | Thomas Hoevel [ Tue Sep 10, 2013 3:37 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
The pattern is: Code: Paragraph para = section.AddParagraph(); para.AddFormattedText("Bold text", TextFormat.Bold); para.AddFormattedText(" and normal text"); See also: http://www.pdfsharp.net/wiki/MigraDocFirstSteps.ashx |
|
| Author: | BextecUK [ Tue Sep 10, 2013 7:06 pm ] |
| Post subject: | Re: Process.start() Issue in c# |
That wont work as its thie line generator.ProductDetails = "Product Code:" + dtPSDDetails.Rows[0]["ProductCode"].ToString() + "\n\r" + that I want to make the text Product Code Bold when it comes up on the PDF if I write it from behind as you suggest it fails |
|
| Author: | Thomas Hoevel [ Mon Sep 16, 2013 7:55 am ] |
| Post subject: | Re: Process.start() Issue in c# |
BextecUK wrote: if I write it from behind as you suggest it fails Probably a problem with how you call the MigraDoc functions. Difficult to tell without a code snippet.
|
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|