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.
Syncfusion Feedback

Can we insert an image into an existing pdf that was recently created via doc to pdf converter

Thread ID:

Created:

Updated:

Platform:

Replies:

113819 Oct 10,2013 03:37 PM UTC Oct 18,2013 04:26 AM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
Jeff O''Connell
Asked On October 10, 2013 03:37 PM UTC

Do you have a sample that shows how to Insert an image in an existing pdf that was converted from word Doc originally.  Here's the code that I'm using to convert the word doc.

string ext = Path.GetExtension(file.Name).ToLower();
try
{
 FileStream FS;
 if (ext == ".doc" || ext == ".docx")
 {
 string strFullFileName = strPath + file.Name; 
 FS = File.OpenRead(strFullFileName);
 Stream readFile = FS;               

 WordDocument wordDoc = null;
 // check the word extension type
 if (ext == ".doc")
     wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Doc);
 else if (ext == ".docx")
     wordDoc = new WordDocument(readFile, Syncfusion.DocIO.FormatType.Docx);
 DocToPDFConverter converter = new DocToPDFConverter();
 //Convert word document into PDF document
 PdfDocument pdfDoc = converter.ConvertToPDF(wordDoc);
Could I insert the image here using pdfDoc or is that something that needs after I save the file (see below)


 // set password for security and view preferences
 pdfDoc.ViewerPreferences.FitWindow = true;
 pdfDoc.Security.OwnerPassword = "blahblahblah";

 //pdfDoc.Security.Permissions = Syncfusion.Pdf.Security.PdfPermissionsFlags.Print;
 pdfDoc.ViewerPreferences.PageLayout = PdfPageLayout.TwoPageLeft;
 NewFileName = NewFileName + ".pdf";
 //pdfDoc.Save(NewFileName, Response, HttpReadType.Save);
 pdfDoc.Save(strSavedFileLocation + NewFileName);
Or do I need to retrieve and load the new .pdf I just saved in the location in the line above (pdfDoc.Save) here.

}
catch{}

What I need to do is add/insert our logo 215px x 52px in the upper right hand corner of the first page.

 Any assistance would be greatly appreciated.

Jeff


Praveenkumar H [Syncfusion]
Replied On October 18, 2013 04:26 AM UTC

Hi Jeff,

Thank you for using Syncfusion products,

We have created the sample to insert the image into pdf document as per your requirement.

The sample is attached for your reference.

http://www.syncfusion.com/downloads/support/directtrac/114248/DocToPdfWithImage890510326.zip

We can create the PdfImage as follow.

PdfImage image = PdfImage.FromFile(Server.MapPath('Data/logo.png'));

We can place the image into page as follow.

page.Graphics.DrawImage(image, pageWidth - 215, 0, 215, 52);

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.

Warning Icon 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.Close Icon

;