Hi,
we want to convert 2 word files to PDF (one document with the letter header / footer and another for the specific content). We convert both documents to PDF using your DocToPDFConverter class and want to overlay both resulting files, saving the resulting PDF.
Both documents are currently created with another word library but we also have the problems if we create a new document with Word.
When we overlay the pages of both PDFs the resulting file only contains the last page. It seems you set the PDF Background to white instead of transparent when converting the Word document, resulting in the second document overlaying the first one completely.
When i convert both word files using http://www.freepdfconvert.com/ and overlay the resulting PDF files i have no problems. I also tried to save the converted files first and loading them like the externally converted files but that also did not work
Sample Code:
void Main()
{
// Convert existing word files to pdf
PdfDocument invoice = WordToPdf(@"c:\test\invoice.docx");
PdfDocument logo = WordToPdf(@"c:\test\logo.docx");
// or load pdf files converted using http://www.freepdfconvert.com/
// PdfLoadedDocument logo = new PdfLoadedDocument(@"C:\test\logo.pdf");
// PdfLoadedDocument invoice = new PdfLoadedDocument(@"C:\test\invoice.pdf");
// Overlaying According to sample.
var doc = new PdfDocument();
var page = doc.Pages.Add();
var g = page.Graphics;
// overlay the first page of both source files. Using the externally converted files work, converted using SyncFusion only shows the last page
g.DrawPdfTemplate(logo.Pages[0].CreateTemplate(), PointF.Empty, page.GetClientSize());
g.DrawPdfTemplate(invoice.Pages[0].CreateTemplate(), PointF.Empty, page.GetClientSize());
doc.Save(@"c:\test\combined.pdf");
Process.Start(@"c:\test\combined.pdf");
}
PdfDocument WordToPdf(string wordDocPath)
{
WordDocument wordDoc = new WordDocument(wordDocPath);
DocToPDFConverter converter = new DocToPDFConverter();
PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
return pdfDoc;
}
Just create two new word documents (word 2013) with some text on different lines. I attached the new word documents and externally converted files i am used to try the overlay (simple files that have the text "foo" and "bar")
I tried setting the background of the loaded word files to Transparent or none, playing with the pdf layers, ... Nothing helped.
Any help is appreciated
Best regards,
Felix
Attachment:
test_6988f16a.zip