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.

Converting Word to PDF created white Background / cannot overlay

Thread ID:

Created:

Updated:

Platform:

Replies:

117566 Nov 9,2014 11:59 PM Nov 11,2014 11:22 PM Windows Forms 1
loading
Tags: PDF
Felix Mohr
Asked On November 9, 2014 11:59 PM

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

Praveenkumar H [Syncfusion]
Replied On November 11, 2014 11:22 PM

Hi Felix,

Thank you for using syncfusion products,

We have analyzed your code and found that it is an issue, we have logged the issue report and will fix this internally.

Please let us know if you need further assistance.

With Regards,
Praveen

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.

;