Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GroupDocs.Viewer for Java 17.5.0
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set CAD options to get the full list of layouts
DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions();
documentInfoOptions.getCadOptions().setRenderLayouts(true);
// Get DocumentInfoContainer and iterate through pages
DocumentInfoContainer documentInfoContainer = imageHandler.getDocumentInfo(guid, documentInfoOptions);
System.out.println("Name: " + documentInfoContainer.getName());
System.out.println("Name: " + documentInfoContainer.getPages());
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
// Set pdf options to get original file without annotations
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.getPdfOptions().setDeleteAnnotations(true); // Default value is false
String guid = fileName;
// Get original Pdf document without annotations
FileContainer fileContainer = imageHandler.getPdfFile(guid, pdfFileOptions);
// Access resultant Pdf document using fileContainer.Stream property
Utilities.saveAsFile(fileName, fileContainer.getStream());
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set Cad options to render content with a specified size
ImageOptions options = new ImageOptions();
options.getCadOptions().setHeight(750);
options.getCadOptions().setWidth(450);
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
for (PageImage page : pages) {
System.out.println("Page number: " + page.getPageNumber());
InputStream imageContent = page.getStream();
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create HTML handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set words options to render content with comments
HtmlOptions options = new HtmlOptions();
options.setRenderComments(true); // Default value is false
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
System.out.println("Page number: " + page.getPageNumber());
final String htmlContent = page.getHtmlContent();
System.out.println("Html content: " + htmlContent);
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create HTML handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set PdfOptions to get Pdf file with comments
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.setRenderComments(true); // Default value is false
// Get Pdf document with comments
FileContainer container = htmlHandler.getPdfFile(guid, pdfFileOptions);
System.out.println("Name: " + container.getStream().available());
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
// Set pdf options JpegQuality in a range between 1 and 100
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.setJpegQuality(5);
String guid = fileName;
// Get file as pdf
FileContainer container = imageHandler.getPdfFile(guid, pdfFileOptions);
System.out.println("Name: " + container.getStream().available());
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set Cells options to hide overflowing text
HtmlOptions options = new HtmlOptions();
options.getCellsOptions().setTextOverflowMode(TextOverflowMode.HideText);
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
System.out.println("Page number: " + page.getPageNumber());
final String htmlContent = page.getHtmlContent();
System.out.println("Html content: " + htmlContent);
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set CAD options to render Model and all non empty Layouts
ImageOptions options = new ImageOptions();
options.getCadOptions().setRenderLayouts(true);
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
for (PageImage page : pages) {
System.out.println("Page number: " + page.getPageNumber());
InputStream imageContent = page.getStream();
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set pdf options to render content in a precise mode
HtmlOptions options = new HtmlOptions();
options.getPdfOptions().setEnablePreciseRendering(true); // Default value is false
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
System.out.println("Page number: " + page.getPageNumber());
System.out.println("Html content: " + page.getHtmlContent());
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image or html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set pdf options to render content without annotations
HtmlOptions options = new HtmlOptions();
options.getPdfOptions().setDeleteAnnotations(true); // Default value is false
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
System.out.println("Page number: " + page.getPageNumber());
System.out.println("Html content: " + page.getHtmlContent());
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image or html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set CAD options to render Model and all non empty Layouts
ImageOptions options = new ImageOptions();
options.getCadOptions().setLayoutName("MyFirstLayout");
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
for (PageImage page : pages) {
System.out.println("Page number: " + page.getPageNumber());
InputStream imageContent = page.getStream();
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create Html handler
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = fileName;
// Set Html options
HtmlOptions options = new HtmlOptions();
options.getWordsOptions().setShowTrackedChanges(true); // Default value is false
// Get pages
List<PageHtml> pages = htmlHandler.getPages(guid, options);
for (PageHtml page : pages) {
System.out.println("Page number: " + page.getPageNumber());
System.out.println("Html content: " + page.getHtmlContent());
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create Html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set Html options
ImageOptions options = new ImageOptions();
options.getWordsOptions().setShowTrackedChanges(true); // Default value is false
// Get pages
List<PageImage> pages = imageHandler.getPages(guid, options);
for (PageImage page : pages) {
System.out.println("Page number: " + page.getPageNumber());
InputStream content = page.getStream();
}
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
// For complete examples and data files, please go to https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-Java
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create Html handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;
// Set pdf options to get pdf file with tracked changes
PdfFileOptions pdfFileOptions = new PdfFileOptions();
pdfFileOptions.getWordsOptions().setShowTrackedChanges(true); // Default value is false
// Get pdf document with tracked changes
FileContainer fileContainer = imageHandler.getPdfFile(guid, pdfFileOptions);
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
exp.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.