Aurigma Forums
 » 
Graphics Mill
 » 
Discussions – Graphics Mill
 » 
How to open a PDF, add text & an image, and save it as a new file
 
		
        
            
            
	
    | 
Rank: Member
 Groups: Guest
Joined: 3/21/2016(UTC)
 Posts: 23
 
 Thanks: 1 timesWas thanked: 1 time(s) in 1 post(s)
 
 | 
            
	      
                Hey,
 I am trying to wrap my head around how to open a pdf with PDFReader (which is a template), add some text and some images, and then save it out as a new file using PDFWriter... Can someone point me in the right direction?
 
 Thanks :)
 | 
	
    | 
             | 
            
         | 
    |  | 
        
        
        
         
		   
        
            
            
	
    | 
Rank: Advanced Member
 Groups: Guest
Joined: 8/19/2016(UTC)
 Posts: 33
 
 Was thanked: 1 time(s) in 1 post(s)
 | 
            
	      
                Hey Nokturnal, Sorry for being late in answering you. You can use the following code snippet: Code:
var img = new Bitmap(@"image.jpg");
using (var reader = new PdfReader("in.pdf", dpi, dpi))
using (var frame = reader.Frames[0])
using (var container = frame.GetContent())
using (var writer = new PdfWriter("out.pdf"))
{
       writer.AddPage(pageWidth, pageHeight, dpi, dpi);
       using (var graphics = writer.GetGraphics())
       {
              graphics.DrawImage(frame.GetBitmap(), new System.Drawing.RectangleF(0, 0, frame.Width, frame.Height));
              graphics.DrawImage(img, new System.Drawing.RectangleF(0, 0, imgWidth, imgHeight));
              var plainText = new PlainText("Some text", graphics.CreateFont("Arial", 16), new System.Drawing.PointF(20, 30));
              graphics.DrawText(plainText);
       }
 }
 Let me know, if you have any questions/concerns. Kind regards, Julia | 
	
    | 
             | 
            
         | 
    |  | 
        
        
        
    
Aurigma Forums
 » 
Graphics Mill
 » 
Discussions – Graphics Mill
 » 
How to open a PDF, add text & an image, and save it as a new file
 
    
        Forum Jump
         
    
    You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.