- Code: Select all
string svgFilename = @"C:\path\to\file.svg";
var doc = new Document();
doc.LoadFromFile(@"C:path\to\file.rtf", FileFormat.Rtf);
doc.SaveToSVG(svgFilename);
var svgDoc = Svg.SvgDocument.Open(svgFilename);
var bitmap = svgDoc.Draw();
string svgFilename = @"C:\path\to\file.svg";
var doc = new Document();
doc.LoadFromFile(@"C:path\to\file.rtf", FileFormat.Rtf);
doc.SaveToSVG(svgFilename);
var svgDoc = Svg.SvgDocument.Open(svgFilename);
var bitmap = svgDoc.Draw();
var doc = new Document();
doc.LoadFromFile(@"C:path\to\file.rtf", Spire.Doc.FileFormat.Rtf);
foreach (Section section in doc.Sections)
{
//change page size
section.PageSetup.PageSize = new SizeF(400, 400);
}
doc.SaveToSVG(svgFilename);
Lisa.Li wrote:Hello,
Thanks for your message.
Please try to change the page size to modify the svg size. If there is still any questions, please share us with your rtf file as well as your desired svg effect for further testing. You could attach them here or send them to us via email(support@e-iceblue.com).
- Code: Select all
var doc = new Document();
doc.LoadFromFile(@"C:path\to\file.rtf", Spire.Doc.FileFormat.Rtf);
foreach (Section section in doc.Sections)
{
//change page size
section.PageSetup.PageSize = new SizeF(400, 400);
}
doc.SaveToSVG(svgFilename);
Sincerely,
Lisa
E-iceblue support team
float p1 = w * 72 / 96;
float p2 = h * 72 / 96;
section.PageSetup.PageSize = new SizeF(p1, p2);
.....
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
float width = unitCvtr.ConvertUnits(600, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
float height = unitCvtr.ConvertUnits(600, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
foreach (Spire.Doc.Section section in doc.Sections)
{
//change page size
section.PageSetup.PageSize = new SizeF(width, height);
}
......
Lisa.Li wrote:Hello,
Thanks for your feedback.
Yes, the internal default unit of our Spire.Doc is “point”. You can use the code as you know, or you can refer to the following code to specify.
- Code: Select all
.....
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
float width = unitCvtr.ConvertUnits(600, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
float height = unitCvtr.ConvertUnits(600, PdfGraphicsUnit.Pixel, PdfGraphicsUnit.Point);
foreach (Spire.Doc.Section section in doc.Sections)
{
//change page size
section.PageSetup.PageSize = new SizeF(width, height);
}
......
Meanwhile, you can share us with your rtf file for testing on our side. Look forward to your further reply.
Sincerely,
Lisa
E-iceblue support team
var doc = new Document();
doc.LoadFromFile(..., FileFormat.Rtf);
var bitmap = (Bitmap) doc.SaveToImages(Spire.Doc.Documents.ImageType.Bitmap)[0];
Lisa.Li wrote:Hello,
Thanks for your feedback.
Please refer to this tutorial (How to convert RTF to Image and reset image resolution) to the dpi. If there is any other questions, just feel free to contact us.
Sincerely,
Lisa
E-iceblue support team
Lisa.Li wrote:Hello,
Please refer to the below screenshot to specify the image type as Metafile when you save your rtf. Did you encounter any issues? If so, you can share us with your rtf file as well as the error details for our reference.
Sincerely,
Lisa
E-iceblue support team
Bitmap bitmap = null;
using (var img = doc.SaveToImages(Spire.Doc.Documents.ImageType.Metafile)[0])
{
bitmap = new Bitmap(AppSettings.Instance.SeloSize.Width,
AppSettings.Instance.SeloSize.Height);
bitmap.SetResolution(dpi, dpi);
using (var g = Graphics.FromImage(bitmap))
{
g.DrawImage(img, Point.Empty);
}
}
......
private static Image SetImageOpacity(Image srcImage, int opacity)
{
Bitmap img = new Bitmap(srcImage);
using (Bitmap bmp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(img, 0, 0);
for (int h = 0; h <= img.Height - 1; h++)
{
for (int w = 0; w <= img.Width - 1; w++)
{
Color c = img.GetPixel(w, h);
if (!c.Equals(Color.FromArgb(0, 0, 0, 0)))
{
bmp.SetPixel(w, h, Color.FromArgb(opacity, c.R, c.G, c.B));
}
else
{
bmp.SetPixel(w, h, Color.FromArgb(c.A, c.R, c.G, c.B));
}
}
}
}
Image ninaimg = (Image)bmp.Clone();
ninaimg.Save("result.png");
return (Image)bmp.Clone();
}
}
......
Lisa.Li wrote:Hello,
Sorry our product does not have a direct way to make images transparent. However, you can use the online methods to achieve it, such as the following sample code.
- Code: Select all
......
private static Image SetImageOpacity(Image srcImage, int opacity)
{
Bitmap img = new Bitmap(srcImage);
using (Bitmap bmp = new Bitmap(img.Width, img.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
{
using (Graphics g = Graphics.FromImage(bmp))
{
g.DrawImage(img, 0, 0);
for (int h = 0; h <= img.Height - 1; h++)
{
for (int w = 0; w <= img.Width - 1; w++)
{
Color c = img.GetPixel(w, h);
if (!c.Equals(Color.FromArgb(0, 0, 0, 0)))
{
bmp.SetPixel(w, h, Color.FromArgb(opacity, c.R, c.G, c.B));
}
else
{
bmp.SetPixel(w, h, Color.FromArgb(c.A, c.R, c.G, c.B));
}
}
}
}
Image ninaimg = (Image)bmp.Clone();
ninaimg.Save("result.png");
return (Image)bmp.Clone();
}
}
......
Sincerely,
Lisa
E-iceblue support team