Knowledgebase (2311)
Children categories
How to Mannually Add Spire.PDF as Dependency in a .NET Standard Library Project
2019-10-30 03:43:03 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 Standarad from the "netstandard2.0" folder. 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 five packages in your project via the NuGet Package Manager. They are SkiaSharp, System.Buffers, System.Memory, System.Text.Encoding.CodePages and System.Runtime.CompilerServices.Unsafe.
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 PDF documents.
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;
namespace SpirePdfStandard
{
public class Class1
{
public void CreatePdf()
{
//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");
}
}
}
This article demonstrates how to rotate shapes on a Word document using Spire.Doc for Java.
import com.spire.doc.Document;
import com.spire.doc.DocumentObject;
import com.spire.doc.FileFormat;
import com.spire.doc.Section;
import com.spire.doc.documents.*;
import com.spire.doc.fields.ShapeObject;
public class RotateShape {
public static void main(String[] args) throws Exception {
//Load the Sample Word document.
Document doc = new Document();
doc.loadFromFile("InsertShapes.docx");
//Get the first section
Section sec = doc.getSections().get(0);
//Traverse every paragraphs to get the shapes and rotate them
for ( Paragraph para: (Iterable<Paragraph>) sec.getParagraphs()) {
for (DocumentObject obj : (Iterable<DocumentObject>) para.getChildObjects()) {
if (obj instanceof ShapeObject) {
((ShapeObject) obj).setRotation(20);
}
}
}
//Save to file
doc.saveToFile("output/RotateShape.docx", FileFormat.Docx);
}
}
Effective screenshot after rotating the shapes on word:

Spire.Presentation supports setting alignment for table in a PowerPoint document. This article demonstrates how to align a table to the bottom of a PowerPoint slide using Spire.Presentation.
Below screenshot shows the original table before setting alignment:

using Spire.Presentation;
namespace AlignTable
{
class Program
{
static void Main(string[] args)
{
//Load PowerPoint document
Presentation ppt = new Presentation();
ppt.LoadFromFile("Table.pptx");
ITable table = null;
//Loop through the shapes in the first slide
foreach (IShape shape in ppt.Slides[0].Shapes)
{
//Find the table and align it to the bottom of the slide
if (shape is ITable)
{
table = (ITable)shape;
table.SetShapeAlignment(Spire.Presentation.ShapeAlignment.AlignBottom);
}
}
//Save the resultant document
ppt.SaveToFile("Result.pptx", FileFormat.Pptx2013);
}
}
}
Output:
