PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Wed Dec 13, 2017 7:07 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Jul 09, 2017 1:55 pm 
Offline

Joined: Sun Jul 09, 2017 1:32 pm
Posts: 4
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);
}


Last edited by EmotionFever on Wed Jul 26, 2017 12:18 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 09, 2017 7:57 pm 
Offline
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 308
Location: CCAA
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

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 13, 2017 10:57 am 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2740
Location: Cologne, Germany
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

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Jul 26, 2017 9:49 am 
Offline

Joined: Sun Jul 09, 2017 1:32 pm
Posts: 4
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group