Welcome Guest! To enable all features, please Login or Register.

Notification

Icon
Error

Options
View
Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, November 20, 2019 9:04:54 AM(UTC)
Abdul Rahman

Groups: Registered
Posts: 60


Hi Team,

Thanks for LeadTools. You guys are doing a great works with your SDK's. I'm planning to purchase LeadTools v20. Right now I'm experimenting with Evaluation Package. I stuck with achieving my functionality. I couldn't find any proper examples. After a long google search. I'm writing here. Please assist me.

My Use Case:

To put in simple words, I need to open any document or any print via my Virtual Printer in LeadTools HTML/JavaScript Document Viewer.

Here are the steps that I have tried.

I have installed Lead Tools V20 Virtual Printer in my Windows 10 PC. Now If I open a word document (or any document) and select File -> Print -> Selecting My Virtual Printer -> Now Click on Print Button.

Now my Virtual Printer's will capture the Print Job and Convert it to PDF and save it in a Path. Here is the Code for that.

Code:

[EmfEventMethodAttribute]
        public static void SaveStreamAsPdf(object sender, Leadtools.Printer.EmfEventArgs e)
        {
            try
            {
                ConsoleMethods.Info("EMF Event: SaveStreamAsPdf");
                // Write the EMF as file to disk.
                const string format = "pdf";
                var fileName = GetRandomFileName(format);
                string path = Path.Combine(
                   GetOutputRootPath(),
                   format + @"\",
                   fileName);
                Directory.CreateDirectory(Path.GetDirectoryName(path));

                // Create an instance of the LEADTOOLS DocumentWriter
                var docWriter = new DocumentWriter();
                docWriter.BeginDocument(path, DocumentFormat.Pdf);

                var page = new DocumentWriterEmfPage()
                {
                    EmfHandle = new Metafile(new MemoryStream(e.Stream.ToArray()))
                      .GetHenhmetafile()
                };
                docWriter.AddPage(page);
                docWriter.EndDocument();
                ConsoleMethods.Success("SaveStreamAsPdf: Complete");
                ConsoleMethods.Verbose(path);

                // Now Here I need to open this file in my HTML5/JavaScript Document Viewer
                Process.Start("http://localhost:20020/index.html?file=" + fileName);
            }
            catch (Exception ex)
            {
                ConsoleMethods.Error(ex.Message, 4000);
            }
        }


Line No 31 in above code opens my HTML5/JavaScript Document Viewer. From here I need to know how to customize LeadTools HTML5/JavaScript Document Viewer example to customize and pass the file name. I'm stuck here. LeadTools HTML5/Javascript Viewer always passes default LeadToolsDemo.Pdf url to the Document Service and it loads the default sample document. Please assist on how to achieve this so that I can demonstrate this to my BOSS and get approval for purchase.

Thanks,
Abdul Rahman
 

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Thursday, November 21, 2019 9:33:25 AM(UTC)
Matthew Bresson

Groups: Registered, Tech Support, Administrators
Posts: 98

Was thanked: 3 time(s) in 3 post(s)

Hello Abdul,

To change the default PDF document that is loaded into the HTML5/JS Document Viewer Demo you need to change line 796 of the Main.ts file
Code:

this.loadDocument("https://demo.leadtools.com/images/pdf/leadtools.pdf", null, false);


Or you can change line line 582 of the Main.js file.
Code:

_this.loadDocument("https://demo.leadtools.com/images/pdf/leadtools.pdf", null, false);


Thanks
Matt Bresson
Developer Support Engineer
LEAD Technologies, Inc.
LEADTOOLS
 
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.090 seconds.