Spire.Office for Java 7.8.0 is released
We are glad to announce the release of Spire.Office for Java 7.8.0. In this version, Spire.XLS for Java supports custom sorting and supports converting Excel containing chart types defined by Excel 2016 to PDF and images; Spire.Presentation for Java supports converting all slides from a PowerPoint document to an SVG file and deleting macros from PPTM files; Spire.Doc for Java enhances the conversion from Word and HTML to PDF; Spire.PDF for Java enhances the conversion from PDF to images, Tiff, OFD, and PDF/A3A as well as Tiff to PDF. Additionally, many known bugs have been fixed successfully. More details are listed below.
Here is a list of changes made in this release
Spire.XLS for Java
Category | ID | Description |
New feature | SPIREXLS-3704 | Supports custom sorting.
wb.getDataSorter().getSortColumns().add(0, new String[] {"12345","Argentina", "Area", "Chile", "Capital","USA","Ecuador","Guyana"} ); wb.getDataSorter().sort(wb.getWorksheets().get(0).getRange().get("A1:A8")); |
New feature | - | Supports converting Excel containing chart types defined by Excel 2016 to PDF and images. |
Bug | SPIREXLS-3524 | Fixes the issue that caused incorrect chart content after converting Excel to PDF. |
Bug | SPIREXLS-3862 | Fixes the issue that caused incorrect line color after converting Excel to Html. |
Bug | SPIREXLS-3863 | Fixes the issue that the chart became blurry after converting Excel to Html. |
Bug | SPIREXLS-3975 | Fixes the issue that caused incorrect data after importing data from datatable in sheet |
Bug | SPIREXLS-3976 | Fixes the issue that the line format was changed after adding TrendLines to chart. |
Bug | SPIREXLS-3979 | Fixes the issue that the content in X axis was incorrect after converting chart to image. |
Spire.Presentation for Java
Category | ID | Description |
New feature | SPIREPPT-1983 | Supports deleting macros from PPTM files. |
New feature | SPIREPPT-1995 | Provides the method isSlideSizeAutoFit() to fit content to the slide size when cloning slides. Note: currently only 4:3->16:9 is supported.
Presentation presentation1 =new Presentation(); presentation1.loadFromFile(inputFile_1); Presentation presentation2 =new Presentation(); presentation2.loadFromFile(inputFile_2); presentation1.isSlideSizeAutoFit(true); ILayout layout = presentation1.getSlides().get(0).getLayout(); presentation1.getSlides().append(presentation2.getSlides().get(0),layout); presentation1.saveToFile(outputFile, FileFormat.PPTX_2013); |
New feature | SPIREPPT-1996 | Supports converting all slides from a PowerPoint document to an SVG file.
byte[] bytes=ppt.saveToOneSVG(); try(java.io.FileOutputStream stream = new java.io.FileOutputStream(outputFile)){ stream.write(bytes); } |
Bug | SPIREPPT-1982 | Fixes the issue that the application threw exceptions "NullPointerException" and “Unsupported Image Type” when converting PPT to images. |
Bug | SPIREPPT-1990 | Fixes the issue that the size of text font was reduced after splitting the PowerPoint document according to the slides. |
Bug | SPIREPPT-1991 | Fixes the issue that when setShowLoop(true) method has been set to loop the slideshow, the Microsoft PowerPoint would stop after playing the first slide. |
Bug | SPIREPPT-1994 | Optimizes the speed of loading PowerPoint files. |
Bug | SPIREPPT-2000 | Adjusts the names of slide.SaveToFile(), SaveToSVG() methods to saveToFile() and saveToSVG(). |
Bug | SPIREPPT-2004 | Fixes the issue that the application threw exception “Java heap space" when converting PowerPoint to images. |
Spire.Doc for Java
Category | ID | Description |
Bug | SPIREDOC-4372 | Fixes the issue that the application hung when converting Word to PDF. |
Bug | SPIREDOC-6957 | Fixes the issue that the application threw the "IndexOutOfBoundException" when converting HTML to PDF. |
Bug | SPIREDOC-7123 | Fixes the issue that the password was lost after loading and saving a password-protected Word document. |
Bug | SPIREDOC-7524 | Fixes the issue that caused incorrect number list after converting Word to HTML. |
Bug | SPIREDOC-7620 SPIREDOC-7628 SPIREDOC-7732 SPIREDOC-7736 SPIREDOC-7737 SPIREDOC-7750 SPIREDOC-7751 SPIREDOC-7752 SPIREDOC-7907 SPIREDOC-8005 SPIREDOC-8009 SPIREDOC-8060 SPIREDOC-8062 |
Fixes the issue that caused incorrect pagination after converting Word to PDF. |
Bug | SPIREDOC-7658 SPIREDOC-8043 |
Fixes the issue that caused incorrect text wrapping after converting Word to PDF. |
Bug | SPIREDOC-7713 SPIREDOC-7741 SPIREDOC-7831 SPIREDOC-7999 |
Fixes the issue that the contents were overlapped after converting Word to PDF. |
Bug | SPIREDOC-7739 | Fixes the issue that the location of line was incorrect after converting Word to PDF. |
Bug | SPIREDOC-7748 | Fixes the issue that the location of number was incorrect after converting Word to PDF. |
Bug | SPIREDOC-7758 | Fixes the issue that caused incorrect content format after converting Word to PDF. |
Bug | SPIREDOC-7820 | Fixes the issue that the table text was not centered after converting Word to PDF. |
Bug | SPIREDOC-7851 | Fixes the issue that setting the docPicture.setWidthScale and docPicture.setHeightScale properties didn't take effect. |
Bug | SPIREDOC-7913 | Fixes the issue that caused incomplete content and blurry table after converting Word to PDF. |
Bug | SPIREDOC-7912 | Fixes the issue that caused incorrect table format after converting HTML to image. |
Bug | SPIREDOC-7914 SPIREDOC-7926 SPIREDOC-7932 SPIREDOC-7942 |
Fixes the issue that the decimal point was covered after converting Word to PDF. |
Bug | SPIREDOC-7955 | Fixes the issue that the content was blank after converting Word to PDF. |
Bug | SPIREDOC-7966 | Fixes the issue that the date repeated after converting Word to PDF. |
Bug | SPIREDOC-7981 | Fixes the issue that the border of table was lost after converting Word to PDF. |
Bug | SPIREDOC-8011 | Fixes the issue that the content was blank after adding LatexMathCode. |
Bug | SPIREDOC-8012 | Fixes the issue that caused incorrect content after adding LatexMathCode. |
Bug | SPIREDOC-8039 | Fixes the issue that caused incorrect order of cell content after converting Word to PDF. |
Bug | SPIREDOC-8040 | Fixes the issue that caused incorrect wrapping of cell content after converting Word to PDF. |
Bug | SPIREDOC-8065 | Fixes the issue that the table contents were messed up after converting Word to PDF. |
Bug | SPIREDOC-8078 | Fixes the issue that the application threw the "IndexOutOfBoundException" when removing table cell. |
Bug | SPIREDOC-8087 | Fixes the issue that caused incorrect text wrapping after converting Word to PDF. |
Bug | SPIREDOC-8093 | Fixes the issue that the application threw the "Unknow char: \" when appending HTML to Word. |
Bug | SPIREDOC-8104 | Fixes the issue that the text was garbled after converting Word PDF with new engine. |
Bug | SPIREDOC-8155 | Fixes the issue that the application threw the Unknown char: ' when loading Word document. |
Bug | SPIREDOC-8172 | Fixes the issue that caused incorrect data of field after converting Word to PDF. |
Bug | SPIREDOC-8201 | Fixes the issue that the decimal point was lost after converting Word to PDF. |
Spire.PDF for Java
Category | ID | Description |
Bug | SPIREPDF-5248 | Fixes the issue that some characters were incorrect after converting PDF to PDF/A3A. |
Bug | SPIREPDF-5312 | Fixes the issue that the application threw exception "Parameter is invalid" when converting PDF to Tiff. |
Bug | SPIREPDF-5322 | Fixes the issue that the location of text was incorrect after converting PDF to image. |
Bug | SPIREPDF-5327 | Fixed the issue that after converting PDF to OFD, the content was lost when opened with Dotpoly OFD reader. |
Bug | SPIREPDF-5332 | Fixes the issue that the text displayed incorrectly after converting PDF to image. |
Bug | SPIREPDF-5337 | Fixes the issue that the application threw exception "No have this TiffTag" when converting Tiff to PDF. |
Bug | SPIREPDF-5350 | Fixes the issue that the content was lost after converting PDF to OFD. |
Bug | SPIREPDF-5362 | Fixes the issue that the application threw exception "NullPointerException" when loading PDF. |
Spire.PDF for Java 8.8.0 enhances the conversion from PDF to images, OFD and PDF/A3A
We are happy to announce the release of Spire.PDF for Java 8.8.0. This version enhances the conversion from PDF to images, Tiff, OFD, and PDF/A3A as well as Tiff to PDF. Moreover, some known issues are fixed, such as the issue that the application threw exception "NullPointerException" when loading PDF. More details are listed below.
Here is a list of changes made in this release
Category | ID | Description |
Bug | SPIREPDF-5248 | Fixes the issue that some characters were incorrect after converting PDF to PDF/A3A. |
Bug | SPIREPDF-5312 | Fixes the issue that the application threw exception "Parameter is invalid" when converting PDF to Tiff. |
Bug | SPIREPDF-5322 | Fixes the issue that the location of text was incorrect after converting PDF to image. |
Bug | SPIREPDF-5327 | Fixed the issue that after converting PDF to OFD, the content was lost when opened with Dotpoly OFD reader. |
Bug | SPIREPDF-5332 | Fixes the issue that the text displayed incorrectly after converting PDF to image. |
Bug | SPIREPDF-5337 | Fixes the issue that the application threw exception "No have this TiffTag" when converting Tiff to PDF. |
Bug | SPIREPDF-5350 | Fixes the issue that the content was lost after converting PDF to OFD. |
Bug | SPIREPDF-5362 | Fixes the issue that the application threw exception "NullPointerException" when loading PDF. |
Java: Convert Text Files to PDF
Text files can be easily edited by any text editing program. If you want to prevent changes when others view the files, you can convert them to PDF. In this article, we will demonstrate how to convert text files to PDF in Java using Spire.PDF for Java.
Install Spire.PDF for Java
First of all, you're required to add the Spire.Pdf.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<repositories> <repository> <id>com.e-iceblue</id> <name>e-iceblue</name> <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url> </repository> </repositories> <dependencies> <dependency> <groupId>e-iceblue</groupId> <artifactId>spire.pdf</artifactId> <version>8.7.0</version> </dependency> </dependencies>
Convert Text Files to PDF in Java
The following are the main steps to convert a text file to PDF using Spire.PDF for Java:
- Read the text in the text file into a String object.
- Create a PdfDocument instance and add a page to the PDF file using PdfDocument.getPages().add() method.
- Create a PdfTextWidget instance from the text.
- Draw the text onto the PDF page using PdfTextWidget.draw() method.
- Save the result file using PdfDocument.saveToFile() method.
- Java
import com.spire.pdf.FileFormat; import com.spire.pdf.PdfDocument; import com.spire.pdf.PdfPageBase; import com.spire.pdf.graphics.*; import java.awt.geom.Rectangle2D; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; public class ConvertTextToPdf { public static void main(String[] args) throws Exception { //Read the text from the text file String text = readTextFromFile("Input.txt"); //Create a PdfDocument instance PdfDocument pdf = new PdfDocument(); //Add a page PdfPageBase page = pdf.getPages().add(); //Create a PdfFont instance PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 11); //Create a PdfTextLayout instance PdfTextLayout textLayout = new PdfTextLayout(); textLayout.setBreak(PdfLayoutBreakType.Fit_Page); textLayout.setLayout(PdfLayoutType.Paginate); //Create a PdfStringFormat instance PdfStringFormat format = new PdfStringFormat(); format.setLineSpacing(20f); //Create a PdfTextWidget instance from the text PdfTextWidget textWidget = new PdfTextWidget(text, font, PdfBrushes.getBlack()); //Set string format textWidget.setStringFormat(format); //Draw the text at the specified location of the page Rectangle2D.Float bounds = new Rectangle2D.Float(); bounds.setRect(0,25,page.getCanvas().getClientSize().getWidth(),page.getCanvas().getClientSize().getHeight()); textWidget.draw(page, bounds, textLayout); //Save the result file pdf.saveToFile("TextToPdf.pdf", FileFormat.PDF); } public static String readTextFromFile(String fileName) throws IOException { StringBuffer sb = new StringBuffer(); BufferedReader br = new BufferedReader(new FileReader(fileName)); String content = null; while ((content = br.readLine()) != null) { sb.append(content); sb.append("\n"); } return sb.toString(); } }
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Spire.Office 7.7.6 is released
We are excited to announce the release of Spire.Office 7.7.6. In this release, Spire.PDF supports creating tagged PDF files and PDF/UA files; Spire.Doc supports reserving the text direction when using the new engine to convert Word to PDF; Spire.Presentation supports cropping slide pictures; Spire.XLS supports calculating "UNICODE" formulas. Moreover, a number of known issues are fixed successfully. More details are listed below.
In this version, the most recent versions of Spire.Doc, Spire.PDF, Spire.XLS, Spire.Presentation, Spire.Email, Spire.DocViewer, Spire.PDFViewer, Spire.Spreadsheet, Spire.OfficeViewer, Spire.DataExport, Spire.Barcode are included.
DLL Versions:
- Spire.Doc.dll v10.7.16
- Spire.Pdf.dll v8.7.9
- Spire.XLS.dll v12.7.0
- Spire.Email.dll v5.6.0
- Spire.DocViewer.Forms.dll v7.6.0
- Spire.PdfViewer.Forms.dll v7.7.0
- Spire.PdfViewer.Asp.dll v7.7.0
- Spire.Presentation.dll v7.7.1
- Spire.Spreadsheet.dll v6.6.1
- Spire.OfficeViewer.Forms.dll v7.7.6
- Spire.Barcode.dll v6.7.0
- Spire.DataExport.dll v4.5.0
- Spire.DataExport.ResourceMgr.dll v2.1.0
Here is a list of changes made in this release
Spire.Doc
Category | ID | Description |
New feature | - | Supports reserving the text direction when using new engine to convert Word to PDF. |
Adjustment | - | Abandons public IStyle FindById(int styleId) method. |
Adjustment | - | Abandons public IStyle FindByIstd(int istd) method. |
Adjustment | - | Adopts public IStyle FindByIdentifier(int sIdentifier) method. |
Bug | SPIREPDF-6923 | Fixes the issue that the pagination was incorrect after converting Word to PDF. |
Bug | SPIREPDF-7103 SPIREPDF-7796 |
Fixes the issue that the content format was incorrect after converting Word to PDF. |
Bug | SPIREPDF-7591 | Fixes the issue that the line breaks were incorrect after converting Word to PDF. |
Bug | SPIREPDF-7601 | Fixes the issue that the text in table was incomplete after converting Word to PDF. |
Bug | SPIREPDF-7660 | Fixes the issue that the application threw the "InvalidOperationException" when loading HTML. |
Bug | SPIREPDF-7793 | Fixes the issue that the application threw the "InvalidCastException" when replacing picture. |
Bug | SPIREPDF-7821 | Fixes the issue that the application threw "FileNotFoundException" when loading HTML. |
Bug | SPIREPDF-7826 | Fixes the issue that the field text was not set correctly. |
Bug | SPIREPDF-7830 | Fixes the issue that the location of mathematical formula was incorrect after converting Word to PDF. |
Bug | SPIREPDF-7892 | Fixes the issue that setting LinkToPrevious as false didn't take effect when converting Word to PDF using new engine. |
Bug | SPIREPDF-7922 | Fixes the issue that the application threw the "InvalidOperationException" when converting Word to PDF. |
Bug | - | Fixes the reference issue of Comment.CommentMarkEnd and Comment.CommentMarkStart. |
Bug | SPIREDOC-7218 | Fixes the issue that the count of paragraph characters was incorrect. |
Bug | SPIREDOC-7317 | Fixes the issue that there are extra columns after merging cells. |
Bug | SPIREDOC-7467 | Fixes the issue that the application throws "NullReferenceException: Object reference not set to an instance of an object" when loading HTML files. |
Bug | SPIREDOC-7604 | Fixes the issue that extra border lines in the table after converting Word to PDF. |
Bug | SPIREDOC-7833 | Fixes the issue that table borders missing after converting HTML to Word. |
Bug | SPIREDOC-7884 | Fixes the issue that the table position changed after converting HTML to Word. |
Bug | SPIREDOC-7933 | Fixes the issue with incorrect table layout when generating Doc format documents. |
Bug | SPIREDOC-7967 | Fixes the issue of image loss after converting RTF to PDF. |
Bug | SPIREDOC-7968 | Fixed the issue that the multiple columns did not take effect after creating multiple columns and converting Word to PDF. |
Bug | SPIREDOC-8002 | Fixes the issue that there are extra spaces after inserting text to bookmarks. |
Bug | SPIREDOC-8033 | Fixes the issue that the Word to PDF converting program hangs. |
Bug | SPIREDOC-8106 | Fixes the issue of incorrect images after converting Word to PDF |
Bug | SPIREDOC-8125 | Fixes the issue that the application throws an exception "Property value is of unsupported type" when setting custom properties to Null for a document |
Spire.PDF
Category | ID | Description |
New feature | SPIREPDF-3803 |
Support creating tagged PDF files. //Note:At present, in order to ensure the validity of the output tagged PDF file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark. //Spire.License.LicenseProvider.SetLicenseKey("valid license key"); //Create a pdf document PdfDocument doc = new PdfDocument(); //Add page doc.Pages.Add(); //Set tab order doc.Pages[0].SetTabOrder(TabOrder.Structure); //Create PdfTaggedContent PdfTaggedContent taggedContent = new PdfTaggedContent(doc); taggedContent.SetLanguage("en-US"); taggedContent.SetTitle("test"); //Set font PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 10), true); PdfSolidBrush brush = new PdfSolidBrush(Color.Black); //Append elements PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document); PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span); span1.BeginMarkedContent(doc.Pages[0]); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET is a professional PDF API applied to creating, writing, editing, handling and reading PDF files.", font, brush, new Rectangle(40, 0, 480, 80), format); span1.EndMarkedContent(doc.Pages[0]); PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); paragraph2.BeginMarkedContent(doc.Pages[0]); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET can be applied to easily convert Text, Image, SVG, HTML to PDF and convert PDF to Excel with C#/VB.NET in high quality.", font, brush, new Rectangle(40, 80, 480, 60), format); paragraph2.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure1.Alt = "replacement text1"; figure1.BeginMarkedContent(doc.Pages[0], null); PdfImage image = PdfImage.FromFile(@"E-logo.png"); doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100)); figure1.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure2.Alt = "replacement text2"; figure2.BeginMarkedContent(doc.Pages[0], null); doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100)); figure2.EndMarkedContent(doc.Pages[0]); //Save to file String result = "CreateTaggedFile_result.pdf"; doc.SaveToFile(result); doc.Close(); |
New feature | SPIREPDF-4559 | Support creating PDF/UA files.
//Note:At present, in order to ensure the validity of the output PDF/UA file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark. //Spire.License.LicenseProvider.SetLicenseKey("valid license key"); //Create a pdf document PdfDocument doc = new PdfDocument(); //Add page doc.Pages.Add(); //Set tab order doc.Pages[0].SetTabOrder(TabOrder.Structure); //Create PdfTaggedContent PdfTaggedContent taggedContent = new PdfTaggedContent(doc); taggedContent.SetLanguage("en-US"); taggedContent.SetTitle("test"); //Set PDF/UA1 identification taggedContent.SetPdfUA1Identification(); //Set font PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 10), true); PdfSolidBrush brush = new PdfSolidBrush(Color.Black); //Append elements PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document); PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span); span1.BeginMarkedContent(doc.Pages[0]); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET is a professional PDF API applied to creating, writing, editing, handling and reading PDF files.", font, brush, new Rectangle(40, 0, 480, 80), format); span1.EndMarkedContent(doc.Pages[0]); PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); paragraph2.BeginMarkedContent(doc.Pages[0]); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET can be applied to easily convert Text, Image, SVG, HTML to PDF and convert PDF to Excel with C#/VB.NET in high quality.", font, brush, new Rectangle(40, 80, 480, 60), format); paragraph2.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure1.Alt = "replacement text1"; figure1.BeginMarkedContent(doc.Pages[0], null); PdfImage image = PdfImage.FromFile(@"E-logo.png"); doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100)); figure1.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure2.Alt = "replacement text2"; figure2.BeginMarkedContent(doc.Pages[0], null); doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100)); figure2.EndMarkedContent(doc.Pages[0]); //Save to file String result = "CreatePDFUAFile_result.pdf"; doc.SaveToFile(result); doc.Close(); |
Bug | SPIREPDF-4227 | Fixes the issue that the application threw "System.NotSupportedException" when signing a PDF document with a timestamp server. |
Bug | SPIREPDF-4596 | Fixes the issue that the content format was incorrect after converting PDF to excel file. |
Bug | SPIREPDF-5214 | Fixes the issue that the application threw "System.NullReferenceException" when converting PDF to SVG. |
Bug | SPIREPDF-5247 | Fixes the issue that the stamp content format was incorrect after printing PDF file. |
Bug | SPIREPDF-5266 | Optimizes the time consumption issue when finding PDF file text. |
Bug | SPIREPDF-5277 | Fixes the issue that the ReplaceAllText() function didn't take effect. |
Bug | SPIREPDF-5292 | Optimizes the DrawString() method to draw Html string. |
Bug | SPIREPDF-5314 | Fixes the issue that the RemoveCustomProperty() function effect was incorrect. |
Bug | SPIREPDF-5317 | Fixes the issue that the application threw "System.OutOfMemoryException" when compressing PDF images. |
Bug | SPIREPDF-5318 | Fixes the issue that the output PDF couldn't be opened after converting from a u3d file. |
Bug | SPIREPDF-5319 | Fixes the issue that the size of the extracted images was incorrect. |
Bug | SPIREPDF-5330 | Fixes the issue that the QR code of the PDF file was incorrect after converting PDF to image. |
Bug | SPIREPDF-5331 | Fixes the issue that the application threw "System.NullReferenceException" when extracting text from a PDF/A file. |
Bug | SPIREPDF-5333 | Fixes the issue that it wasn't able to find text from a PDF file. |
Bug | SPIREPDF-5336 | Fixes the issue that the application threw "Invalid year in date string" after loading and then directly saving a PDF file. |
Bug | SPIREPDF-5351 | Fixes the issue that the content lost after printing a PDF file. |
Bug | SPIREPDF-5305 | Fixes the issue that the application threw "System.IndexOutOfRangeException" when merging PDF files. |
Spire.PDFViewer
Category | ID | Description |
Bug | SPIREPDFVIEWER-492 | Optimizes document loading time. |
Bug | SPIREPDFVIEWER-542 | Fixes the issue that the document became blank when viewing. |
Bug | SPIREPDFVIEWER-547 | Fixes the issue that the application threw "value can not be null" when rotating PDF. |
Bug | SPIREPDFVIEWER-551 | Fixes the issue that the stamp was lost when viewing. |
Spire.XLS
Category | ID | Description |
New feature | SPIREXLS-3944 | Supports setting whether to keep the number format of the data when exporting to DataTable.
ExportTableOptions options = new ExportTableOptions(); options.KeepDataFormat = false; DataTable table = sheet.ExportDataTable(1, 1, sheet.LastDataRow, sheet.LastDataColumn, options); |
New feature | - | Supports calculating "UNICODE" formulas. |
Bug | SPIREXLS-3902 | Fixes the issue that the column names of the pivot table were offset after converting Excel to PDF. |
Bug | SPIREXLS-3957 | Fixes the issue that "System.FormatException: Input string was not in a correct format" was thrown when loading HTML files |
Bug | SPIREXLS-3966 | Fixes the issue that formulas were not calculated after inserting formulas. |
Bug | SPIREXLS-3967 | Fixes the issue that "CellRange.DisplayedText" property getting incorrect value. |
Bug | SPIREXLS-3971 | Fixes the issue that "System.FormatException: The string is not recognized as a valid DateTime" exception was thrown when converting Excel to PDF. |
Bug | SPIREXLS-3972 | Fixes an issue that the application threw a null pointer exception when getting the name manager for a non-contiguous range. |
Spire.Presentation
Category | ID | Description |
New feature | SPIREPPT-1965 | Supports cropping slide picture.
SlidePicture slidePicture = (SlidePicture)presentation.Slides[0].Shapes[0]; slidePicture.Crop(float x, float y, float width, float height); |
New feature | SPIREPPT-1984 | Provides InsertPicture(stream) to insert picture from file stream.
presentation.Slides[0].Shapes[0].InsertPicture(Stream stream) |
New feature | - | Supports creating new chart types in PowerPoint2016 (Waterfall, Treemap, Boxandwhisker, Histogram, Pareto, SunBurst).
public void CreateWaterFall(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.WaterFall, new RectangleF(50, 50, 500, 400), false); chart.ChartData[0, 1].Text = "Series 1"; string[] categories = { "Category 1", "Category 2", "Category 3", "Category 4", "Category 5", "Category 6", "Category 7" }; for (int i = 0; i < categories.Length; i++) { chart.ChartData[i + 1, 0].Text = categories[i]; } double[] values = { 100, 20, 50, -40, 130, -60, 70 }; for (int i = 0; i < values.Length; i++) { chart.ChartData[i + 1, 1].NumberValue = values[i]; } chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, 1]; chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0]; chart.Series[0].Values = chart.ChartData[1, 1, values.Length, 1]; ChartDataPoint chartDataPoint = new ChartDataPoint(chart.Series[0]); chartDataPoint.Index = 2; chartDataPoint.SetAsTotal = true; chart.Series[0].DataPoints.Add(chartDataPoint); ChartDataPoint chartDataPoint2 = new ChartDataPoint(chart.Series[0]); chartDataPoint2.Index = 5; chartDataPoint2.SetAsTotal = true; chart.Series[0].DataPoints.Add(chartDataPoint2); chart.Series[0].ShowConnectorLines = true; chart.Series[0].DataLabels.LabelValueVisible = true; chart.ChartLegend.Position = ChartLegendPositionType.Right; chart.ChartTitle.TextProperties.Text = "WaterFall"; } public void CreateTreeMap(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.TreeMap, new RectangleF(50, 50, 500, 400), false); chart.ChartData[0, 3].Text = "Series 1"; string[,] categories = {{"Branch 1","Stem 1","Leaf 1"},{"Branch 1","Stem 1","Leaf 2"},{"Branch 1","Stem 1", "Leaf 3"}, {"Branch 1","Stem 2","Leaf 4"},{"Branch 1","Stem 2","Leaf 5"},{"Branch 1","Stem 2","Leaf 6"},{"Branch 1","Stem 2","Leaf 7"}, {"Branch 2","Stem 3","Leaf 8"},{"Branch 2","Stem 3","Leaf 9"},{"Branch 2","Stem 4","Leaf 10"},{"Branch 2","Stem 4","Leaf 11"}, {"Branch 2","Stem 5","Leaf 12"},{"Branch 3","Stem 5","Leaf 13"},{"Branch 3","Stem 6","Leaf 14"},{"Branch 3","Stem 6","Leaf 15"}}; for (int i = 0; i < 15; i++) { for (int j = 0; j < 3; j++) chart.ChartData[i + 1, j].Text = categories[i, j]; } double[] values = { 17, 23, 48, 22, 76, 54, 77, 26, 44, 63, 10, 15, 48, 15, 51 }; for (int i = 0; i < values.Length; i++) { chart.ChartData[i + 1, 3].NumberValue = values[i]; } chart.Series.SeriesLabel = chart.ChartData[0, 3, 0, 3]; chart.Categories.CategoryLabels = chart.ChartData[1, 0, values.Length, 2]; chart.Series[0].Values = chart.ChartData[1, 3, values.Length, 3]; chart.Series[0].DataLabels.CategoryNameVisible = true; chart.Series[0].TreeMapLabelOption = TreeMapLabelOption.Banner; chart.ChartTitle.TextProperties.Text = "TreeMap"; chart.HasLegend = true; chart.ChartLegend.Position = ChartLegendPositionType.Top; } public void CreateSunBurs(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.SunBurst, new RectangleF(50, 50, 500, 400), false); chart.ChartData[0, 3].Text = "Series 1"; string[,] categories = {{"Branch 1","Stem 1","Leaf 1"},{"Branch 1","Stem 1","Leaf 2"},{"Branch 1","Stem 1", "Leaf 3"}, {"Branch 1","Stem 2","Leaf 4"},{"Branch 1","Stem 2","Leaf 5"},{"Branch 1","Leaf 6",null},{"Branch 1","Leaf 7", null}, {"Branch 2","Stem 3","Leaf 8"},{"Branch 2","Leaf 9",null},{"Branch 2","Stem 4","Leaf 10"},{"Branch 2","Stem 4","Leaf 11"}, {"Branch 2","Stem 5","Leaf 12"},{"Branch 3","Stem 5","Leaf 13"},{"Branch 3","Stem 6","Leaf 14"},{"Branch 3","Leaf 15",null}}; for (int i = 0; i < 15; i++) { for (int j = 0; j < 3; j++) chart.ChartData[i + 1, j].Value = categories[i, j]; } double[] values = { 17, 23, 48, 22, 76, 54, 77, 26, 44, 63, 10, 15, 48, 15, 51 }; for (int i = 0; i < values.Length; i++) { chart.ChartData[i + 1, 3].NumberValue = values[i]; } chart.Series.SeriesLabel = chart.ChartData[0, 3, 0, 3]; chart.Categories.CategoryLabels = chart.ChartData[1, 0, values.Length, 2]; chart.Series[0].Values = chart.ChartData[1, 3, values.Length, 3]; chart.Series[0].DataLabels.CategoryNameVisible = true; chart.ChartTitle.TextProperties.Text = "SunBurst"; chart.HasLegend = true; chart.ChartLegend.Position = ChartLegendPositionType.Top; } public void CreatePareto(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.Pareto, new RectangleF(50, 50, 500, 400), false); chart.ChartData[0, 1].Text = "Series 1"; string[] categories = { "Category 1", "Category 2", "Category 4", "Category 3", "Category 4", "Category 2", "Category 1", "Category 1", "Category 3", "Category 2", "Category 4", "Category 2", "Category 3", "Category 1", "Category 3", "Category 2", "Category 4", "Category 1", "Category 1", "Category 3", "Category 2", "Category 4", "Category 1", "Category 1", "Category 3", "Category 2", "Category 4", "Category 1"}; for (int i = 0; i < categories.Length; i++) { chart.ChartData[i + 1, 0].Text = categories[i]; } double[] values = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 }; for (int i = 0; i < values.Length; i++) { chart.ChartData[i + 1, 1].NumberValue = values[i]; } chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, 1]; chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0]; chart.Series[0].Values = chart.ChartData[1, 1, values.Length, 1]; chart.PrimaryCategoryAxis.IsBinningByCategory = true; chart.Series[1].Line.FillFormat.FillType = FillFormatType.Solid; chart.Series[1].Line.FillFormat.SolidFillColor.Color = Color.Red; chart.ChartTitle.TextProperties.Text = "Pareto"; chart.HasLegend = true; chart.ChartLegend.Position = ChartLegendPositionType.Bottom; } public void CreateHistogram(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.Histogram, new RectangleF(50, 50, 500, 400), false); chart.ChartData[0, 0].Text = "Series 1"; double[] values = { 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 8, 8, 8, 9, 9, 9, 12, 12, 13, 13, 17, 17, 17, 19, 19, 19, 25, 25, 25, 25, 25, 25, 25, 25, 29, 29, 29, 29, 32, 32, 33, 33, 35, 35, 41, 41, 44, 45, 49, 49 }; for (int i = 0; i < values.Length; i++) { chart.ChartData[i + 1, 1].NumberValue = values[i]; } chart.Series.SeriesLabel = chart.ChartData[0, 0, 0, 0]; chart.Series[0].Values = chart.ChartData[1, 0, values.Length, 0]; chart.PrimaryCategoryAxis.NumberOfBins = 7; chart.PrimaryCategoryAxis.GapWidth = 20; chart.ChartTitle.TextProperties.Text = "Histogram"; chart.ChartLegend.Position = ChartLegendPositionType.Bottom; } public void CreateBoxAndWhisker(Presentation ppt) { IChart chart = ppt.Slides[0].Shapes.AppendChart(ChartType.BoxAndWhisker, new RectangleF(50, 50, 500, 400), false); string[] seriesLabel = { "Series 1", "Series 2", "Series 3" }; for (int i = 0; i < seriesLabel.Length; i++) { chart.ChartData[0, i + 1].Text = "Series 1"; } string[] categories = {"Category 1", "Category 1", "Category 1", "Category 1", "Category 1", "Category 1", "Category 1", "Category 2", "Category 2", "Category 2", "Category 2", "Category 2", "Category 2", "Category 3", "Category 3", "Category 3", "Category 3", "Category 3"}; for (int i = 0; i < categories.Length; i++) { chart.ChartData[i + 1, 0].Text = categories[i]; } double[,] values = new double[18, 3]{{-7,-3,-24},{-10,1,11},{-28,-6,34},{47,2,-21},{35,17,22},{-22,15,19},{17,-11,25}, {-30,18,25},{49,22,56},{37,22,15},{-55,25,31},{14,18,22},{18,-22,36},{-45,25,-17}, {-33,18,22},{18,2,-23},{-33,-22,10},{10,19,22}}; for (int i = 0; i < seriesLabel.Length; i++) { for (int j = 0; j < categories.Length; j++) { chart.ChartData[j + 1, i + 1].NumberValue = values[j, i]; } } chart.Series.SeriesLabel = chart.ChartData[0, 1, 0, seriesLabel.Length]; chart.Categories.CategoryLabels = chart.ChartData[1, 0, categories.Length, 0]; chart.Series[0].Values = chart.ChartData[1, 1, categories.Length, 1]; chart.Series[1].Values = chart.ChartData[1, 2, categories.Length, 2]; chart.Series[2].Values = chart.ChartData[1, 3, categories.Length, 3]; chart.Series[0].ShowInnerPoints = false; chart.Series[0].ShowOutlierPoints = true; chart.Series[0].ShowMeanMarkers = true; chart.Series[0].ShowMeanLine = true; chart.Series[0].QuartileCalculationType = QuartileCalculation.ExclusiveMedian; chart.Series[1].ShowInnerPoints = false; chart.Series[1].ShowOutlierPoints = true; chart.Series[1].ShowMeanMarkers = true; chart.Series[1].ShowMeanLine = true; chart.Series[1].QuartileCalculationType = QuartileCalculation.InclusiveMedian; chart.Series[2].ShowInnerPoints = false; chart.Series[2].ShowOutlierPoints = true; chart.Series[2].ShowMeanMarkers = true; chart.Series[2].ShowMeanLine = true; chart.Series[2].QuartileCalculationType = QuartileCalculation.ExclusiveMedian; chart.HasLegend = true; chart.ChartTitle.TextProperties.Text = "BoxAndWhisker"; chart.ChartLegend.Position = ChartLegendPositionType.Top; } |
Spire.Doc 10.7.16 enhances the conversion from Word to PDF and HTML to Word
We are pleased to announce the release of Spire.Doc 10.7.16. This version enhances the conversion from Word to PDF as well as HTML to Word. What’s more, it fixes some known issues such as the count of paragraph characters was incorrect. More details are listed below.
Here is a list of changes made in this release
Category | ID | Description |
Bug | SPIREDOC-7218 | Fixes the issue that the count of paragraph characters was incorrect. |
Bug | SPIREDOC-7317 | Fixes the issue that there are extra columns after merging cells. |
Bug | SPIREDOC-7467 | Fixes the issue that the application throws "NullReferenceException: Object reference not set to an instance of an object" when loading HTML files. |
Bug | SPIREDOC-7604 | Fixes the issue that extra border lines in the table after converting Word to PDF. |
Bug | SPIREDOC-7833 | Fixes the issue that table borders missing after converting HTML to Word. |
Bug | SPIREDOC-7884 | Fixes the issue that the table position changed after converting HTML to Word. |
Bug | SPIREDOC-7933 | Fixes the issue with incorrect table layout when generating Doc format documents. |
Bug | SPIREDOC-7967 | Fixes the issue of image loss after converting RTF to PDF. |
Bug | SPIREDOC-7968 | Fixed the issue that the multiple columns did not take effect after creating multiple columns and converting Word to PDF. |
Bug | SPIREDOC-8002 | Fixes the issue that there are extra spaces after inserting text to bookmarks. |
Bug | SPIREDOC-8033 | Fixes the issue that the Word to PDF converting program hangs. |
Bug | SPIREDOC-8106 | Fixes the issue of incorrect images after converting Word to PDF |
Bug | SPIREDOC-8125 | Fixes the issue that the application throws an exception "Property value is of unsupported type" when setting custom properties to Null for a document |
Spire.Doc for Java 10.7.10 enhances the conversion from Word and HTML to PDF
We are excited to announce the release of Spire.Doc for Java 10.7.10. This version enhances the conversion from Word and HTML to PDF, HTML to images, and Word to HTML. Besides, some known issues are fixed, such as the issue that the password was lost after loading and saving a password-protected Word document and the issue that setting the docPicture.setWidthScale and docPicture.setHeightScale properties didn't take effect. More details are listed below.
Here is a list of changes made in this release
Category | ID | Description |
Bug | SPIREDOC-4372 | Fixes the issue that the application hung when converting Word to PDF. |
Bug | SPIREDOC-6957 | Fixes the issue that the application threw the "IndexOutOfBoundException" when converting HTML to PDF. |
Bug | SPIREDOC-7123 | Fixes the issue that the password was lost after loading and saving a password-protected Word document. |
Bug | SPIREDOC-7524 | Fixes the issue that caused incorrect number list after converting Word to HTML. |
Bug | SPIREDOC-7620 SPIREDOC-7628 SPIREDOC-7732 SPIREDOC-7736 SPIREDOC-7737 SPIREDOC-7750 SPIREDOC-7751 SPIREDOC-7752 SPIREDOC-7907 SPIREDOC-8005 SPIREDOC-8009 SPIREDOC-8060 SPIREDOC-8062 |
Fixes the issue that caused incorrect pagination after converting Word to PDF. |
Bug | SPIREDOC-7658 SPIREDOC-8043 |
Fixes the issue that caused incorrect text wrapping after converting Word to PDF. |
Bug | SPIREDOC-7713 SPIREDOC-7741 SPIREDOC-7831 SPIREDOC-7999 |
Fixes the issue that the contents were overlapped after converting Word to PDF. |
Bug | SPIREDOC-7739 | Fixes the issue that the location of line was incorrect after converting Word to PDF. |
Bug | SPIREDOC-7748 | Fixes the issue that the location of number was incorrect after converting Word to PDF. |
Bug | SPIREDOC-7758 | Fixes the issue that caused incorrect content format after converting Word to PDF. |
Bug | SPIREDOC-7820 | Fixes the issue that the table text was not centered after converting Word to PDF. |
Bug | SPIREDOC-7851 | Fixes the issue that setting the docPicture.setWidthScale and docPicture.setHeightScale properties didn't take effect. |
Bug | SPIREDOC-7913 | Fixes the issue that caused incomplete content and blurry table after converting Word to PDF. |
Bug | SPIREDOC-7912 | Fixes the issue that caused incorrect table format after converting HTML to image. |
Bug | SPIREDOC-7914 SPIREDOC-7926 SPIREDOC-7932 SPIREDOC-7942 |
Fixes the issue that the decimal point was covered after converting Word to PDF. |
Bug | SPIREDOC-7955 | Fixes the issue that the content was blank after converting Word to PDF. |
Bug | SPIREDOC-7966 | Fixes the issue that the date repeated after converting Word to PDF. |
Bug | SPIREDOC-7981 | Fixes the issue that the border of table was lost after converting Word to PDF. |
Bug | SPIREDOC-8011 | Fixes the issue that the content was blank after adding LatexMathCode. |
Bug | SPIREDOC-8012 | Fixes the issue that caused incorrect content after adding LatexMathCode. |
Bug | SPIREDOC-8039 | Fixes the issue that caused incorrect order of cell content after converting Word to PDF. |
Bug | SPIREDOC-8040 | Fixes the issue that caused incorrect wrapping of cell content after converting Word to PDF. |
Bug | SPIREDOC-8065 | Fixes the issue that the table contents were messed up after converting Word to PDF. |
Bug | SPIREDOC-8078 | Fixes the issue that the application threw the "IndexOutOfBoundException" when removing table cell. |
Bug | SPIREDOC-8087 | Fixes the issue that caused incorrect text wrapping after converting Word to PDF. |
Bug | SPIREDOC-8093 | Fixes the issue that the application threw the "Unknow char: \" when appending HTML to Word. |
Bug | SPIREDOC-8104 | Fixes the issue that the text was garbled after converting Word PDF with new engine. |
Bug | SPIREDOC-8155 | Fixes the issue that the application threw the Unknown char: ' when loading Word document. |
Bug | SPIREDOC-8172 | Fixes the issue that caused incorrect data of field after converting Word to PDF. |
Bug | SPIREDOC-8201 | Fixes the issue that the decimal point was lost after converting Word to PDF. |
C#/VB.NET: Convert ODP to PDF
An ODP file is an OpenDocument Presentation file consisting of slides containing images, text, media, and transition effects. Since ODP files can only be opened by specified programs such as OpenOffice Impress, LibreOffice Impress, and Microsoft PowerPoint, if you want your ODP files to be viewable on more devices, you can convert them to PDF. In this article, you will learn how to programmatically convert a ODP file to PDF using Spire.Presentation for .NET.
Install Spire.Presentation for .NET
To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.
PM> Install-Package Spire.Presentation
Convert OpenDocument Presentation to PDF
The detailed steps are as follows:
- Create a Presentation instance.
- Load an ODP file using Presentation.LoadFromFile() method.
- Save the ODP file to PDF using Presentation.SaveToFile(String, FileFormat) method.
- C#
- VB.NET
using Spire.Presentation; namespace ODPtoPDF { class Program { static void Main(string[] args) { //Create a Presentation instance Presentation presentation = new Presentation(); //Load an ODP file presentation.LoadFromFile("Sample.odp", FileFormat.ODP); //Convert the ODP file to PDF presentation.SaveToFile("OdptoPDF.pdf", FileFormat.PDF); } } }
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.
Spire.PDF 8.7.9 support creating tagged PDF files
We are glad to announce the release of Spire.PDF 8.7.9. This version support creating tagged PDF files and PDF/UA files. It also enhances the conversion from PDF to SVG. Additionally, it fixes some known issues such as the application threw "System.NotSupportedException" when signing a PDF document with a timestamp server. More details are listed below.
Here is a list of changes made in this release
Category | ID | Description |
New feature | SPIREPDF-3803 |
Support creating tagged PDF files. //Note:At present, in order to ensure the validity of the output tagged PDF file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark. //Spire.License.LicenseProvider.SetLicenseKey("valid license key"); //Create a pdf document PdfDocument doc = new PdfDocument(); //Add page doc.Pages.Add(); //Set tab order doc.Pages[0].SetTabOrder(TabOrder.Structure); //Create PdfTaggedContent PdfTaggedContent taggedContent = new PdfTaggedContent(doc); taggedContent.SetLanguage("en-US"); taggedContent.SetTitle("test"); //Set font PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 10), true); PdfSolidBrush brush = new PdfSolidBrush(Color.Black); //Append elements PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document); PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span); span1.BeginMarkedContent(doc.Pages[0]); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET is a professional PDF API applied to creating, writing, editing, handling and reading PDF files.", font, brush, new Rectangle(40, 0, 480, 80), format); span1.EndMarkedContent(doc.Pages[0]); PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); paragraph2.BeginMarkedContent(doc.Pages[0]); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET can be applied to easily convert Text, Image, SVG, HTML to PDF and convert PDF to Excel with C#/VB.NET in high quality.", font, brush, new Rectangle(40, 80, 480, 60), format); paragraph2.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure1.Alt = "replacement text1"; figure1.BeginMarkedContent(doc.Pages[0], null); PdfImage image = PdfImage.FromFile(@"E-logo.png"); doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100)); figure1.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure2.Alt = "replacement text2"; figure2.BeginMarkedContent(doc.Pages[0], null); doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100)); figure2.EndMarkedContent(doc.Pages[0]); //Save to file String result = "CreateTaggedFile_result.pdf"; doc.SaveToFile(result); doc.Close(); |
New feature | SPIREPDF-4559 | Support creating PDF/UA files.
//Note:At present, in order to ensure the validity of the output PDF/UA file, it is necessary to add the valid license of Spire.PDF for .net to remove the red warning watermark. //Spire.License.LicenseProvider.SetLicenseKey("valid license key"); //Create a pdf document PdfDocument doc = new PdfDocument(); //Add page doc.Pages.Add(); //Set tab order doc.Pages[0].SetTabOrder(TabOrder.Structure); //Create PdfTaggedContent PdfTaggedContent taggedContent = new PdfTaggedContent(doc); taggedContent.SetLanguage("en-US"); taggedContent.SetTitle("test"); //Set PDF/UA1 identification taggedContent.SetPdfUA1Identification(); //Set font PdfTrueTypeFont font = new PdfTrueTypeFont(new System.Drawing.Font("Times New Roman", 10), true); PdfSolidBrush brush = new PdfSolidBrush(Color.Black); //Append elements PdfStructureElement article = taggedContent.StructureTreeRoot.AppendChildElement(PdfStandardStructTypes.Document); PdfStructureElement paragraph1 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); PdfStructureElement span1 = paragraph1.AppendChildElement(PdfStandardStructTypes.Span); span1.BeginMarkedContent(doc.Pages[0]); PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Justify); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET is a professional PDF API applied to creating, writing, editing, handling and reading PDF files.", font, brush, new Rectangle(40, 0, 480, 80), format); span1.EndMarkedContent(doc.Pages[0]); PdfStructureElement paragraph2 = article.AppendChildElement(PdfStandardStructTypes.Paragraph); paragraph2.BeginMarkedContent(doc.Pages[0]); doc.Pages[0].Canvas.DrawString("Spire.PDF for .NET can be applied to easily convert Text, Image, SVG, HTML to PDF and convert PDF to Excel with C#/VB.NET in high quality.", font, brush, new Rectangle(40, 80, 480, 60), format); paragraph2.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure1 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure1.Alt = "replacement text1"; figure1.BeginMarkedContent(doc.Pages[0], null); PdfImage image = PdfImage.FromFile(@"E-logo.png"); doc.Pages[0].Canvas.DrawImage(image, new PointF(40, 200), new SizeF(100, 100)); figure1.EndMarkedContent(doc.Pages[0]); PdfStructureElement figure2 = article.AppendChildElement(PdfStandardStructTypes.Figure); //Set Alternate text figure2.Alt = "replacement text2"; figure2.BeginMarkedContent(doc.Pages[0], null); doc.Pages[0].Canvas.DrawRectangle(PdfPens.Black, new Rectangle(300, 200, 100, 100)); figure2.EndMarkedContent(doc.Pages[0]); //Save to file String result = "CreatePDFUAFile_result.pdf"; doc.SaveToFile(result); doc.Close(); |
Bug | SPIREPDF-4227 | Fixes the issue that the application threw "System.NotSupportedException" when signing a PDF document with a timestamp server. |
Bug | SPIREPDF-4596 | Fixes the issue that the content format was incorrect after converting PDF to excel file. |
Bug | SPIREPDF-5214 | Fixes the issue that the application threw "System.NullReferenceException" when converting PDF to SVG. |
Bug | SPIREPDF-5247 | Fixes the issue that the stamp content format was incorrect after printing PDF file. |
Bug | SPIREPDF-5266 | Optimizes the time consumption issue when finding PDF file text. |
Bug | SPIREPDF-5277 | Fixes the issue that the ReplaceAllText() function didn't take effect. |
Bug | SPIREPDF-5292 | Optimizes the DrawString() method to draw Html string. |
Bug | SPIREPDF-5314 | Fixes the issue that the RemoveCustomProperty() function effect was incorrect. |
Bug | SPIREPDF-5317 | Fixes the issue that the application threw "System.OutOfMemoryException" when compressing PDF images. |
Bug | SPIREPDF-5318 | Fixes the issue that the output PDF couldn't be opened after converting from a u3d file. |
Bug | SPIREPDF-5319 | Fixes the issue that the size of the extracted images was incorrect. |
Bug | SPIREPDF-5330 | Fixes the issue that the QR code of the PDF file was incorrect after converting PDF to image. |
Bug | SPIREPDF-5331 | Fixes the issue that the application threw "System.NullReferenceException" when extracting text from a PDF/A file. |
Bug | SPIREPDF-5333 | Fixes the issue that it wasn't able to find text from a PDF file. |
Bug | SPIREPDF-5336 | Fixes the issue that the application threw "Invalid year in date string" after loading and then directly saving a PDF file. |
Bug | SPIREPDF-5351 | Fixes the issue that the content lost after printing a PDF file. |
Bug | SPIREPDF-5305 | Fixes the issue that the application threw "System.IndexOutOfRangeException" when merging PDF files. |
Spire.Presentation for Java 7.7.3 supports deleting macros from PPTM files
We are glad to announce the release of Spire.Presentation for Java 7.7.3. This version supports converting all slides from a PowerPoint document to an SVG file and deleting macros from PPTM files. Besides, it also provides the method isSlideSizeAutoFit() to fit content to the slide size when cloning slides. Moreover, some known issues are fixed, such as the issue that the application threw exception “Java heap space" when converting PowerPoint to images. More details are listed below.
Here is a list of changes made in this release
Category | ID | Description |
New feature | SPIREPPT-1983 | Supports deleting macros from PPTM files. |
New feature | SPIREPPT-1995 | Provides the method isSlideSizeAutoFit() to fit content to the slide size when cloning slides. Note: currently only 4:3->16:9 is supported.
Presentation presentation1 =new Presentation(); presentation1.loadFromFile(inputFile_1); Presentation presentation2 =new Presentation(); presentation2.loadFromFile(inputFile_2); presentation1.isSlideSizeAutoFit(true); ILayout layout = presentation1.getSlides().get(0).getLayout(); presentation1.getSlides().append(presentation2.getSlides().get(0),layout); presentation1.saveToFile(outputFile, FileFormat.PPTX_2013); |
New feature | SPIREPPT-1996 | Supports converting all slides from a PowerPoint document to an SVG file.
byte[] bytes=ppt.saveToOneSVG(); try(java.io.FileOutputStream stream = new java.io.FileOutputStream(outputFile)){ stream.write(bytes); } |
Bug | SPIREPPT-1982 | Fixes the issue that the application threw exceptions "NullPointerException" and “Unsupported Image Type” when converting PPT to images. |
Bug | SPIREPPT-1990 | Fixes the issue that the size of text font was reduced after splitting the PowerPoint document according to the slides. |
Bug | SPIREPPT-1991 | Fixes the issue that when setShowLoop(true) method has been set to loop the slideshow, the Microsoft PowerPoint would stop after playing the first slide. |
Bug | SPIREPPT-1994 | Optimizes the speed of loading PowerPoint files. |
Bug | SPIREPPT-2000 | Adjusts the names of slide.SaveToFile(), SaveToSVG() methods to saveToFile() and saveToSVG(). |
Bug | SPIREPPT-2004 | Fixes the issue that the application threw exception “Java heap space" when converting PowerPoint to images. |
Java: Change PDF Page Size
In some circumstances, you may need to change the page size of a PDF. For example, if you have a combined PDF file with pages of different sizes, you may want to resize the pages to the same size for easier reading and printing. In this article, we will introduce how to change the page size of a PDF file in Java using Spire.PDF for Java.
Install Spire.PDF for Java
First of all, you're required to add the Spire.Pdf.jar file as a dependency in your Java program. The JAR file can be downloaded from this link. If you use Maven, you can easily import the JAR file in your application by adding the following code to your project's pom.xml file.
<repositories> <repository> <id>com.e-iceblue</id> <name>e-iceblue</name> <url>https://repo.e-iceblue.com/nexus/content/groups/public/</url> </repository> </repositories> <dependencies> <dependency> <groupId>e-iceblue</groupId> <artifactId>spire.pdf</artifactId> <version>8.7.0</version> </dependency> </dependencies>
Change PDF Page Size to a Standard Paper Size in Java
The way to change the page size of a PDF file is to create a new PDF file and add pages of the desired size to it, next, create templates from the pages in the original PDF file, then draw the templates onto the pages in the new PDF file. This process will preserve text, images, and other elements present in the original PDF.
Spire.PDF for Java supports a variety of standard paper sizes like letter, legal, A0, A1, A2, A3, A4, B0, B1, B2, B3, B4 and many more. The following steps show you how to change the page size of a PDF file to a standard paper size.
- Initialize a PdfDocument instance and load the original PDF file using PdfDocument.loadFromFile() method.
- Initialize another PdfDocument instance to create a new PDF file.
- Loop through the pages in the original PDF.
- Add pages of the desired size to the new PDF file using PdfDocument.getPages().add() method.
- Initialize a PdfTextLayout instance and set the text layout as one page using PdfTextLayout.setLayout() method.
- Create templates based on the pages in the original PDF using PdfPageBase.createTemplate() method.
- Draw the templates onto the pages in the new PDF file with the specified text layout using PdfTemplate.draw() method.
- Save the result file using PdfDocument.saveToFile() method.
- Java
import com.spire.pdf.PdfDocument; import com.spire.pdf.PdfPageBase; import com.spire.pdf.PdfPageSize; import com.spire.pdf.graphics.*; import java.awt.geom.Point2D; public class ChangePageSizeToStandardPaperSize { public static void main(String []args){ //Load the original PDF document PdfDocument originPdf = new PdfDocument(); originPdf.loadFromFile("Sample.pdf"); //Create a new PDF document PdfDocument newPdf = new PdfDocument(); //Loop through the pages in the original PDF for(int i = 0; i< originPdf.getPages().getCount(); i++) { //Add pages of size A1 to the new PDF PdfPageBase newPage = newPdf.getPages().add(PdfPageSize.A1, new PdfMargins((0))); //Create a PdfTextLayout instance PdfTextLayout layout = new PdfTextLayout(); //Set text layout as one page (if not set the content will not scale to fit page size) layout.setLayout(PdfLayoutType.One_Page); //Create templates based on the pages in the original PDF PdfTemplate template = originPdf.getPages().get(i).createTemplate(); //Draw templates onto the pages in the new PDF template.draw(newPage, new Point2D.Float(0,0), layout); } //Save the result document newPdf.saveToFile("ChangePageSizeToA1.pdf"); } }
Change PDF Page Size to a Custom Paper Size in Java
Spire.PDF for Java uses point (1/72 of an inch) as the unit of measure. If you want to change the page size of a PDF to a custom paper size in other units of measure like inches or millimeters, you can use the PdfUnitConvertor class to convert them to points.
The following steps show you how to change the page size of a PDF file to a custom paper size in inches:
- Initialize a PdfDocument instance and load the original PDF file using PdfDocument.loadFromFile() method.
- Initialize another PdfDocument instance to create a new PDF file.
- Initialize a PdfUnitConvertor instance, then convert the custom size in inches to points using PdfUnitConvertor.convertUnits() method.
- Initialize a Dimension2D instance from the custom size.
- Loop through the pages in the original PDF.
- Add pages of the custom size to the new PDF file using PdfDocument.getPages().add() method.
- Create a PdfTextLayout instance and set the text layout as one page using PdfTextLayout.setLayout() method.
- Create templates based on the pages in the original PDF using PdfPageBase.createTemplate() method.
- Draw the templates onto the pages in the new PDF file with the specified text layout using PdfTemplate.draw() method.
- Save the result file using PdfDocument.saveToFile() method.
- Java
import com.spire.pdf.PdfDocument; import com.spire.pdf.PdfPageBase; import com.spire.pdf.graphics.*; import java.awt.*; import java.awt.geom.Dimension2D; import java.awt.geom.Point2D; public class ChangePageSizeToCustomPaperSize { public static void main(String []args){ //Load the original PDF document PdfDocument originPdf = new PdfDocument(); originPdf.loadFromFile("Sample.pdf"); //Create a new PDF document PdfDocument newPdf = new PdfDocument(); //Create a PdfUnitConvertor instance PdfUnitConvertor unitCvtr = new PdfUnitConvertor(); //Convert the custom size in inches to points float width = unitCvtr.convertUnits(6.5f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point); float height = unitCvtr.convertUnits(8.5f, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point); //Create a Dimension2D instance from the custom size, then it will be used as the page size of the new PDF Dimension2D size = new Dimension(); size.setSize(width, height); //Loop through the pages in the original PDF for(int i = 0; i< originPdf.getPages().getCount(); i++) { //Add pages of the custom size (6.5*8.5 inches) to the new PDF PdfPageBase newPage = newPdf.getPages().add(size, new PdfMargins((0))); //Create a PdfTextLayout instance PdfTextLayout layout = new PdfTextLayout(); //Set text layout as one page (if not set the content will not scale to fit page size) layout.setLayout(PdfLayoutType.One_Page); //Create templates based on the pages in the original PDF PdfTemplate template = originPdf.getPages().get(i).createTemplate(); //Draw templates onto the pages in the new PDF template.draw(newPage, new Point2D.Float(0,0), layout); } //Save the result document newPdf.saveToFile("ChangePageSizeToCustomSize.pdf"); } }
Apply for a Temporary License
If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.