PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDF Sharp (VB2010), Draw Image
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1648
Page 1 of 1

Author:  Smithers929 [ Fri May 06, 2011 1:26 pm ]
Post subject:  PDF Sharp (VB2010), Draw Image

Hi there guys,
im new to PDF Sharp and wanted to ask something:

in VB2010 i used

gfx.DrawString(MYLINE, font1, XBrushes.Black, New XRect(50, 120, page1.Width.Point, page1.Height.Point), XStringFormats.TopLeft)


to draw the Text from "MYLINE"



How can i drwa an image?

I wanted to print the image (image.jpg) on Harddisk D:/

The only samples i found, are for C#, not for VB.NET

Can you help me please?
Thank you and sorry for my bad english ;)


Greetings
Vanessa

Author:  ReinerWolff [ Sun May 08, 2011 8:27 am ]
Post subject:  Re: PDF Sharp (VB2010), Draw Image

Hi ho,

you have then to translate the smaple code into VB.
In example this could be something from:
Code:
void DrawImage(XGraphics gfx, int number)
{
BeginBox(gfx, number, "DrawImage (original)");
 
XImage image = XImage.FromFile(jpegSamplePath);
 
// Left position in point
double x = (250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2;
gfx.DrawImage(image, x, 0);
 
EndBox(gfx);
}

To:
Code:
Private Sub DrawImage (GFX As XGraphics, Number as Integer)
  Image as XImage = XImage.FromFile(jpegSamplePath)
  Dim x As Double = ((250 - image.PixelWidth * 72 / image.HorizontalResolution) / 2)
  GFX.DrawImage(Image, x, 0)
End Sub


I haven't tested the code but maybe you get the idea what is to do.

HTH
Greetings from germany
Reiner

Author:  Smithers929 [ Tue May 17, 2011 6:30 pm ]
Post subject:  Re: PDF Sharp (VB2010), Draw Image

Hello Reiner,

nice to see other Germans here^^


In German:

So kann ich es besser weklären ;)

Ich erhalte beim einfügen des Codes 2 Fehler:

Fehler 1
Für den Parameter "GFX" von "Public Sub DrawImage(GFX As PdfSharp.Drawing.XGraphics, Number As Integer)" wurde kein Argument angegeben.


Fehler 2
Für den Parameter "Number" von "Public Sub DrawImage(GFX As PdfSharp.Drawing.XGraphics, Number As Integer)" wurde kein Argument angegeben.


Habe den Private Sub eingefüht und an entsprechender Stelle per DrawImage() aufgerufen.

ohne den Aufruf habeich keine Fehlermeldung - aber ich muss den befehl ja irgendwie aufrufen, damit dieser auch ausgeführt wird, oder?

Danke für deine nette Hilfe
Vanessa

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/