使用C#将Xml文件转换为Pdf文件 [英] Converting Xml file to Pdf File using C#

查看:388
本文介绍了使用C#将Xml文件转换为Pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好知道如何使用C#将xml文件转换为Pdf文件。我尝试使用Aspose.pdf,但是当我使用该DLL并尝试调用类PDF时显示错误。

是否有任何其他链接或信息如何转换xml数据到C#中的Pdf文件



谢谢

Hi Like to know how to convert xml file to Pdf File using C#. I tried to work it on with Aspose.pdf but when i used that dll and tried call a class PDF it show an error.
Is there any other links or information about this how to convert an xml data to Pdf file in C#

thank You

推荐答案

现在这里是转换使用XML创建的表的示例PDF格式:

======================================= =========================



XML:

======

Now Here is Example to convert Table created Using XML into PDF:
================================================================

XML :
======
<?XML version=1.0 encoding="utf-8"?>
<column>Products</column>
 <column>Units</column>
 <column>Price</column>
<row></row></
 <column>Product 1</column>
 <column>2</column>
 <column>60</column>
<row></row>
 <column>Product 2</column>
 <column>3</column>
 <column>50</column>
<row></row>
 <column>Product 3</column>
 <column>4</column>
 <column>80</column>
<row></row>
 <column>Total</column>
 <column>9</column>
 <column>190</column>





现在c#中的等价PDF:

==========================





Now Equivalent PDF in c# :
==========================

using System;
using System.Collections.Generic;
using System.Text;
using Bytescout.PDFExtractor;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            // Create Bytescout.PDFExtractor.XMLExtractor instance
            XMLExtractor extractor = new XMLExtractor();
            extractor.RegistrationName = "demo";
            extractor.RegistrationKey = "demo";

            // Load sample PDF document
            extractor.LoadDocumentFromFile("sample3.pdf");

            extractor.SaveXMLToFile("output.XML");

            Console.WriteLine();
            Console.WriteLine("Data has been extracted to 'output.XML' file.");
            Console.WriteLine();
            Console.WriteLine("Press any key to continue and open XML in default XML viewer)...");
            Console.ReadKey();

            Process.Start("output.XML");
        }
    }
}


这篇关于使用C#将Xml文件转换为Pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆