.NET में लो-कोड प्रस्तुति संचालन
अवलोकन
The Aspose.Slides.LowCode namespace provides static helper classes for common presentation operations. These helpers wrap frequently used object-model workflows in focused methods, so you can convert or merge files, process presentation elements, collect shapes, and remove unused content with less code.
Low-code helpers are most useful when the operation applies to an entire file or presentation and the default workflow matches your requirements. Use the full Aspose.Slides object model when you need fine-grained control over individual slides, masters, layouts, shapes, export settings, or relationships between presentation elements.
The following table summarizes the available helpers:
| सहायक | उपयोग |
|---|---|
| Convert | सीधे फ़ाइल‑से‑फ़ाइल कॉल के साथ प्रस्तुति को एक अन्य प्रारूप में बदलना। |
| Merger | एक ही प्रारूप की संपूर्ण प्रस्तुति फ़ाइलों को संयोजित करना। |
| ForEach | प्रत्येक स्लाइड, शैप, पैराग्राफ या टेक्स्ट भाग के लिए कार्रवाई चलाना। |
| Collect | पुनरावर्ती प्रक्रिया या विश्लेषण के लिए संपूर्ण प्रस्तुति से शैप्स को प्राप्त करना। |
| Compress | अप्रयुक्त मास्टर/लेआउट को हटाना, एम्बेडेड फ़ॉन्ट डेटा को कम करना और चित्रों को संकुचित करना। |
Convert a Presentation
Use Convert.AutoByExtension when the output file extension is sufficient to select the export format. The method opens the source presentation, determines the required format from the output path, and writes the result.
using Aspose.Slides.LowCode;
Convert.AutoByExtension("input.pptx", "output.pdf");
The Convert class also provides dedicated methods for PDF, SVG, JPEG, PNG, and TIFF output. Use the full object model when you need to inspect or modify the presentation before export or configure an export option that is not exposed by the selected helper. See Convert Presentation for format-specific workflows and options.
Merge Presentations
Use Merger.Process to combine complete presentation files with one call. The input presentations must have the same file format.
using Aspose.Slides.LowCode;
var inputFiles = new[] { "part-1.pptx", "part-2.pptx" };
Merger.Process(inputFiles, "merged.pptx");
The helper is appropriate when all slides should be appended to one result without selecting or remapping them individually. Use the full object model when you need to merge selected slides, apply a destination master or layout, preserve sections explicitly, or reconcile different slide sizes. See Merge Presentations for those scenarios.
Iterate Through Presentation Elements
The ForEach class invokes a callback for each requested type of presentation element. It avoids nested collection loops and is convenient for presentation-wide inspection or formatting changes.
The following example uses ForEach.Slide, ForEach.Shape, ForEach.Paragraph, and ForEach.Portion to inspect the corresponding elements:
using System;
using Aspose.Slides;
using Aspose.Slides.LowCode;
using var presentation = new Presentation("input.pptx");
ForEach.Slide(presentation, (slide, index) =>
{
Console.WriteLine($"Slide {index}: {slide.Shapes.Count} shapes");
});
ForEach.Shape(presentation, (shape, slide, index) =>
{
Console.WriteLine($"Shape {index} on {slide.GetType().Name}: {shape.Name}");
});
ForEach.Paragraph(presentation, (paragraph, slide, index) =>
{
Console.WriteLine($"Paragraph {index} on {slide.GetType().Name}: {paragraph.Text}");
});
ForEach.Portion(presentation, (portion, paragraph, slide, index) =>
{
Console.WriteLine($"Portion {index} on {slide.GetType().Name}: {portion.Text}");
});
By default, presentation-wide shape and text traversal includes normal, master, and layout slides. Overloads with an includeNotes parameter can also process notes slides. Use direct collection loops when traversal order, early exit, filtering before callback invocation, or detailed parent-child control is important.
Collect Shapes
Use Collect.Shapes when you need a collection of all shapes in a presentation rather than a callback for each shape. This is useful when the same set will be filtered, counted, or processed more than once.
using System;
using Aspose.Slides;
using Aspose.Slides.LowCode;
using var presentation = new Presentation("input.pptx");
var shapes = Collect.Shapes(presentation);
foreach (var shape in shapes)
{
Console.WriteLine($"{shape.Name}: {shape.GetType().Name}");
}
Use ForEach.Shape instead when each shape can be handled immediately and you do not need to retain the collected result.
Compress Presentation Content
The Compress class can remove unused structural elements and reduce embedded font data:
- Compress.RemoveUnusedLayoutSlides removes layout slides that no normal slide references.
- Compress.RemoveUnusedMasterSlides removes master slides that are no longer used.
- Compress.CompressEmbeddedFonts removes unused characters from embedded fonts.
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.LowCode;
using var presentation = new Presentation("input.pptx");
Compress.RemoveUnusedLayoutSlides(presentation);
Compress.RemoveUnusedMasterSlides(presentation);
Compress.CompressEmbeddedFonts(presentation);
presentation.Save("compressed.pptx", SaveFormat.Pptx);
Remove unused layouts before unused masters so a master that becomes unreferenced after layout cleanup can also be removed. Save the optimized presentation to a new file if you may need the original masters, layouts, or complete embedded font data later. For more detail, see Slide Master and Embedded Font.
Compress the Whole Presentation
Aspose.Slides for .NET 26.11 adds Compress.CompressPresentation. It combines removal of unused layout/master slides, subsetting of embedded fonts to used characters, and picture compression at 150 DPI. Use the individual operations above when you need to control which changes are applied.
Install Aspose.Slides for .NET 26.11 or later and provide input.pptx. Save to a separate file: removed layouts, font characters and cropped picture pixels may be needed for later editing.
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.LowCode;
using var presentation = new Presentation("input.pptx");
Compress.CompressPresentation(presentation);
presentation.Save("compressed.pptx", SaveFormat.Pptx);
Compress Images at a Chosen Resolution
Use Compress.CompressImages to process eligible pictures without also removing layouts or subsetting fonts. This example uses 96 DPI; select another PicturesCompression value for your output needs.
using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.LowCode;
using var presentation = new Presentation("input.pptx");
Compress.CompressImages(presentation, PicturesCompression.Dpi96);
presentation.Save("compressed-images.pptx", SaveFormat.Pptx);
Both helpers use the following picture-processing scope:
| सामग्री | उपचार |
|---|---|
| सामान्य, मास्टर और लेआउट स्लाइडों पर रैस्टर चित्र और शैप पिक्चर फ़िल्स, समूहित शैप सहित | संकुचन के योग्य। |
| अनुरोधित रिज़ॉल्यूशन से पहले या उससे कम वाले चित्र | अपस्केल नहीं किया जाता। क्रॉप किए हुए हिस्से अभी भी हटाए जा सकते हैं। |
| क्रॉप किए हुए चित्र क्षेत्र | छिपे पिक्सेल स्थायी रूप से हटाए जाते हैं और क्रॉप ऑफ़सेट रीसेट होते हैं। |
| स्लाइड बैकग्राउंड और टेबल‑सेल फ़िल्स | इन सहायक द्वारा प्रोसेस नहीं किये जाते। |
| चार्ट/स्मार्टआर्ट इंटर्नल्स, GIF और वेक्टर फ़ॉर्मेट जैसे SVG, EMF और WMF | दस्तावेज़ित इमेज‑कम्प्रेशन स्कोप के बाहर। |
In 26.11, PicturesCompression.DocumentResolution avoids resolution‑based downsampling of an uncropped picture, but does not preserve cropped pixels. A cropped picture can still be rewritten with its hidden areas removed. Neither helper exposes a preserve‑crop option. For individual control, see the per-picture compression example.
Compare the output’s appearance and file size before replacing the original. Savings depend on the source pictures, their displayed size and unused content; compression does not guarantee a smaller file. See Embedded Fonts for the implications of font subsetting.
FAQ
When should I use the low-code API instead of the full object model?
Use low-code helpers when a standard operation applies to a complete file or presentation and does not require detailed control over individual elements. Use the full object model when you need to select specific slides, control master and layout relationships, inspect intermediate state, or configure behavior that the helper does not expose.
Can Merger combine presentations in different file formats?
No. Merger.Process requires input presentations in the same format. Convert the input files to a common format first, for example with Convert.AutoByExtension, and then merge the converted files.
Does ForEach process master, layout, and notes slides?
ForEach.Slide iterates through normal presentation slides. Presentation-wide ForEach.Shape, ForEach.Paragraph, and ForEach.Portion operations include normal, master, and layout slides by default. Use their overloads with includeNotes set to true to include notes slides.
What is the difference between ForEach.Shape and Collect.Shapes?
Use ForEach.Shape to process each shape immediately through a callback. Use Collect.Shapes when you need an enumerable result that can be retained, filtered, counted, or traversed multiple times.
Does Compress always make the presentation file smaller?
Not necessarily. Savings depend on unused layouts/masters, embedded fonts with unused characters, and pictures that benefit from compression. The Compress helpers may leave the size unchanged or produce a larger file for some inputs. Compare both size and rendered quality, and keep the original.
Are changes made by ForEach or Compress saved automatically?
No. These helpers operate on the loaded Presentation object in memory. After changing elements in a ForEach callback or running Compress, call Presentation.Save to write the result.