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

What is BeginBox() in this code
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3623
Page 1 of 1

Author:  EmotionFever [ Sun Jul 09, 2017 1:55 pm ]
Post subject:  What is BeginBox() in this code

PDFsharp
I don't know what BeginBox in this snippet? Thanks in advance :)
Code:
void DrawImageRotated(XGraphics gfx, int number)
{
  BeginBox(gfx, number, "DrawImage (rotated)");
 
  XImage image = XImage.FromFile(jpegSamplePath);
 
  const double dx = 250, dy = 140;
 
  gfx.TranslateTransform(dx / 2, dy / 2);
  gfx.ScaleTransform(0.7);
  gfx.RotateTransform(-25);
  gfx.TranslateTransform(-dx / 2, -dy / 2);
 
  //XMatrix matrix = new XMatrix();  //XMatrix.Identity;
 
  double width = image.PixelWidth * 72 / image.HorizontalResolution;
  double height = image.PixelHeight * 72 / image.HorizontalResolution;
 
  gfx.DrawImage(image, (dx - width) / 2, 0, width, height);
 
  EndBox(gfx);
}

Author:  TH-Soft [ Sun Jul 09, 2017 7:57 pm ]
Post subject:  Re: Sample of code translated into VB.NET

Hi!

Ignore the semicolons at the end of the lines.
"XImage image =" becomes "Dim image as XImage ="
"new" becomes "New".

BeginBox is a method (a Sub) defined in the same sample.

"//" marks comments.


PDFsharp includes a VB sample (complete sample in the source code ZIP):
http://www.pdfsharp.net/wiki/HelloWorld-sample-VB.ashx

Author:  Thomas Hoevel [ Thu Jul 13, 2017 10:57 am ]
Post subject:  Re: Sample of code translated into VB.NET

Hi!

There are several code converters on the web.
https://www.google.de/?gws_rd=ssl#q=c%23+to+vb.net

Here's what I got:
Code:
Private Sub DrawImageRotated(gfx As XGraphics, number As Integer)
   BeginBox(gfx, number, "DrawImage (rotated)")

   Dim image As XImage = XImage.FromFile(jpegSamplePath)

   Const  dx As Double = 250, dy As Double = 140

   gfx.TranslateTransform(dx / 2, dy / 2)
   gfx.ScaleTransform(0.7)
   gfx.RotateTransform(-25)
   gfx.TranslateTransform(-dx / 2, -dy / 2)

   'XMatrix matrix = new XMatrix();  //XMatrix.Identity;

   Dim width As Double = image.PixelWidth * 72 / image.HorizontalResolution
   Dim height As Double = image.PixelHeight * 72 / image.HorizontalResolution

   gfx.DrawImage(image, (dx - width) / 2, 0, width, height)

   EndBox(gfx)
End Sub

Author:  EmotionFever [ Wed Jul 26, 2017 9:49 am ]
Post subject:  Re: Sample of code translated into VB.NET

TH-Soft wrote:
Hi!
BeginBox is a method (a Sub) defined in the same sample.

Thank you! When I was translating it for the first time I could not figure out why "BeginBox" was giving me errors. I didn't know that it was defined in the sample. Thank you again TH-Soft

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