Knowledgebase (2328)
Children categories
How to Mannually Add Spire.Doc as Dependency in a .NET Standard Library Project
2019-10-22 09:02:07 Written by KoohjiAs System.Drawing only supported on Windows in NET6.0, you need to use SkiaSharp instead under NET5.0 or NET6.0 in Linux, or inside docker container. Please follow the next steps to use the NetStandard dlls to get SkiaSharp to your project manually. We will use Spire.Doc as example.
Step 1: Download the latest version of Spire.Doc Pack from this link, unzip it, and you'll get the DLL files for .NET Standarad from the "netstandard2.0" folder or install via NuGet.
PM> Install-Package Spire.Officefor.NETStandard
If you already have this folder in your disk, go straight to step two.

Step 2: Create a .NET Standard library project in your Visual Studio.

Step 3: Add all DLL files under the "netstandard2.0" folder as dependencies in your project.
Right-click "Dependencies" – select "Add Reference" – click "Browse" – selcet all DLLs under "netstandard2.0" folder – click "Add".

Step 4: Install the other three packages in your project via the NuGet Package Manager. They are SkiaSharp, System.Text.Encoding.CodePages and System.Security.Cryptography.Xml.
Right-click "Dependencies" – select "Manage NuGet Packages" – click "Browse" – type the package name – select the package from the search results – click "Install".

Step 5: Now that you've added all the dependences successfully, you can start to write your own .NET Standard library that is capable of creating and processing Word documents.
using Spire.Doc;
using Spire.Doc.Documents;
namespace SpireDocStandard
{
public class Class1
{
public void CreateWord()
{
//Create a document object
Document doc = new Document();
//Add a section
Section section = doc.AddSection();
//Add a paragrah
Paragraph paragraph = section.AddParagraph();
//Append text to the paragraph
paragraph.AppendText("Hello World");
//Save to file
doc.SaveToFile("Output.docx", FileFormat.Docx2013);
}
}
}
This article demonstrates how to add data labels to a chart and set the appearance (border style and fill style) for the data labels in PowerPoint using Spire.Presentation for Java. Note some chart types like Surface3D, Surface3DNoColor, Contour and ContourNoColor do not support data labels.
Below screenshot shows the original chart before adding data labels:

import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;
import com.spire.presentation.charts.IChart;
import com.spire.presentation.charts.entity.ChartDataLabel;
import com.spire.presentation.charts.entity.ChartSeriesDataFormat;
import com.spire.presentation.drawing.FillFormatType;
import java.awt.*;
public class AddDataLabelsToChart {
public static void main(String[] args) throws Exception {
//Load the PowerPoint document
Presentation ppt = new Presentation();
ppt.loadFromFile("Chart.pptx");
//Get the first slide
ISlide slide = ppt.getSlides().get(0);
//Get the chart in the slide
IChart chart = (IChart)slide.getShapes().get(0);
//Loop through the series in the chart
for (ChartSeriesDataFormat series:(Iterable<ChartSeriesDataFormat>)chart.getSeries()) {
) {
//Add data labels for the data points in each series
for(int i = 0; i < 4; i++){
ChartDataLabel dataLabel = series.getDataLabels().add();
//Show label value
dataLabel.setLabelValueVisible(true);
//Show series name
dataLabel.setSeriesNameVisible(true);
//Set border line style
dataLabel.getLine().setFillType(FillFormatType.SOLID);
dataLabel.getLine().getSolidFillColor().setColor(Color.RED);
//Set fill style
dataLabel.getFill().setFillType(FillFormatType.SOLID);
dataLabel.getFill().getSolidColor().setColor(Color.YELLOW);
}
}
//Save the resultant document
ppt.saveToFile("DataLabels.pptx", FileFormat.PPTX_2013);
}
}
Output:

How to Mannually Add Spire.PDF as Dependency in a .NET Core Application
2019-10-17 07:44:00 Written by KoohjiStep 1: Download the latest version of Spire.PDF Pack from the link below, unzip it, and you'll get the DLL files for .NET Core in the "netcoreapp2.0" folder. If you already have this folder in your disk, go straight to step two.

Step 2: Create a .NET Core application in your Visual Studio.

Step 3: Add all DLL files under the "netcoreapp2.0" folder as dependencies in your project.
Right-click "Dependencies" – select "Add Reference" – click "Browse" – selcet all DLLs under "netcoreapp2.0" folder – click "Add".

Step 4: Install the other two packages in your project via the NuGet Package Manager. They are System.Drawing.Common and System.Text.Encoding.CodePages.
Right-click "Dependencies" – select "Manage NuGet Packages" – click "Browse" –type the package name – select the package from the search results – click "Install".

Step 5: Now that you’ve added all the dependences successfully, you can start to code. The following code snippet gives you an exmaple of how to create a simple PDF document using Spire.PDF.
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace SpirePdfCore
{
class Program
{
static void Main(string[] args)
{
//Create a PdfDocument object
PdfDocument doc = new PdfDocument();
//Add a page
PdfPageBase page = doc.Pages.Add();
//Draw text on the page at the specified position
page.Canvas.DrawString("Hello World",
new PdfFont(PdfFontFamily.Helvetica, 13f),
new PdfSolidBrush(Color.Black),
new PointF(50, 50));
//Save the document
doc.SaveToFile("Output.pdf");
}
}
}