Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Tuesday, March 27, 2012

Combining reports into a single PDF

My company has spent the last few months developing a set of complex
financial reports using RS. The goal has always been to package them
into a single PDF, with different users receiving customized versions
of each report (eg, everyone in NY gets #s for the NY office).
We've just learned that if we combine the reports as subreports, we
lose the page headers and footers, and landscape and portrait reports
cannot be combined.
But we still have to deliver the package somehow. Does anyone have an
recommendations? We're looking at:
-Putting the page footers and headers in the report body some way.
-Writing an app to automate Adobe distiller and build the packages
ourselves (but we lose the RS delivery functionality)
-Leaving the reports as separate PDFs, and writing an app that will
print them all, creating the appearance of a single package at least
when printed.
Thanks,
BurtBurt
I had a similar problem but I could not resolve it via RS. Here is how I
solved it.
In my c# app I use the Render method for each report and save off its byte
array that is returns into a member variable pdfStream. When the report
generation was complete I then created a pdf with the byte array. Somethign
like this:
// Render Method
private byte[] m_bytResult;
m_bytResult = oRpts.Render(m_sName, GetReportFormat(false), showHideToggle,
m_sDevice, m_oParms, credentials, showHideToggle, out encoding, out mimeType,
out reportHistoryParameters, out warnings, out streamIDs);
// Generate Single PDF From Results of RS Render
string sOut = "myNewReports.pdf";
FileStream stream = File.Create( sOut, bytResult.Length );
stream.Write( bytResult, 0, bytResult.Length );
stream.close;
I hope this helps some.
Tom
"Burt" wrote:
> My company has spent the last few months developing a set of complex
> financial reports using RS. The goal has always been to package them
> into a single PDF, with different users receiving customized versions
> of each report (eg, everyone in NY gets #s for the NY office).
> We've just learned that if we combine the reports as subreports, we
> lose the page headers and footers, and landscape and portrait reports
> cannot be combined.
> But we still have to deliver the package somehow. Does anyone have an
> recommendations? We're looking at:
> -Putting the page footers and headers in the report body some way.
> -Writing an app to automate Adobe distiller and build the packages
> ourselves (but we lose the RS delivery functionality)
> -Leaving the reports as separate PDFs, and writing an app that will
> print them all, creating the appearance of a single package at least
> when printed.
> Thanks,
> Burt
>|||Thanks, Tom.
Looks like I'm going to have to resort to this- write all combinations
of the customized reports to a file structure, combine them per below,
then write a process to email them. Ug.
Burt
Tom Walls <TomWalls@.discussions.microsoft.com> wrote in message news:<E674D836-A609-4FC2-8B4C-46222FC11C1D@.microsoft.com>...
> Burt
> I had a similar problem but I could not resolve it via RS. Here is how I
> solved it.
> In my c# app I use the Render method for each report and save off its byte
> array that is returns into a member variable pdfStream. When the report
> generation was complete I then created a pdf with the byte array. Somethign
> like this:
> // Render Method
> private byte[] m_bytResult;
> m_bytResult = oRpts.Render(m_sName, GetReportFormat(false), showHideToggle,
> m_sDevice, m_oParms, credentials, showHideToggle, out encoding, out mimeType,
> out reportHistoryParameters, out warnings, out streamIDs);
> // Generate Single PDF From Results of RS Render
> string sOut = "myNewReports.pdf";
> FileStream stream = File.Create( sOut, bytResult.Length );
> stream.Write( bytResult, 0, bytResult.Length );
> stream.close;
>
> I hope this helps some.
> Tom
> "Burt" wrote:
> > My company has spent the last few months developing a set of complex
> > financial reports using RS. The goal has always been to package them
> > into a single PDF, with different users receiving customized versions
> > of each report (eg, everyone in NY gets #s for the NY office).
> >
> > We've just learned that if we combine the reports as subreports, we
> > lose the page headers and footers, and landscape and portrait reports
> > cannot be combined.
> >
> > But we still have to deliver the package somehow. Does anyone have an
> > recommendations? We're looking at:
> >
> > -Putting the page footers and headers in the report body some way.
> > -Writing an app to automate Adobe distiller and build the packages
> > ourselves (but we lose the RS delivery functionality)
> > -Leaving the reports as separate PDFs, and writing an app that will
> > print them all, creating the appearance of a single package at least
> > when printed.
> >
> > Thanks,
> >
> > Burt
> >|||Did anyone come up with a better way to do this? Seems like something a lot
of people would want to do, if you actually want to be able to log in to
Reports Manager and get a nice clean report every so often (with cover page,
TOC, et al). Otherwise it means RS is really only good for us IT guys. Anyone
from MSFT know if this kind of feature is on the horizon?
"Burt" wrote:
> Thanks, Tom.
> Looks like I'm going to have to resort to this- write all combinations
> of the customized reports to a file structure, combine them per below,
> then write a process to email them. Ug.
> Burt
>
> Tom Walls <TomWalls@.discussions.microsoft.com> wrote in message news:<E674D836-A609-4FC2-8B4C-46222FC11C1D@.microsoft.com>...
> > Burt
> >
> > I had a similar problem but I could not resolve it via RS. Here is how I
> > solved it.
> >
> > In my c# app I use the Render method for each report and save off its byte
> > array that is returns into a member variable pdfStream. When the report
> > generation was complete I then created a pdf with the byte array. Somethign
> > like this:
> >
> > // Render Method
> > private byte[] m_bytResult;
> >
> > m_bytResult = oRpts.Render(m_sName, GetReportFormat(false), showHideToggle,
> > m_sDevice, m_oParms, credentials, showHideToggle, out encoding, out mimeType,
> > out reportHistoryParameters, out warnings, out streamIDs);
> >
> > // Generate Single PDF From Results of RS Render
> > string sOut = "myNewReports.pdf";
> > FileStream stream = File.Create( sOut, bytResult.Length );
> > stream.Write( bytResult, 0, bytResult.Length );
> > stream.close;
> >
> >
> > I hope this helps some.
> >
> > Tom
> >
> > "Burt" wrote:
> >
> > > My company has spent the last few months developing a set of complex
> > > financial reports using RS. The goal has always been to package them
> > > into a single PDF, with different users receiving customized versions
> > > of each report (eg, everyone in NY gets #s for the NY office).
> > >
> > > We've just learned that if we combine the reports as subreports, we
> > > lose the page headers and footers, and landscape and portrait reports
> > > cannot be combined.
> > >
> > > But we still have to deliver the package somehow. Does anyone have an
> > > recommendations? We're looking at:
> > >
> > > -Putting the page footers and headers in the report body some way.
> > > -Writing an app to automate Adobe distiller and build the packages
> > > ourselves (but we lose the RS delivery functionality)
> > > -Leaving the reports as separate PDFs, and writing an app that will
> > > print them all, creating the appearance of a single package at least
> > > when printed.
> > >
> > > Thanks,
> > >
> > > Burt
> > >
>

Combining Output PDF files

Is there a way to output reports to the same PDF file. Basicly Appending several reports to the one PDF.

Without combining the reports using subreports, I think you would use code & custom PDF components, unless you want to jump into writing a rendering extension.

Softartisians Officewriter & abcPDF.NET are two possible options. You can also try automating Acrobat.

http://www.planetpdf.com/forumarchive/84747.asp

One alternative may be to export to a different format and then convert to pdf afterwards.

cheers,

Andrew

|||

we're trying to do this on the report server with out having to add another process.

Is there any good tutorials for writing a rendering extension? I've heard its difficult.

|||

Not sure if it has changed since RS 2000, but here is a comment on how difficult...

http://blogs.msdn.com/bryanke/archive/2004/03/16/90797.aspx

If you want to develop one, it might help to travel to Microsoft's main campus and stay for a month or two while you work alongside Reporting Services developers.

cheers,

Andrew

|||

LOL, Yeah I saw that, showed it to my boss. He said no to funding that trip..Oh well...LOL

Doubt they would let me in anyways

But hey if Microsoft wants to use me as a test case, I'm all for it!!! {WINK WINK, NUDGE NUDGE}

sqlsql

Combining multiple subreports into a single report

The goal is to produce a single PDF consisting of a number of subreports. Some are landscape, others are portrait. The subreports may also be run as independent reports. The master report that contains them defaults to the width of the widest subreport, which is landscape. This causes all portrait subreports to spill over producing blank pages. Are there any work-arounds to concatenate multiple, single report PDFs into a single PDF and have page numbering too?


Thanks!

Have you tried reducing the body width to landscape? We had a similar requrement which we implemented with linked reports pointing to standalone reports and I don't recall having extra blank pages with mixed layouts.|||

I did check the landscape width for the reports both individualy and in the master report. They all render fine independently. I also tested the report rendering as I added each subreport to the master report. The moment I added the Landscape one, all portrait reports (that rendered fine before) spilled over onto subsequent pages. The subreports are embedded in a main report and not linked. Can you tell me more about how you configured your reports to be linked?

Thanks!

|||

I appologize I meant reducing the body width to portrait regardless of the fact that you have reports set to landscape. I believe at runtime the report server will expand the body width as needed.

A linked report is essentially a smart pointer to the actual report. You can create a linked reportin in the Report Manager. Go to the report properties and click on the Create Linked Report button. The advantage of having this point of indirection is that if the standalone report is moved, the linked report will automatically be redirected to the new location. Also, a linked report can have its own security policies, etc.

|||

Hi,

I was able to find information at this link:

http://msdn2.microsoft.com/en-us/library/ms155993.aspx

"Reporting Services does not provide a way to combine landscape and portrait mode pages in the same report, nor does it provide a way to create a print-based layout that replaces or exists alongside the layout of a report as rendered in a browser or other application. For most exported reports, report printouts include everything that is visible on the report, as viewed by the user on a computer monitor."

Not what I wanted to hear. Also, I was unable to find the Linked Reports option within Report Designer Report Properties. We are using Visual Studio 2005. Someone on the team provided these links for combining PDFs. This seems like a lot of work to go thru because of a missing feature. Even Word allows you to insert section breaks where you can specigy Landscapre or Portrait.

http://www.codeproject.com/cs/library/giospdfnetlibrary.asp

https://secure.codeproject.com/csharp/giospdfsplittermerger.asp

|||

Yes, this is correct. I appologize for giving you wrong information. Upon looking at our report package implementation, the master report width is set to Landscape. The Create Linked Report button is on the report properties (General Tab) assuming you use the Report Manager and have rights to create linked reports.

|||

Hi,

The mechanism that we've used to achieve this is to write some code using a PDF library to combine the reports. It goes off and renders the reports and then adds them to a master document. That way we can add page numbers, table of contents etc. and its all dynamic.

Sanjay

|||

Hi, and thanks.

That is what we ended up doing and I am posting the code for the benefit of others. We used PDFSharp (there are several others) and I modified one of their samples into the class below. It worked good and we ended up with one report that could have both landscape and portrait pages and page numbers.

#region PDFsharp - A .NET library for processing PDF

//

// Copyright (c) 2005-2006 empira Software GmbH, Cologne (Germany)

//

// http://www.pdfsharp.com

//

// http://sourceforge.net/projects/pdfsharp

//

// Permission is hereby granted, free of charge, to any person obtaining a copy

// of this software and associated documentation files (the "Software"), to deal

// in the Software without restriction, including without limitation the rights

// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

// copies of the Software, and to permit persons to whom the Software is

// furnished to do so, subject to the following conditions:

//

// The above copyright notice and this permission notice shall be included in

// all copies or substantial portions of the Software.

//

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.

// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,

// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR

// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE

// USE OR OTHER DEALINGS IN THE SOFTWARE.

#endregion

using System;

using System.Diagnostics;

using System.IO;

using PdfSharp;

using PdfSharp.Pdf;

using PdfSharp.Pdf.IO;

using PdfSharp.Drawing;

namespace successionManagement

{

public class CombinePdfs

{

public static PdfDocument combine(Stream[] streams, String fileName)

{

PdfDocument outputDocument = new PdfDocument();

XFont font = new XFont("arial", 8, XFontStyle.Regular);

XStringFormat format = new XStringFormat();

format.Alignment = XStringAlignment.Center;

format.LineAlignment = XLineAlignment.Far;

XGraphics gfx;

XRect box;

int totalPages = 0;

int currentPage = 0;

PdfDocument[] pdfDocuments = new PdfDocument[streams.Length];

for (int i = 0; i < streams.Length; i++)

{

Stream stream = (Stream) streamsIdea;

PdfDocument inputDocument = PdfReader.Open(stream, PdfDocumentOpenMode.Import);

totalPages = totalPages + inputDocument.PageCount;

pdfDocumentsIdea = inputDocument;

}

String pageNbrFooter;

for (int i=0; i < pdfDocuments.Length; i++)

{

PdfDocument inputDocument = (PdfDocument) pdfDocumentsIdea;

for (int idx = 0; idx < inputDocument.PageCount; idx++)

{

PdfPage page = inputDocument.Pages[idx];

currentPage = currentPage + 1;

pageNbrFooter = "Page " + currentPage + " of " + totalPages;

page = outputDocument.AddPage(page);

//Write document file name and page number on each page

gfx = XGraphics.FromPdfPage(page);

box = page.MediaBox.ToXRect();

box.Inflate(20, -10);

gfx.DrawString(String.Format( pageNbrFooter,0 ),

font, XBrushes.Black, box, format);

}

}

outputDocument.Save(fileName);

return outputDocument;

}

}

}

To invoke the class you would supply your stream in place of the pdf and the relative path. Here is a simple hard-coded path example.

Stream[] streams = new Stream[5];

streams[0] = new FileStream(@."c:/Lynette/portrait1.pdf", FileMode.Open);

streams[1] = new FileStream(@."c:/Lynette/portrait2.pdf", FileMode.Open);

streams[2] = new FileStream(@."c:/Lynette/portrait3.pdf", FileMode.Open);

streams[3] = new FileStream(@."c:/Lynette/landscape1.pdf", FileMode.Open);

streams[4] = new FileStream(@."c:/Lynette/portrait4.pdf", FileMode.Open);

PdfDocument combinedPdf = CombinePdfs.combine(streams,"c:/Lynette/myCombined.pdf");

|||

The code sample above should have a subscript in brackets but I guess that is also the symbol for an idea. How funny!

|||

Great solution to this issue. Thank you for posting the code!

Combining multiple subreports into a single report

The goal is to produce a single PDF consisting of a number of subreports. Some are landscape, others are portrait. The subreports may also be run as independent reports. The master report that contains them defaults to the width of the widest subreport, which is landscape. This causes all portrait subreports to spill over producing blank pages. Are there any work-arounds to concatenate multiple, single report PDFs into a single PDF and have page numbering too?


Thanks!

Have you tried reducing the body width to landscape? We had a similar requrement which we implemented with linked reports pointing to standalone reports and I don't recall having extra blank pages with mixed layouts.|||

I did check the landscape width for the reports both individualy and in the master report. They all render fine independently. I also tested the report rendering as I added each subreport to the master report. The moment I added the Landscape one, all portrait reports (that rendered fine before) spilled over onto subsequent pages. The subreports are embedded in a main report and not linked. Can you tell me more about how you configured your reports to be linked?

Thanks!

|||

I appologize I meant reducing the body width to portrait regardless of the fact that you have reports set to landscape. I believe at runtime the report server will expand the body width as needed.

A linked report is essentially a smart pointer to the actual report. You can create a linked reportin in the Report Manager. Go to the report properties and click on the Create Linked Report button. The advantage of having this point of indirection is that if the standalone report is moved, the linked report will automatically be redirected to the new location. Also, a linked report can have its own security policies, etc.

|||

Hi,

I was able to find information at this link:

http://msdn2.microsoft.com/en-us/library/ms155993.aspx

"Reporting Services does not provide a way to combine landscape and portrait mode pages in the same report, nor does it provide a way to create a print-based layout that replaces or exists alongside the layout of a report as rendered in a browser or other application. For most exported reports, report printouts include everything that is visible on the report, as viewed by the user on a computer monitor."

Not what I wanted to hear. Also, I was unable to find the Linked Reports option within Report Designer Report Properties. We are using Visual Studio 2005. Someone on the team provided these links for combining PDFs. This seems like a lot of work to go thru because of a missing feature. Even Word allows you to insert section breaks where you can specigy Landscapre or Portrait.

http://www.codeproject.com/cs/library/giospdfnetlibrary.asp

https://secure.codeproject.com/csharp/giospdfsplittermerger.asp

|||

Yes, this is correct. I appologize for giving you wrong information. Upon looking at our report package implementation, the master report width is set to Landscape. The Create Linked Report button is on the report properties (General Tab) assuming you use the Report Manager and have rights to create linked reports.

|||

Hi,

The mechanism that we've used to achieve this is to write some code using a PDF library to combine the reports. It goes off and renders the reports and then adds them to a master document. That way we can add page numbers, table of contents etc. and its all dynamic.

Sanjay

|||

Hi, and thanks.

That is what we ended up doing and I am posting the code for the benefit of others. We used PDFSharp (there are several others) and I modified one of their samples into the class below. It worked good and we ended up with one report that could have both landscape and portrait pages and page numbers.

#region PDFsharp - A .NET library for processing PDF

//

// Copyright (c) 2005-2006 empira Software GmbH, Cologne (Germany)

//

// http://www.pdfsharp.com

//

// http://sourceforge.net/projects/pdfsharp

//

// Permission is hereby granted, free of charge, to any person obtaining a copy

// of this software and associated documentation files (the "Software"), to deal

// in the Software without restriction, including without limitation the rights

// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

// copies of the Software, and to permit persons to whom the Software is

// furnished to do so, subject to the following conditions:

//

// The above copyright notice and this permission notice shall be included in

// all copies or substantial portions of the Software.

//

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.

// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,

// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR

// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE

// USE OR OTHER DEALINGS IN THE SOFTWARE.

#endregion

using System;

using System.Diagnostics;

using System.IO;

using PdfSharp;

using PdfSharp.Pdf;

using PdfSharp.Pdf.IO;

using PdfSharp.Drawing;

namespace successionManagement

{

public class CombinePdfs

{

public static PdfDocument combine(Stream[] streams, String fileName)

{

PdfDocument outputDocument = new PdfDocument();

XFont font = new XFont("arial", 8, XFontStyle.Regular);

XStringFormat format = new XStringFormat();

format.Alignment = XStringAlignment.Center;

format.LineAlignment = XLineAlignment.Far;

XGraphics gfx;

XRect box;

int totalPages = 0;

int currentPage = 0;

PdfDocument[] pdfDocuments = new PdfDocument[streams.Length];

for (int i = 0; i < streams.Length; i++)

{

Stream stream = (Stream) streamsIdea;

PdfDocument inputDocument = PdfReader.Open(stream, PdfDocumentOpenMode.Import);

totalPages = totalPages + inputDocument.PageCount;

pdfDocumentsIdea = inputDocument;

}

String pageNbrFooter;

for (int i=0; i < pdfDocuments.Length; i++)

{

PdfDocument inputDocument = (PdfDocument) pdfDocumentsIdea;

for (int idx = 0; idx < inputDocument.PageCount; idx++)

{

PdfPage page = inputDocument.Pages[idx];

currentPage = currentPage + 1;

pageNbrFooter = "Page " + currentPage + " of " + totalPages;

page = outputDocument.AddPage(page);

//Write document file name and page number on each page

gfx = XGraphics.FromPdfPage(page);

box = page.MediaBox.ToXRect();

box.Inflate(20, -10);

gfx.DrawString(String.Format( pageNbrFooter,0 ),

font, XBrushes.Black, box, format);

}

}

outputDocument.Save(fileName);

return outputDocument;

}

}

}

To invoke the class you would supply your stream in place of the pdf and the relative path. Here is a simple hard-coded path example.

Stream[] streams = new Stream[5];

streams[0] = new FileStream(@."c:/Lynette/portrait1.pdf", FileMode.Open);

streams[1] = new FileStream(@."c:/Lynette/portrait2.pdf", FileMode.Open);

streams[2] = new FileStream(@."c:/Lynette/portrait3.pdf", FileMode.Open);

streams[3] = new FileStream(@."c:/Lynette/landscape1.pdf", FileMode.Open);

streams[4] = new FileStream(@."c:/Lynette/portrait4.pdf", FileMode.Open);

PdfDocument combinedPdf = CombinePdfs.combine(streams,"c:/Lynette/myCombined.pdf");

|||

The code sample above should have a subscript in brackets but I guess that is also the symbol for an idea. How funny!

|||

Great solution to this issue. Thank you for posting the code!

Combining multiple subreports into a single report

The goal is to produce a single PDF consisting of a number of subreports. Some are landscape, others are portrait. The subreports may also be run as independent reports. The master report that contains them defaults to the width of the widest subreport, which is landscape. This causes all portrait subreports to spill over producing blank pages. Are there any work-arounds to concatenate multiple, single report PDFs into a single PDF and have page numbering too?


Thanks!

Have you tried reducing the body width to landscape? We had a similar requrement which we implemented with linked reports pointing to standalone reports and I don't recall having extra blank pages with mixed layouts.|||

I did check the landscape width for the reports both individualy and in the master report. They all render fine independently. I also tested the report rendering as I added each subreport to the master report. The moment I added the Landscape one, all portrait reports (that rendered fine before) spilled over onto subsequent pages. The subreports are embedded in a main report and not linked. Can you tell me more about how you configured your reports to be linked?

Thanks!

|||

I appologize I meant reducing the body width to portrait regardless of the fact that you have reports set to landscape. I believe at runtime the report server will expand the body width as needed.

A linked report is essentially a smart pointer to the actual report. You can create a linked reportin in the Report Manager. Go to the report properties and click on the Create Linked Report button. The advantage of having this point of indirection is that if the standalone report is moved, the linked report will automatically be redirected to the new location. Also, a linked report can have its own security policies, etc.

|||

Hi,

I was able to find information at this link:

http://msdn2.microsoft.com/en-us/library/ms155993.aspx

"Reporting Services does not provide a way to combine landscape and portrait mode pages in the same report, nor does it provide a way to create a print-based layout that replaces or exists alongside the layout of a report as rendered in a browser or other application. For most exported reports, report printouts include everything that is visible on the report, as viewed by the user on a computer monitor."

Not what I wanted to hear. Also, I was unable to find the Linked Reports option within Report Designer Report Properties. We are using Visual Studio 2005. Someone on the team provided these links for combining PDFs. This seems like a lot of work to go thru because of a missing feature. Even Word allows you to insert section breaks where you can specigy Landscapre or Portrait.

http://www.codeproject.com/cs/library/giospdfnetlibrary.asp

https://secure.codeproject.com/csharp/giospdfsplittermerger.asp

|||

Yes, this is correct. I appologize for giving you wrong information. Upon looking at our report package implementation, the master report width is set to Landscape. The Create Linked Report button is on the report properties (General Tab) assuming you use the Report Manager and have rights to create linked reports.

|||

Hi,

The mechanism that we've used to achieve this is to write some code using a PDF library to combine the reports. It goes off and renders the reports and then adds them to a master document. That way we can add page numbers, table of contents etc. and its all dynamic.

Sanjay

|||

Hi, and thanks.

That is what we ended up doing and I am posting the code for the benefit of others. We used PDFSharp (there are several others) and I modified one of their samples into the class below. It worked good and we ended up with one report that could have both landscape and portrait pages and page numbers.

#region PDFsharp - A .NET library for processing PDF

//

// Copyright (c) 2005-2006 empira Software GmbH, Cologne (Germany)

//

// http://www.pdfsharp.com

//

// http://sourceforge.net/projects/pdfsharp

//

// Permission is hereby granted, free of charge, to any person obtaining a copy

// of this software and associated documentation files (the "Software"), to deal

// in the Software without restriction, including without limitation the rights

// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

// copies of the Software, and to permit persons to whom the Software is

// furnished to do so, subject to the following conditions:

//

// The above copyright notice and this permission notice shall be included in

// all copies or substantial portions of the Software.

//

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.

// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,

// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR

// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE

// USE OR OTHER DEALINGS IN THE SOFTWARE.

#endregion

using System;

using System.Diagnostics;

using System.IO;

using PdfSharp;

using PdfSharp.Pdf;

using PdfSharp.Pdf.IO;

using PdfSharp.Drawing;

namespace successionManagement

{

public class CombinePdfs

{

public static PdfDocument combine(Stream[] streams, String fileName)

{

PdfDocument outputDocument = new PdfDocument();

XFont font = new XFont("arial", 8, XFontStyle.Regular);

XStringFormat format = new XStringFormat();

format.Alignment = XStringAlignment.Center;

format.LineAlignment = XLineAlignment.Far;

XGraphics gfx;

XRect box;

int totalPages = 0;

int currentPage = 0;

PdfDocument[] pdfDocuments = new PdfDocument[streams.Length];

for (int i = 0; i < streams.Length; i++)

{

Stream stream = (Stream) streamsIdea;

PdfDocument inputDocument = PdfReader.Open(stream, PdfDocumentOpenMode.Import);

totalPages = totalPages + inputDocument.PageCount;

pdfDocumentsIdea = inputDocument;

}

String pageNbrFooter;

for (int i=0; i < pdfDocuments.Length; i++)

{

PdfDocument inputDocument = (PdfDocument) pdfDocumentsIdea;

for (int idx = 0; idx < inputDocument.PageCount; idx++)

{

PdfPage page = inputDocument.Pages[idx];

currentPage = currentPage + 1;

pageNbrFooter = "Page " + currentPage + " of " + totalPages;

page = outputDocument.AddPage(page);

//Write document file name and page number on each page

gfx = XGraphics.FromPdfPage(page);

box = page.MediaBox.ToXRect();

box.Inflate(20, -10);

gfx.DrawString(String.Format( pageNbrFooter,0 ),

font, XBrushes.Black, box, format);

}

}

outputDocument.Save(fileName);

return outputDocument;

}

}

}

To invoke the class you would supply your stream in place of the pdf and the relative path. Here is a simple hard-coded path example.

Stream[] streams = new Stream[5];

streams[0] = new FileStream(@."c:/Lynette/portrait1.pdf", FileMode.Open);

streams[1] = new FileStream(@."c:/Lynette/portrait2.pdf", FileMode.Open);

streams[2] = new FileStream(@."c:/Lynette/portrait3.pdf", FileMode.Open);

streams[3] = new FileStream(@."c:/Lynette/landscape1.pdf", FileMode.Open);

streams[4] = new FileStream(@."c:/Lynette/portrait4.pdf", FileMode.Open);

PdfDocument combinedPdf = CombinePdfs.combine(streams,"c:/Lynette/myCombined.pdf");

|||

The code sample above should have a subscript in brackets but I guess that is also the symbol for an idea. How funny!

|||

Great solution to this issue. Thank you for posting the code!

Thursday, March 22, 2012

Combine two or more reports into one PDF Report

We are building a "Annual Statement" which will include a series or Reports
that will be bound into a Booklet. We will need a table of Contents (With
Page Numbers) and also need the pages to be continuous throughout.
Our question is what is the best approach to build this dynamically in
Report Server?
Build One "Master Report which includes Sub-Reports or Build the Sub Reports
and pass them into the Master?
We have a middle "Business Logic" Tier that we will be driving the creation
of these reoprts from.
Thanks!
...BryanUpdate:
I am thinking that we can programattically create a "Master RDL" that
includes the Sub Reports.
Question: would we be able to control the processing of the sub reports so
that they generate first then generate the Master Report genterating the
Table of Contents after the Sub Reports have been created (and we know the
sub Report Page Counts)
Any Suggestions would be really appreachiated
Thanks!
...Bryan
"Bryan E." wrote:
> We are building a "Annual Statement" which will include a series or Reports
> that will be bound into a Booklet. We will need a table of Contents (With
> Page Numbers) and also need the pages to be continuous throughout.
> Our question is what is the best approach to build this dynamically in
> Report Server?
> Build One "Master Report which includes Sub-Reports or Build the Sub Reports
> and pass them into the Master?
> We have a middle "Business Logic" Tier that we will be driving the creation
> of these reoprts from.
> Thanks!
> ...Bryan|||Bryan -
Did you ever get an answer? We are looking to do something similar. The
first page of one of our reports needs to be a table of contents.
Thanks
Jen
"Bryan E." wrote:
> Update:
> I am thinking that we can programattically create a "Master RDL" that
> includes the Sub Reports.
> Question: would we be able to control the processing of the sub reports so
> that they generate first then generate the Master Report genterating the
> Table of Contents after the Sub Reports have been created (and we know the
> sub Report Page Counts)
> Any Suggestions would be really appreachiated
> Thanks!
> ...Bryan
> "Bryan E." wrote:
> > We are building a "Annual Statement" which will include a series or Reports
> > that will be bound into a Booklet. We will need a table of Contents (With
> > Page Numbers) and also need the pages to be continuous throughout.
> >
> > Our question is what is the best approach to build this dynamically in
> > Report Server?
> >
> > Build One "Master Report which includes Sub-Reports or Build the Sub Reports
> > and pass them into the Master?
> >
> > We have a middle "Business Logic" Tier that we will be driving the creation
> > of these reoprts from.
> >
> > Thanks!
> > ...Bryan

Tuesday, March 20, 2012

combine pdf with reporting services pdfs

Through another software package, I generate pdfs which I save. I now want to combine those pdf with pdf output from reporting services. how can i do this?

thks

ken

Hi Ken-

You'd need to create your own delivery extension to do that. I imagine you could add the PDF to the RS rendered PDFs in the Deliver method of your custom delivery provider. Check out the PrinterDeliverySample in the Samples folder where you installed RS. This example can give you an idea of what you need to do to set this up.

Scott

Wednesday, March 7, 2012

column widths changing in PDF export

Hi,
When exporting my report to excel, the column widths change resulting in mis
alignment, and certain columns being place on new pages, which is not very
user friendly at all.
Is there anyway that I can prevent this from happening?
ThanksRob, we had this problem too, and it happens in Excel exports too. The
solution for us was to make sure the overall report with was less than 29cm
and that any Graphics were optimised to the size displayed in the report
(rather than the report shrinking the graphics, for some reason, if the
actual size of the graphic meant that the edge would be displayed off the
page, this would trigger a form feed?)
Hope this helps
Mikey :o)
"Rob" <kothesit@.newsgroup.nospam> wrote in message
news:Ou9TA0ayHHA.2224@.TK2MSFTNGP02.phx.gbl...
> Hi,
> When exporting my report to excel, the column widths change resulting in
> mis alignment, and certain columns being place on new pages, which is not
> very user friendly at all.
> Is there anyway that I can prevent this from happening?
> Thanks
>|||Hi Rob ,
How is everything going? Please feel free to let me know if you need any
assistance.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

Friday, February 24, 2012

column heading is missing on some pdf rendered pages

I am new to RS so this might be a stupid question. Since the page header
can't have table, I have placed the table in the body as table group header.
The table contains column heading for my report. The report produces over a
hundred pages of PDF files. As I scroll through the PDF pages I noticed that
on some pages the column heading is missing. Does anyone know why or is there
a better way to do this?
Thanks,
TimThis might not be the right answer, but my impression is that where pages
break in the web report, and in the PDF exported report, are two different
things. I noticed it when I added a footer with a line to a report. THis
line would show up at the end of each page in the web report, and totally
randomly in the PDF report. And there would be a lot more text on each page
in the web report, than in the PDF. At least this goes for reports with 8pt
font and landscape view.
Try to check if what you see on each page in the PDF corresponds with what
you see in your web report.
Kaisa M. Lindahl
"Tim2Be" <Tim2Be@.discussions.microsoft.com> wrote in message
news:5660FC32-2C75-43F2-BA22-212001F7D535@.microsoft.com...
> I am new to RS so this might be a stupid question. Since the page header
> can't have table, I have placed the table in the body as table group
header.
> The table contains column heading for my report. The report produces over
a
> hundred pages of PDF files. As I scroll through the PDF pages I noticed
that
> on some pages the column heading is missing. Does anyone know why or is
there
> a better way to do this?
> Thanks,
> Tim|||My web report looks perfectly find with all the column heading in tack on all
pages. Only some of the PDF pages that is missing the column heading. I don't
know why it does that.
"Kaisa M. Lindahl" wrote:
> This might not be the right answer, but my impression is that where pages
> break in the web report, and in the PDF exported report, are two different
> things. I noticed it when I added a footer with a line to a report. THis
> line would show up at the end of each page in the web report, and totally
> randomly in the PDF report. And there would be a lot more text on each page
> in the web report, than in the PDF. At least this goes for reports with 8pt
> font and landscape view.
> Try to check if what you see on each page in the PDF corresponds with what
> you see in your web report.
> Kaisa M. Lindahl
> "Tim2Be" <Tim2Be@.discussions.microsoft.com> wrote in message
> news:5660FC32-2C75-43F2-BA22-212001F7D535@.microsoft.com...
> > I am new to RS so this might be a stupid question. Since the page header
> > can't have table, I have placed the table in the body as table group
> header.
> > The table contains column heading for my report. The report produces over
> a
> > hundred pages of PDF files. As I scroll through the PDF pages I noticed
> that
> > on some pages the column heading is missing. Does anyone know why or is
> there
> > a better way to do this?
> >
> > Thanks,
> > Tim
>
>

Sunday, February 19, 2012

Column Header Problems in PDF exports

Hi. I have some matrix style reports that many customers export to PDF.
Most of these are quite large files and span numerous pages. The first 3 - 4
pages of the report look great, then after that the column header is pushed
down into the first data row of the report.
Has anyone run into this or know of a workaround etc.?
Thanks in advance.this is a known microsoft bug is what i found out
"comet61" wrote:
> Hi. I have some matrix style reports that many customers export to PDF.
> Most of these are quite large files and span numerous pages. The first 3 - 4
> pages of the report look great, then after that the column header is pushed
> down into the first data row of the report.
> Has anyone run into this or know of a workaround etc.?
> Thanks in advance.