Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two image, where i need to insert the first image to first page and second image to second page in the same PDF. How do i achieve this ? sorry, im new in this programming. tq

What I have tried:

private void pdfConverter()
{
    //FIRST PAGE
                  // Create new pdf document and page
    PdfDocument doc = new PdfDocument();
    PdfPage oPage = new PdfPage();

                 // Add the page to the pdf document and add the captured image to it
    doc.Pages.Add(oPage);
    XGraphics xgr = XGraphics.FromPdfPage(oPage);
    XImage img = XImage.FromFile(@"C:\Temp\img1.jpg");
    xgr.DrawImage(img, 0, 0);


    saveFileDialog.Filter = ("PDF File|*.pdf");
    DialogResult btnSave = saveFileDialog.ShowDialog();
    if (btnSave.Equals(DialogResult.OK))
    {
        doc.Save(saveFileDialog.FileName);
        doc.Close();
    }

    img.Dispose();
}
Posted
Updated 12-Sep-17 19:00pm

 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900