Hi,
I have to duplicate pages on a document too.
And I have used the Clone() command
Code:
PdfPage newPage = (PdfPage)Content.Clone();
which is doesn't work has it is already said.
So I would like to use the method of Thomas Hoevel using a document and a memoryStream.
But I don't understand what i can do with a XPdfForm.
SO there is my code :
Code:
// Create new PDF document
PdfDocument document = new PdfDocument();
// Create new page
PdfPage page = document.AddPage(Content);
MemoryStream stream = new MemoryStream();
document.Save(stream, false);
stream.Close();
//this command throw an Exception (The specified stream has no valid PDF file header.)
XPdfForm xpdf = XPdfForm.FromStream(stream);
This exception is thrown in XpdfForm.cs in the internal Ctor
Code:
/// <summary>
/// Initializes a new instance of the <see cref="XPdfForm"/> class from a stream.
/// </summary>
/// <param name="stream">The stream.</param>
internal XPdfForm(Stream stream)
{
// Create a dummy unique path
this.path = "*" + Guid.NewGuid().ToString("B");
if (PdfReader.TestPdfFile(stream) == 0)
throw new ArgumentException("The specified stream has no valid PDF file header.", "stream");
this.externalDocument = PdfReader.Open(stream);
}
Someone has an idea ?