Ich versuche, eine XImage Funktion zu schreiben, die ein Bild von einer bestimmten URL liest und es sieht so aus:PDFsharp Ximage keinen Konstruktor enthält, enthält 1 Argument
public static XImage FromURI(string uri)
{
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
webRequest.AllowWriteStreamBuffering = true;
WebResponse webResponse = webRequest.GetResponse();
System.Drawing.Image image = System.Drawing.Image.FromStream(webResponse.GetResponseStream());
webResponse.Close();
PdfSharp.Drawing.XImage ximg = new PdfSharp.Drawing.XImage(image);
return new PdfSharp.Drawing.XImage(image);
}
aber ich bin einen Fehler auf dem immer Linie
return new PdfSharp.Drawing.XImage(image);
Dort heißt es:
XImage does not contain a constructor that contains 1 argument.
Wenn ich die XImage.cs Datei aussehen, es scheint, wie es ein Co hat nstructor mit 1 Argument.
namespace PdfSharp.Drawing
{
//
// Summary:
// Defines an object used to draw image files (bmp, png, jpeg, gif) and PDF forms.
// An abstract base class that provides functionality for the Bitmap and Metafile
// descended classes.
public class XImage : IDisposable
{
//
// Summary:
// Initializes a new instance of the PdfSharp.Drawing.XImage class.
protected XImage();
//
// Summary:
// Gets the vertical resolution of the image.
public virtual double VerticalResolution { get; }
//
// Summary:
// Gets the horizontal resolution of the image.
public virtual double HorizontalResolution { get; }
//
// Summary:
// Gets the size in point of the image.
public virtual XSize Size { get; }
//
// Summary:
// Gets the height of the image in pixels.
public virtual int PixelHeight { get; }
//
// Summary:
// Gets the width of the image in pixels.
public virtual int PixelWidth { get; }
//
// Summary:
// Gets the height of the image in point.
public virtual double PointHeight { get; }
//
// Summary:
// Gets the width of the image in point.
public virtual double PointWidth { get; }
//
// Summary:
// Gets the height of the image.
[Obsolete("Use either PixelHeight or PointHeight. Temporarily obsolete because of rearrangements for WPF. Currently same as PixelHeight, but will become PointHeight in future releases of PDFsharp.")]
public virtual double Height { get; }
//
// Summary:
// Gets the width of the image.
[Obsolete("Use either PixelWidth or PointWidth. Temporarily obsolete because of rearrangements for WPF. Currently same as PixelWidth, but will become PointWidth in future releases of PDFsharp.")]
public virtual double Width { get; }
//
// Summary:
// Gets or sets a flag indicating whether image interpolation is to be performed.
public virtual bool Interpolate { get; set; }
//
// Summary:
// Gets the format of the image.
public XImageFormat Format { get; }
//
// Summary:
// Tests if a file exist. Supports PDF files with page number suffix.
//
// Parameters:
// path:
// The path to a BMP, PNG, GIF, JPEG, TIFF, or PDF file.
public static bool ExistsFile(string path);
//
// Summary:
// Creates an image from the specified file.
//
// Parameters:
// path:
// The path to a BMP, PNG, GIF, JPEG, TIFF, or PDF file.
public static XImage FromFile(string path);
//
// Summary:
// Conversion from Image to XImage.
public static XImage FromGdiPlusImage(Image image);
//
// Summary:
// Under construction
public void Dispose();
//
// Summary:
// Disposes underlying GDI+ object.
protected virtual void Dispose(bool disposing);
//
// Summary:
// Implicit conversion from Image to XImage.
public static implicit operator XImage(Image image);
}
}
Und selbst wenn ich versuche, diese Datei zu reparieren, es kann nicht festgelegt werden, da es ein [von Metadaten] Label hat.
Ich habe keinen Konstruktor mit 1 Parameter in Metadaten bemerkt. Wo ist es? Höchstwahrscheinlich müssen Sie FromGdiPlusImage verwenden. –