I cannot figure out how to label my objects in Aspose.PDF.Drawing.Graph.
In the old version I could add GraphNotes to a graph.
B.T.W. - I don’t know if I chose the correct product family, none of them make sense, especially the ones in chinese.
I cannot figure out how to label my objects in Aspose.PDF.Drawing.Graph.
In the old version I could add GraphNotes to a graph.
B.T.W. - I don’t know if I chose the correct product family, none of them make sense, especially the ones in chinese.
Could you please clarify what specific functionality you are looking for regarding labeling objects in Aspose.PDF.Drawing.Graph? Additionally, which version of Aspose.PDF are you currently using?
Aspose.Pdf version 22.1.0
I used to be able to produce this with Aspose.Pdf.Generator. See all the labels in the drawing.
image.png (8.8 KB)
Could you please share the sample code with us that you have been using with Aspose.Pdf.Generator API?
The code will not run without data connections. I will have to make something up to demonstrate.
Here is a quick demonstration of a graph with shapes and labels.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Aspose.Pdf.Generator;
namespace ControllersCoilCircuitDocument
{
public class CTestDrawingForAspose
{
public static Object LicenseLock = new Object();
//private byte[] CreateCircuitPrint()
public void CreateCircuitPrint()
{
#region page setup
Pdf pdf = new Pdf();
pdf.PageSetup.Margin.Left = 25;
pdf.PageSetup.Margin.Right = 25;
pdf.PageSetup.Margin.Top = 50;
pdf.PageSetup.Margin.Bottom = 25;
pdf.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
pdf.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;
try
{
lock(LicenseLock)
{
if(!IsPdfLicenseSet())
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
//license.SetLicense("ControllersCoilCircuitDocument.Aspose.Total.lic");
license.SetLicense("Aspose.Total.lic");
license.Embedded = true;
}
}
}
catch //(Exception err)
{
//throw (err);
}
Section section = pdf.Sections.Add();
section.PageInfo.Margin.Left = 25;
section.PageInfo.Margin.Right = 25;
section.PageInfo.Margin.Top = 50;
section.PageInfo.Margin.Bottom = 25;
section.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
section.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;
#endregion
Graph graph = new Graph(pdf.PageSetup.PageWidth - pdf.PageSetup.Margin.Left - pdf.PageSetup.Margin.Right,
pdf.PageSetup.PageHeight - pdf.PageSetup.Margin.Top - pdf.PageSetup.Margin.Bottom);
Rectangle rect = new Rectangle(0, 0, graph.GraphWidth, graph.GraphHeight);
graph.Shapes.Add(rect);
GraphNote note = new GraphNote();
note.Content = "I really need to be able to add shapes then anchor text to those shapes.";
note.PositionX = 0;
note.PositionY = graph.GraphHeight - 20;
graph.GraphNotes.Add(note);
rect = new Rectangle(72, 72, 72, 72);
graph.Shapes.Add(rect);
note = new GraphNote();
note.Content = "Square";
note.PositionX = rect.Left;
note.PositionY = rect.Bottom + rect.Height/2;
graph.GraphNotes.Add(note);
Circle circle = new Circle(graph.GraphWidth / 2, graph.GraphHeight / 2, 72);
graph.Shapes.Add(circle);
note = new GraphNote();
note.Content = "Circle";
note.PositionX = circle.PosX - 20;
note.PositionY = circle.PosY;
graph.GraphNotes.Add(note);
section.Paragraphs.Add(graph);
#region convert and return
System.IO.MemoryStream stream = new System.IO.MemoryStream();
pdf.Save(stream);
byte[] returnBytes = stream.ToArray();
stream.Close();
if(!System.IO.Directory.Exists("C:/test"))
{
System.IO.Directory.CreateDirectory("C:/test");
}
System.IO.File.WriteAllBytes("C:/test/graphNoteTest.pdf", returnBytes);
//return returnBytes;
#endregion
}
public bool IsPdfLicenseSet()
{
// B.T.W. - If you guys have a more efficient way of determining if the license has already been set, please share.
//We use this in WCF services and APIs. Setting the license over and over causes bad things to happen.
bool haveLicense = true;
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text("Test Text");
section.Paragraphs.Add(text);
System.IO.MemoryStream stream = new System.IO.MemoryStream();
pdf.Save(stream);
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document(stream);
Aspose.Pdf.Text.TextFragmentAbsorber absorber = new Aspose.Pdf.Text.TextFragmentAbsorber();
foreach(Aspose.Pdf.Page page in pdfDoc.Pages)
{
page.Accept(absorber);
Aspose.Pdf.Text.TextFragmentCollection textColl = absorber.TextFragments;
foreach(Aspose.Pdf.Text.TextFragment frag in textColl)
{
if(frag.Text != "Test Text")
{
haveLicense = false;
break;
}
}
}
stream.Close();
return haveLicense;
}
}
}
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58961
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.