Knowledgebase (2300)
This article demonstrates how to print different pages of a PDF document to different printer trays using Spire.PDF and c#.
Code snippets:
Step 1: Initialize an object of PdfDocument class and Load the PDF document.
PdfDocument doc = new PdfDocument(); doc.LoadFromFile(@"F:\sample.pdf");
Step 2: Set different printer trays for different pages of the document.
doc.PrintSettings.PaperSettings += delegate(object sender, PdfPaperSettingsEventArgs e)
{
//Set the paper source of page 1-50 as tray 1
if (1 <= e.CurrentPaper && e.CurrentPaper <= 50)
{
e.CurrentPaperSource = e.PaperSources[0];
}
//Set the paper source of the rest of pages as tray 2
else
{
e.CurrentPaperSource = e.PaperSources[1];
}
};
Step 3: Print the document.
doc.Print();
Full code:
using Spire.Pdf;
using Spire.Pdf.Print;
namespace Print_pages_to_different_printer_trays
{
class Program
{
static void Main(string[] args)
{
//Initialize an object of PdfDocument class
PdfDocument doc = new PdfDocument();
//Load the PDF document
doc.LoadFromFile(@"F:\sample.pdf");
//Set Paper source
doc.PrintSettings.PaperSettings += delegate(object sender, PdfPaperSettingsEventArgs e)
{
//Set the paper source of page 1-50 as tray 1
if (1 <= e.CurrentPaper && e.CurrentPaper <= 50)
{
e.CurrentPaperSource = e.PaperSources[0];
}
//Set the paper source of the rest of pages as tray 2
else
{
e.CurrentPaperSource = e.PaperSources[1];
}
};
//Print the document
doc.Print();
}
}
}
Preserve Theme When Copying Sections from One Word Document to Another in C#
2018-01-19 08:04:49 Written by KoohjiA theme is a set of colors, fonts, and effects that determines the overall look of your Word document. Suppose you have a document which is neat and stylish, you’d like to copy contents of a section to another document without losing the theme and style. You can clone the theme to destination file using CloneThemeTo method.
Step 1: Create a Document object and load a sample Word file.
Document doc = new Document();
doc.LoadFromFile("theme.docx");
Step 2: Create a new Word document.
Document newWord = new Document();
Step 3: Clone default style, theme, compatibility from the source file to destination document.
doc.CloneDefaultStyleTo(newWord); doc.CloneThemesTo(newWord); doc.CloneCompatibilityTo(newWord);
Step 4: Add the cloned section to destination document.
newWord.Sections.Add(doc.Sections[0].Clone());
Step 5: Save the file.
newWord.SaveToFile("result.docx", FileFormat.Docx);
Output:

Full Code:
using Spire.Doc;
namespace PreserveTheme
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document();
doc.LoadFromFile("theme.docx");
Document newWord = new Document();
doc.CloneDefaultStyleTo(newWord);
doc.CloneThemesTo(newWord);
doc.CloneCompatibilityTo(newWord);
newWord.Sections.Add(doc.Sections[0].Clone());
newWord.SaveToFile("result.docx", FileFormat.Docx);
}
}
}
We have already shown how to use Spire.Presentation to create the bubble chart in C# on the PowerPoint document. This article will demonstrate how to scale the size of bubble chart on the presentation slides in C#. We will use a 3-D bubble chart for example.
Step 1: Create a Presentation instance and load a sample document from the file.
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);
Step 2: Get the chart from the first presentation slide.
IChart chart = ppt.Slides[0].Shapes[0] as IChart;
Step 3: Scale the bubble size, the range value is from 0 to 300.
chart.BubbleScale = 50;
Step 4: Save the document to file.
ppt.SaveToFile("Scalesize.pptx", FileFormat.Pptx2010);
Effective screenshot of scale the bubble size:

Full codes:
using Spire.Presentation;
using Spire.Presentation.Charts;
namespace ScaleSize
{
class Program
{
static void Main(string[] args)
{
Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx", FileFormat.Pptx2010);
IChart chart = ppt.Slides[0].Shapes[0] as IChart;
chart.BubbleScale = 50;
ppt.SaveToFile("Scalesize.pptx", FileFormat.Pptx2010);
}
}
}