有沒有辦法通過將許多rdlc報告合併爲一個大型的pdf在.net框架中來創建報告書。 通常我們通過Datasource生成pdf到rdlc報告,然後我們將它轉換成pdf格式。所以,雖然渲染可以合併多個rdlc生成的PDF文件? 是否有任何工具可用於合併使用SSRS生成的PDF(SQL Server Reporting Service)。合併使用SSRS和ASP.NET生成的PDF格式報告
2
A
回答
0
我已成功使用http://khsw.blogspot.com/2006/04/merge-pdf-files-using-itextsharp.html的代碼將多個現有PDF合併到單個文檔中。
0
我知道你可以將PDF與iTextSharp合併。嘗試這樣的:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
namespace Components.Pdf
{
public class PdfDocumentMerger
{
private List<string> sourceFileList;
#region constructors
public PdfDocumentMerger()
{
//initialize the source file list
sourceFileList = new List<string>();
}
public PdfDocumentMerger(params string[] fileNames) : this()
{
sourceFileList.AddRange(fileNames.AsEnumerable<string>());
}
#endregion
/// <summary>
/// Merges multiple PDF documents into one document
/// </summary>
/// <param name="DestinationFileName">The name and path to the merged document</param>
/// <returns>The name and path to the merged document, if successful. Otherwise, the return value is an empty string</returns>
public string Merge(string destinationFileName)
{
try
{
int sourceIndex = 0;
PdfReader reader = new PdfReader(sourceFileList[sourceIndex]);
int sourceFilePageCount = reader.NumberOfPages;
Document doc = new Document(reader.GetPageSizeWithRotation(1));
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(destinationFileName, FileMode.Create));
doc.Open();
PdfImportedPage page;
PdfContentByte contentByte = writer.DirectContent;
int rotation;
while (sourceIndex < sourceFileList.Count)
{
int pageIndex = 0;
while (pageIndex < sourceFilePageCount)
{
pageIndex++;
doc.SetPageSize(reader.GetPageSizeWithRotation(pageIndex));
doc.NewPage();
page = writer.GetImportedPage(reader, pageIndex);
rotation = reader.GetPageRotation(pageIndex);
if (rotation.Equals(90 | 270))
contentByte.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(pageIndex).Height);
else
contentByte.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
}
sourceIndex++;
if (sourceIndex < sourceFileList.Count)
{
reader = new PdfReader(sourceFileList[sourceIndex]);
sourceFilePageCount = reader.NumberOfPages;
}
}
doc.Close();
}
catch
{
throw;
}
return destinationFileName;
}
}
}
相關問題
- 1. 以pdf格式顯示SSRS報告
- 2. 如何使用jasper生成pdf格式的jsp報告
- 3. 生成PDF報告
- 4. PDF報告生成
- 5. 使用ReportingService2010在JAVA中生成PDF報告usisng SSRS Web服務
- 6. 使用C#程序生成SSRS報告
- 7. 使用xml生成ssrs報告
- 8. SSRS僅報告PDF
- 9. 使用Python生成報告:將PDF或HTML生成爲PDF
- 10. SSRS報告結合數據源並生成csv
- 11. 使用Sweave動態生成PDF報告
- 12. 無法使用JasperReports生成PDF報告
- 13. 使用Java生成PDF報告
- 14. 生成PDF報告:JFreeChart的和DynamicReports
- 15. SSRS報告導出爲PDF,EXCEL和MS-Word格式問題
- 16. 格式改變SSRS報告
- 17. ASP.NET合併報告
- 18. 從php生成PDF報告
- 19. Birt爲同一報告生成不同的PDF格式
- 20. SSRS PDF生成
- 21. 使用ASP.NET AJAX動態生成報告
- 22. 使用圖表生成報告並將其保存爲pdf
- 23. 如何在2016 SSRS報告服務器上生成報告並將其上傳到2014 SSRS報告服務器?
- 24. 從C#對象生成SSRS報告
- 25. 在內存中生成SSRS報告
- 26. SSRS矩陣表報告。合併行
- 27. 帶日期格式的SSRS報告
- 28. 如何使用Coverage.py生成合並報告時保留單個報告
- 29. 如何生成報告的GridView爲PDF
- 30. 導出帶有Jump的SSRS報告以Excel格式報告?
以上要求PDF是物理存在和合並。如果我們使用將本地報告呈現爲pdf的字節流合併並且呈現爲pdf,這將成爲可能 – zain
這是使用字節數組的一種選擇嗎? http://pastebin.com/qbw95cad –