We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to overlay documents

Thread ID:

Created:

Updated:

Platform:

Replies:

96425 Sep 13,2010 12:15 PM Sep 15,2010 11:45 PM WPF 4
loading
Tags: PDF
kim
Asked On September 13, 2010 12:15 PM

Hi!

I try to overlay documents (http://www.syncfusion.com/products/reporting-edition/pdf/overlay-documents); however, I got an exception.

Would you give me the syntax on how to overlay Documents?

Thanks!


~~~~~~~~~~~~~~


string path1 = @"C:\path1.pdf";
string path2 = @"C:\path2.pdf";
string saveToPath = @"C:\out.pdf";

PdfLoadedDocument loadDocument1 = new PdfLoadedDocument(path1);

PdfLoadedDocument loadDocument2 = new PdfLoadedDocument(path2);

PdfDocument doc = new PdfDocument();
PdfPage page = doc.Pages.Add();
//doc.PageSettings.Size = PdfPageSize.A1;
doc.ImportPage(loadDocument1, (PdfPageBase)page);

doc.ImportPage(loadDocument2, page);

doc.Save(saveToPath);
doc.Close(true);
System.Diagnostics.Process.Start(saveToPath);

~~~~~~~~~~~~~~~


System.Windows.Markup.XamlParseException was unhandled
Message="Cannot create instance of 'Window1' defined in assembly 'SyncfusionPDFPrac, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Window1.xaml' Line 1 Position 9."
Source="PresentationFramework"
LineNumber=1
LinePosition=9
.........
at SyncfusionPDFPrac.Window1..ctor() in C:\Documents and Settings\nvan\My Documents\Visual Studio 2008\Projects\SyncfusionPDFPrac\SyncfusionPDFPrac\Window1.xaml.cs:line 50
InnerException:



Angappan G [Syncfusion]
Replied On September 15, 2010 05:53 AM

Hi Kim,

Thank you for using Essential PDF.

We have analyzed your code snippet and found that you were using the page object of the PdfDocument object in which the pages of the PdfLoadedDocument pages where imported. The importPage method will only accept the page objects of the PdfLoadedDocument. Please refer to the sample for more details.

Please try this and let us know if you have any queries.

Regards,
Angappan.





F96425_6fb36de2.zip

kim
Replied On September 15, 2010 03:37 PM

Thanks for the answer; however, the code is just importing pages (not overlaying documents). (Please check attachment for the overlay document screen shot)( http://www.syncfusion.com/products/reporting-edition/pdf/overlay-documents )


Would you provide some sample code on how to do it?

Thanks!



OverlayDocuments_1284ef66.zip

kim
Replied On September 15, 2010 04:10 PM

Hi!

I got it work now, so thanks again.

Just save time for someone, who are looking for solution like me, the code below is working:


string pdfPath1 = @"C:\file1.pdf";
string pdfPath2 = @"C:\file2.pdf";
string outPdfPath = @"C:\outPdf.pdf";


private void OverlayDocument()
{

PdfLoadedDocument ldDoc1 = new PdfLoadedDocument(this.pdfPath1);
PdfLoadedDocument ldDoc2 = new PdfLoadedDocument(this.pdfPath2);
PdfDocument doc = new PdfDocument();

for (int i = 0, count = ldDoc2.Pages.Count; i < count; ++i)
{
PdfPage page = doc.Pages.Add();
PdfGraphics g = page.Graphics;

PdfPageBase lpage = ldDoc2.Pages[i];
PdfTemplate template = lpage.CreateTemplate();

g.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());

lpage = ldDoc1.Pages[0];
template = lpage.CreateTemplate();

g.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());
}

doc.Save(this.outPdfPath);
System.Diagnostics.Process.Start(this.outPdfPath);
}

Found sample code from:

http://samples.syncfusion.com/ASPNET/7.3.0.20/web/Pdf.Web/samples/3.5/Modify%20Documents/Overlay%20Documents/CS/default.aspx



Angappan G [Syncfusion]
Replied On September 15, 2010 11:45 PM

Hi Kim,

Thanks for the update.

Please let us know if you have any queries.

Regards,
Angappan.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;