Nested Bookmarks in PDF - html

I use the HTML to PDF converter from EVO to create a PDF document and I use the following code to generate bookmarks for H tags:
// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlToPdfConverter = new HtmlToPdfConverter();
// Select the HTML elements to bookmark by setting a list of CSS selectors
htmlToPdfConverter.PdfBookmarkOptions.HtmlElementSelectors = new string[] { "H1", "H2", "H3" };
// Display the bookmarks panel in PDF viewer when the generated PDF is opened
htmlToPdfConverter.PdfViewerPreferences.PageMode = ViewerPageMode.UseOutlines;
// Convert the HTML page to a PDF document in a memory buffer
byte[] outPdfBuffer = htmlToPdfConverter.ConvertUrl(urlTextBox.Text);
The bookmarks appear in viewer but they are all at the same level. I would like to have them organized in a tree with H1 tags at first level, H2 tags at the second level and so on. I found another software which can organize the bookmarks the way I want, but I would like to avoid using another tool just for this. I want to generate the bookmarks directly in a tree.

There are 2 methods to automatically create bookmarks in generated PDF document. One is through API and is the method you already used but that does no produce a hierarchy of bookmarks as you would like.
The other method is to set the following line in your code:
// Enable the creation of a hierarchy of bookmarks from H1 to H6 tags
htmlToPdfConverter.PdfBookmarkOptions.AutoBookmarksEnabled = true;
This will enable the creation of a tree of bookmarks based on the heading tags in your HTML.

Related

LOCAL HTML file to generate a text file

I am trying to generate a TEXT/XML file from a LOCAL HTML file. I know there are a lot of answers to generating a file locally, usually suggesting using ActiveX object or HTML 5.
I'm guessing there is a way to make it work on all browsers (in the end HTML extension is opened by a browser even if it is a LOCAL file) and easily since this is a LOCAL file put in by user himself.
My HTML file will be on client's local machine not accessed via HTTP.
It is basically just a form written in HTML that upon "SAVE" command should be generating an XML file in the local disk (anywhere user decides) and saving form's content in.
Any good way?
One way that I can think of is, the html form elements can be set into class variables and then using the jaxb context you can create an XML file out of it.
Useful Link: http://www.vogella.com/tutorials/JAXB/article.html
What you can do is use base64 data-urls (no support for IE9-) to download the file:
First you need to create a temporary iframe element for your file to download in:
var ifrm = document.createElement('iframe');
ifrm.style.display = 'none';
document.body.appendChild(ifrm);
Then you need to define what you want the contents of the file to download to be, and convert it to a base64 data-url:
var html = '<!DOCTYPE html><html><head><title>Foo</title></head><body>Hello World</body></html>';
htmlurl = btoa(html);
and set it as source for the iframe
ifrm.src = 'data:text/x-html;base64,'+htmlurl;

Assigning tags for uploaded HTML files in Concrete5

We are planning to load a number of HTML files as they are in the site using Concrete5.
We had to do this since the number of files is too big to load them via editor.
(We are going to generate the html files with madcap flare)
However, I need to use the tag feature of concrete5 for the contents loaded by this method.
I am told by my developers that this is impossible.
Does anyone know how to use tags for files loaded without going through the C5 editor?
i.e. I want the contents in the manually linked html files to be searched and filtered within the site with the search feature and filter feature provided by C5
HELP!!
I recommend creating a very simple template consisting of the standard C5 header/footer code, with one big block as the contents of the body tag.
You can then import the pages by something along the lines of (pseudo-code):
$parent = Page::getByCollectionPath('/');
$ct = CollectionType::getByHandle('template_name');
$data = array(
'cName' => 'The page title',
'cHandle' => 'The trailing path component'
);
$page = $parent->add($ct, $data);
$blocks = $page->getBlocks('Main');
// Gross hack because the template has one block, and that a 'content' block
$blocks[0]->update('content', 'IMPORTED HTML BODY CONTENT');
After that, you can add tags either via the API or the Dashboard.

Embed DWG file in HTML

I want to ask how to embed DWG file in HTML Page.
I have tried using tag with Volo Viewer but this solution run only in IE not in Firefox and Chrome.
Dwgview-x can do that, but it will need to be installed as a plug-in on client computers so that anyone can view the dwg file that you embed online.
There may be third party ActiveX controls that you could use, but I think ultimately you will find that it's not practical for drawing files of even average complexity. I recommend to create DWF (if you need vector format) or PNG files on demand (using e.g. the free DWG TrueView from http://usa.autodesk.com/design-review/ ) and embed those instead.
I use DWG Browser. Its a stand alone program that is used for reporting and categorizing drawings with previews. It saves exports in html too.
They have a free demo download available.
http://www.graytechnical.com/software/dwg-browser/
You'll find what I think is the latest information on Autodesk's labs site here: http://labs.blogs.com/its_alive_in_the_lab/2014/01/share-your-autodesk-360-designs-on-company-web-sites.html
It looks like a DWG can be embeded there is an example on this page, but clearly DWF is the way to go.
You can embed DWG file's content in an HTML page by rendering the file's pages as HTML pages or images. If you find it an attractive solution then you can do it using GroupDocs.Viewer API that allows you to render the document pages as HTML pages, images, or a PDF document as a whole. You can then include the rendered HTML/image pages or whole PDF document in your HTML page.
Using C#
ViewerConfig config = new ViewerConfig();
config.StoragePath = "D:\\storage\\";
// Create HTML handler (or ViewerImageHandler for rendering document as image)
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
// Guid implies that unique document name
string guid = "sample.dwg";
// Get document pages in html form
List<PageHtml> pages = htmlHandler.GetPages(guid);
// Or Get document pages in image form using image handler
//List<PageImage> pages = imageHandler.GetPages(guid);
foreach (PageHtml page in pages)
{
// Get HTML content of each page using page.HtmlContent
}
Using Java
// Setup GroupDocs.Viewer config
ViewerConfig config = new ViewerConfig();
// Set storage path
config.setStoragePath("D:\\storage\\");
// Create HTML handler (or ViewerImageHandler for rendering document as image)
ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);
String guid = "Sample.dwg"
// Get document pages in HTML form
List<PageHtml> pages = htmlHandler.getPages(guid);
for (PageHtml page : pages) {
// Get HTML content of each page using page.getHtmlContent
}
Disclosure: I work as a Developer Evangelist at GroupDocs.

display an (x)html document structure in a new window

For debugging purpose, I need to create an new xml document popup to display the (x)html source structure of my current document.
But the following code does not work:
var w = window.open();
w.document.open('text/xml');
w.document.write(window.document.documentElement.innerHTML);
w.document.close();
It seems that document.open() does not accept contentType anymore.
Is there any other solution ?
Just put a textarea in your existing page and copy the innerHTML into the textarea.

How to serialize browser HTML DOM to XML?

I need to serialize browser parsed HTML DOM to well-format XML.
In firefox (gecko), this works:
// serialize body to well-format XML.
var xml = new XMLSerializer().serializeToString(document.body);
But in webkit, result is equivalent to document.body.outerHTML, not well-format XML (for example: <br> won't become <br />)
How to serialize browser HTML DOM to XML in webkit?
Thanks.
I have a setInnerXHTML method (not the Facebook version) which should work for this. The method is included in the base framework file, hemi.js, available from the Hemi Project Page. It is also included in my older libXmlRequest library.
Example:
var oXml = Hemi.xml.newXmlDocument("Xhtml");
Hemi.xml.setInnerXHTML(oXml.documentElement, document.documentElement, oXml);
var sSerial = Hemi.xml.serialize(oXml);
If you want to test this on a particular browser, navigate to the Hemi Project Page, click the upper-right tool icon, and click the Active Source tab. Copy and paste the sample code into the textarea and click Eval Source (the response will be a node name). Type in sSerial into the input field and hit enter, or click Eval, and you should see the serialized XML of the copied HTML DOM.