Hi,
I've got an issue with creating a new PDF file by combining other PDF files.
The data seems to be in the PDF but the page is blank when opening.
We got the following process
1) Get a default information PDF (this is static)
2) Create a PDF file for a TIFF, this creates a multi page PDF (in the zip file org_Pdf)
3) Using the following code, we create 1 big PDF
Code:
using (PdfDocument outputDocument = new PdfDocument())
{
PdfDocumentRenderer pdfRenderer;
// loop all small documents
foreach (PdfDocument file in files)
{
if (file.PageCount > 0)
{
pdfRenderer = new PdfDocumentRenderer();
pdfRenderer.DocumentRenderer = new DocumentRenderer(new MigraDoc.DocumentObjectModel.Document());
pdfRenderer.PdfDocument = file;
using (MemoryStream ms = new MemoryStream())
{
pdfRenderer.Save(ms, false);
logger.DebugFormat(CultureInfo.InvariantCulture, "Stream contains {0} bytes of data", ms.Length);
// move to the start of the stream
ms.Seek(0, SeekOrigin.Begin);
ms.Flush();
using (PdfDocument inputDocument = PdfReader.Open(ms, PdfDocumentOpenMode.Import))
{
for (int idx = 0; idx < inputDocument.PageCount; idx++)
{
outputDocument.AddPage(inputDocument.Pages[idx]);
logger.DebugFormat(CultureInfo.InvariantCulture, "Page {0} of document added to big document on page {1}", idx+1, outputDocument.PageCount);
// create extra files to check each PDF page
counter++;
if (!FileHelper.DirExists(@"c:\temp\singlefiles\"))
Directory.CreateDirectory(@"c:\temp\singlefiles\");
using(PdfDocument newDoc = new PdfDocument())
{
newDoc.AddPage(inputDocument.Pages[idx]);
newDoc.Save(@"c:\temp\singlefiles\" + counter + ".pdf");
}
}
}
}
}
}
// add an extra page if its an odd count but not zero
if ((outputDocument.PageCount > 0) && (outputDocument.PageCount % 2 != 0))
{
outputDocument.AddPage(new PdfPage());
logger.Info("Extra page added");
}
outputDocument.Close();
return outputDocument;
}
The issue is that the new PDF created has the correct amount of pages, but the 2nd PDF (created from the TIFF) isn't visible.
This is also true for the single page saves (this is file new_pdf.pdf in the zip).
When looking at the 2 files with notepad++ and comparing them, the data seems the same.
But the attributes/options/ref/... in the file aren't.
In debug mode the issue doesn't exists, only when building the process (in 64-bit) this seems to be not working.
Can some1 shine a light on this issue?
(ps: we also tried to change the corflags of the application to 32bit with the Microsoft tool, but still the same issue)