dongxin5210 发表于 2020-8-28 18:01:48

ActiveReport 12 PDF导出

AcitveReport12怎么导出PDF到本地

Dim p As New Export.Pdf.Section.PdfExport()
            'GrapeCity.ActiveReports.Export.Pdf.v12
            p.Version = Export.Pdf.Section.PdfVersion.Pdf17

            'Set default print settings using PrintPresets class
            p.PrintPresets.PageScaling = Export.Pdf.Enums.PageScaling.None
            p.PrintPresets.DuplexMode = Export.Pdf.Enums.DuplexMode.DuplexFlipLongEdge
            p.PrintPresets.NumberOfCopies = Export.Pdf.Enums.NumberOfCopies.Two
            p.PrintPresets.PaperSourceByPageSize = True
            p.PrintPresets.PrintPageRange = "1-3"      
            p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf")



提示该应用程序未正确授权。

KearneyKang 发表于 2020-8-28 18:54:45

你这是服务器导出包这个错误,还是本地导出出现这个问题。导出PDF可以参考这个代码
// Provide the page report you want to render.
System.IO.FileInfo rptPath = new System.IO.FileInfo(@"..\..\PageReport1.rdlx");
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(rptPath);
// Create an output directory.
System.IO.DirectoryInfo outputDirectory = new System.IO.DirectoryInfo(@"C:\MyPDF");
outputDirectory.Create();
// Add attachment.
var pdfSetting = new GrapeCity.ActiveReports.Export.Pdf.Page.Settings();
// using GrapeCity.ActiveReports.Export.Pdf;      
pdfSetting.Attachments.Add(new AttachmentInfo
{
    Name = "file.txt",
    Content = System.IO.File.ReadAllBytes(@"D:\Reports\file.txt"),
    Description = "attachment description" // optional
});
// or
//{
//   Name = "file.xml",
//   Content = File.ReadAllBytes(Application.StartupPath + "\\file.xml")
//};
GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension pdfRenderingExtension = new GrapeCity.ActiveReports.Export.Pdf.Page.PdfRenderingExtension();
GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider outputProvider = new GrapeCity.ActiveReports.Rendering.IO.FileStreamProvider(outputDirectory, System.IO.Path.GetFileNameWithoutExtension(outputDirectory.Name));
outputProvider.OverwriteOutputFile = true;
pageReport.Document.Render(pdfRenderingExtension, outputProvider, pdfSetting);

dongxin5210 发表于 2020-8-31 13:43:08

KearneyKang 发表于 2020-8-28 18:54
你这是服务器导出包这个错误,还是本地导出出现这个问题。导出PDF可以参考这个代码

本地导出错误,代码执行到 p.Export(sectionReport.Document, Application.StartupPath + "\PrintPresets.pdf")报错,一下是错误信息:

アプリケーションにライセンスが正しく付与されていません。プロジェクトにlicenses.licxファイルが存在し、内容が正しいことを確認の上、アプリケーションをビルドし直してください。詳細については、製品ヘルプの「アプリケーションのライセンスの組み込み」を参照してください。

dongxin5210 发表于 2020-8-31 14:10:58

已解决,licenses.licx 文件缺少对PDF功能的授权信息,在licenses.licx文件添加以下代码:
GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport, GrapeCity.ActiveReports.Export.Pdf.v12

KearneyKang 发表于 2020-8-31 14:34:30

好的,问题解决了就好
页: [1]
查看完整版本: ActiveReport 12 PDF导出