Skip to content

Instantly share code, notes, and snippets.

Avatar

conholdate-gists

View GitHub Profile
@conholdate-gists
conholdate-gists / Convert-PDF-to-PPT.java
Created Aug 18, 2022
Convert PDF to PPT using Java
View Convert-PDF-to-PPT.java
// Create an object of Document class and load the source file
Document doc = new Document("sample.pdf");
// Invoke this method setBackground to set the background color of the document
doc.setBackground(Color.getCoral().toRgb());
// Call this setFitWindow method to set flag specifying whether document window must be resized to fit the first displayed page.
doc.setFitWindow(true);
// Instantiate PptxSaveOptions instance
PptxSaveOptions pptx_save = new PptxSaveOptions();
// If setSlidesAsImages method value is true then all the content is recognized as images (one per page)
pptx_save.setSlidesAsImages(true);
@conholdate-gists
conholdate-gists / Create-BarCode.cs
Last active Aug 15, 2022
Create BarCode using C#
View Create-BarCode.cs
int Resolution = 300;//300 dpi high resolution of the barcode image
int leftBarcodePosition = 10;//left position of the barcode image
int topBarcodePosition = 20;//top position of the barcode image
//create a PDF document with a new page by creating an instance of Aspose.Pdf.Document() class
Aspose.Pdf.Document pdfDoc = new Aspose.Pdf.Document();
Aspose.Pdf.Page pdfPage = pdfDoc.Pages.Add();
//convert the barcode image to a PNG stream by instantiating an instance of BarcodeGenerator class
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Pdf417, "Aspose.Barcode Example");
// Invoke the Resolution property to set the barcode image resolution
@conholdate-gists
conholdate-gists / excel-to-svg.js
Created Aug 14, 2022
Convert Excel to SVG in Node.js
View excel-to-svg.js
var aspose = aspose || {};
aspose.cells = require("aspose.cells");
// Create a workbook object and load the source file
var workbook = new aspose.cells.Workbook("sample.xlsx");
// Initialize an instance of the ImageOrPrintOptions class to access additional image creation options
var imgOptions = new aspose.cells.ImageOrPrintOptions();
// Convert each worksheet into svg format in a single page by calling setSaveFormat method
imgOptions.setSaveFormat(aspose.cells.SaveFormat.SVG);
// Invoke this setOnePagePerSheet method to put all content of one sheet to only one page.
imgOptions.setOnePagePerSheet(true);
@conholdate-gists
conholdate-gists / Encrypt-Excel-Files.Java
Last active Aug 10, 2022
Encrypt Excel Files in Java
View Encrypt-Excel-Files.Java
// Instantiate a Workbook object and load an Excel file path
Workbook workbook = new Workbook("sample.xlsx");
// Password protect the file by calling the setPassword method.
workbook.getSettings().setPassword("1234");
// Specify XOR encrption type by setting values of the setEncryptionOptions method.
workbook.setEncryptionOptions(EncryptionType.XOR, 40);
// Specify Strong Encryption type (RC4,Microsoft Strong Cryptographic Provider).
workbook.setEncryptionOptions(EncryptionType.STRONG_CRYPTOGRAPHIC_PROVIDER, 128);
// Invoke the save to save the Excel file.
workbook.save( "EncryptingFiles_out.xls");
@conholdate-gists
conholdate-gists / Convert-Excel-to-XML.js
Last active Aug 8, 2022
Convert Excel to XML in Node.js
View Convert-Excel-to-XML.js
var aspose = aspose || {};
aspose.cells = require("aspose.cells");
// Create an object of the Workbook class and load the source excel file
var wb = new aspose.cells.Workbook("sample.xlsx");
// Instantiate an instance of the XmlSaveOptions() class that will be used to save a file in XML file format.
var XmlSaveOptions = new aspose.cells.XmlSaveOptions();
// Invoke the save method to save the file
wb.save("DocumentConversionProgress.xml", XmlSaveOptions);
View Convert-PNG-to-PDF.java
public static void ConvertImageToPDF(String inputFileName, String outputFileName) throws Exception {
// Instantiate an instance of Document class
Document doc = new Document();
// Create an object of DocumentBuilder class to make it simple to add content to the document.
DocumentBuilder builder = new DocumentBuilder(doc);
// Load images from the disk using the appropriate reader.
// The file formats that can be loaded depends on the image readers available on the machine.
// Load the input image file by calling the createImageInputStream method and assign it to the object of ImageInputStream.
View convert-Excel-to-XML-in-Csharp.cs
// Create an instance of Workbook class and load the source Excel file
Workbook workbook = new Workbook("sample.xlsx");
// Invoke Save method to save as Excel 2003 Spreadsheet XML
workbook.Save("Spreadsheet.xml");
// Initialize an object of xmlSaveOptions class to save as plain XML data
XmlSaveOptions xmlSaveOptions = new XmlSaveOptions();
// save the XML file by calling the Save method
workbook.Save("data.xml", xmlSaveOptions);
@conholdate-gists
conholdate-gists / Visio-to-pdf-adv.java
Last active Jul 27, 2022
How to Convert Visio to PDF in Java
View Visio-to-pdf-adv.java
// Create an object of Diagram class to load diagram from a VSDX file
Diagram diagram = new Diagram( "sample.vsdx");
// Instantiate an instance of PdfSaveOptions class to specify additional options when rendering diagram pages to PDF.
PdfSaveOptions options = new PdfSaveOptions();
// pass a value to the SplitMultiPages method to define whether split diagram to multi pages according to page's setting. option
options.setSplitMultiPages(true);
// Specify the quality of JPEG compression for images by calling the setJpegQuality method
options.setJpegQuality(100);
// Invoke the setPageSize method to sets the page size for the generated images
options.setPageSize(null);
@conholdate-gists
conholdate-gists / pdf-to-text-adv.cs
Last active Jul 26, 2022
How to Convert PDF to Text in C#
View pdf-to-text-adv.cs
string fullPath = "final.pdf";
// instantiate an instance of the AsposeOcr class
AsposeOcr api = new AsposeOcr();
// Create an instance of the MemoryStream class to recognize pdf from stream
using (MemoryStream ms = new MemoryStream())
{
// Initialize the constructor of FileStream and load the source file
using (FileStream file = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
{
@conholdate-gists
conholdate-gists / convert-html-to-documents-and-images-in-net.md
Last active Jul 22, 2022
HTML to Documents & Images Conversion in C# .NET
View convert-html-to-documents-and-images-in-net.md

Convert HTML to 100+ Documents & Image Formats in C#

Native C# .NET documents conversion APIs to convert from HTML and other web formats to images and 100+ document formats including OpenDocument, Microsoft Word, Excel, PowerPoint HTML, Photoshop and many more.

The below C# code examples demonstrates how to convert HTML files to images, Excel spreadsheet, PowerPoint presentation and Word processing document formats.

View a list of all supported document conversion file formats https://docs.groupdocs.com/conversion/net/supported-document-formats/

Installation